Update the code in the Web API sample projects to only use Swagger / Swagger UI when in the development environment.
Original
|
app.UseSwagger() |
|
.UseSwaggerUI(c => |
|
{ |
|
c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "eShopDashboard.API V1"); |
|
}); |
Update code
https://github.com/dotnet/aspnetcore/blob/d594fc22076db3616a250817c3ca550fcbe69562/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs#L69-L73
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}