Installation

  1. Install the Swashbuckle.AspNetCore metapackage into your ASP.NET Core application:

    > dotnet add package Swashbuckle.AspNetCore
    

    or via Package Manager …

    > Install-Package Swashbuckle.AspNetCore
    
  2. In the ConfigureServices method of Startup.cs, register the Swagger/OpenAPI generator

  3. Ensure your API actions and parameters are decorated with explicit “Http” and “From” bindings.

    NOTE: If you omit the explicit parameter bindings, the generator will describe them as “query” params by default.

  4. In the Configure method, insert middleware to expose the generated Swagger/OpenAPI document as a JSON endpoint

    At this point, you can spin up your application and view the generated Swagger/OpenAPI JSON at “/swagger/v1/swagger.json.”

  5. Optionally, if you want to expose interactive documentation, insert the Swagger UI middleware.

    Now you can restart your application and check out the auto-generated, interactive docs at “/swagger”.