How to do it...

  1. First, let's add the Swashbuckle reference to the project:
"Swashbuckle": "5.6.0"
  1. 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();}
  1. Now, let's launch our API documentation by going to http://{UrlAPI}/swagger/ui. We can now see the generated API documentation:
  1. When we click on each HTTP method, we can see all the options Swagger offers to us, such as testing the API, easily:
  1. Next, let's use another feature: ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.