Three simple steps to enable Swagger on ASP.NET Core WebAPI

Step 1. Install NuGet package:

Install-Package Swashbuckle.AspNetCore

Step 2. Navigate to Startup.cs and add following code inside ConfigureServices() method


services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
});

Step 3. Add following code inside Configure() method


app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
);

Voila!

Based onĀ https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual-studio