Coder Social home page Coder Social logo

donalfenwick / swashbuckle.swaggertopostman Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 40 KB

AspNetCore middleware which uses the Swashbuckle.AspNetCore library produce a postman collection (v2.1) from the swagger schema generated by swashbuckle.

License: MIT License

C# 100.00%

swashbuckle.swaggertopostman's Introduction

Build Status

Swashbuckle.SwaggerToPostman

AspNetCore middleware which leverages the swagger doc schema information generated by the wonderful Swashbuckle.AspNetCore library to generate a JSON postman collection (schema version 2.1). This json document can be imported into the postman client application providing pre-populated requests for any api controllers included in the swagger doc schema.

Instalation

Note: This plugin will install swashbuckle as a dependency and requires that you also configure it within your aspnet core project

  1. Install the latest version from here on nuget NOTE: This is an alpha version

  2. Call the services.AddSwaggerToPostman() extension method in the ConfigureServices method of your applications Startup.cs after the services.AddSwaggerGen() is called for the Swashbuckle library. This will register the required types in the applications DI container.

  public void ConfigureServices(IServiceCollection services)
   {
      services.AddMvc();
      services.AddSwaggerGen(c =>
      {
          c.SwaggerDoc("v1", new Info { Title = "Swashbuckle to postman test API", Version = "v1" });
      });

      services.AddSwaggerToPostman();
  }
  1. Call the app.UseSwaggerToPostman() extension method from the Configure method in your Startup.cs class after you call to app.UseSwagger(). This will register the middleware in the api.net pipeline and expose a json document that can be imported by the postman http client.

    By default, the route to this document is ~/postman/{documentname}/collection.json where document name is the name provided in the options when calling AddSwaggerGen(). In the example above the document name is v1.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseMvc();
    app.UseSwagger();

    app.UseSwaggerToPostman();
}

Importing the collection in postman

To import the collection into postman click on the import button from the top menu within the app. In the modal that appears choose "Import from link" and paste your your postman collection url into the dialog box.

Please ensure that you are using a recent version of postman and choose schema version 2.1 if prompted during the import.

swashbuckle.swaggertopostman's People

Contributors

donalfenwick avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

yangxueminghao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.