dotnet new webapi
dotnet add package swashbuckle.aspnetcore
Add code:
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(options => {
options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo());
});
}
Add more code:
app.UseSwagger();
app.UseSwaggerUI(options => {
options.SwaggerEndpoint("v1/swagger.json", "My API V1");
});
Run it,
go here:
https://localhost:5001/swagger/index.html