Monday 2 May 2022

Get started with Swashbuckle and ASP.NET Core

https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-6.0&tabs=visual-studio

  • Swagger
  • SwaggerGen
  • SwaggerUI


SwaggerUI 

https://localhost:7147/swagger




SwaggerEndpoint
https://localhost:7147/swagger/v1/swagger.json







Package installation
Install the package on the exiting TodoAPI project



API info and description

By changing Program.cs, you can make root url to point to Swagger.

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
    app.UseSwagger();
    //app.UseSwaggerUI();
    app.UseSwaggerUI(options =>
    {
        options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
        options.RoutePrefix = string.Empty;
    });
}

BEFORE:



AFTER:



XML Comments etc seems not working when I tried.




No comments:

Post a Comment