- First, let's add the Swashbuckle reference to the project:
"Swashbuckle": "5.6.0"
- Next, let's add Swagger as a middleware in Startup.cs:
public void ConfigureServices(IServiceCollection services){ services.AddMVC(); services.AddSwaggerGen();}public void Configure(IApplicationBuilder app){ app.UseMVC(); app.UseSwagger(); app.UseSwaggerUi();}
- Now, let's launch our API documentation by going to http://{UrlAPI}/swagger/ui. We can now see the generated API documentation:
- When we click on each HTTP method, we can see all the options Swagger offers to us, such as testing the API, easily:
- Next, let's use another feature: ...