To recreate:
dotnet new webapi
- Add packages Swashbuckle.AspNetCore and Swashbuckle.AspNetCore.Annotations to your
csproj
file. - Change the
Program.cs
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "WebApi9", Version = "v1" });
});
builder.Services.AddMvcCore().AddApiExplorer();
and
app.MapSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApi9 v1");
c.RoutePrefix = string.Empty; // Set Swagger UI at the app's root
});