Merge pull request #32373 from dotnet/captainsafia-patch-2

Put Swagger UI behind development check (WebApiSample.Api.31)
pull/32374/head
Rick Anderson 2024-04-22 14:26:59 -10:00 committed by GitHub
commit 245b90eda0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -57,11 +57,14 @@ namespace WebApiSample.Api._31
app.UseHttpsRedirection();
app.UseSwagger();
app.UseSwaggerUI(c =>
if (env.IsDevelopment())
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My ASP.NET Core 3.0 web API v1");
c.RoutePrefix = string.Empty;
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My ASP.NET Core 3.0 web API v1");
c.RoutePrefix = string.Empty;
});
}
app.UseRouting();
app.UseAuthorization();