Swagger tooling for API’s built with ASP.NET Core. Generate beautiful API documentation, including a UI to explore and test operations, directly from your routes, controllers and models.
Full document can be found here
So let start. First we need to install this package
Install-Package Swashbuckle.AspNetCore
In order to wire up swagger we need to add these following line in Startup.cs
public void ConfigureServices(IServiceCollection services) { services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Version = "v1", Title = "Awesome CMS Core API V1", Contact = new Contact { Name = "Tony Hudson", Email = "", Url = "https://github.com/ngohungphuc" } }); }); } public void Configure(IApplicationBuilder app) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint($"/swagger/v1/swagger.json", "Awesome CMS Core API V1"); }); }
We need to modify a litte bit for our app properties.
Then run our app we will see the swagger ui
In this post I will show you guy how to integrate Swagger with API versioning. Happy coding !!!