Installation¶
Install the
Swashbuckle.AspNetCoremetapackage into your ASP.NET Core application:> dotnet add package Swashbuckle.AspNetCore
or via Package Manager …
> Install-Package Swashbuckle.AspNetCore
In the
ConfigureServicesmethod ofStartup.cs, register the Swagger/OpenAPI generatorEnsure 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.
In the
Configuremethod, insert middleware to expose the generated Swagger/OpenAPI document as a JSON endpointAt this point, you can spin up your application and view the generated Swagger/OpenAPI JSON at “/swagger/v1/swagger.json.”
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”.