From 2231d160701590eb7d03b30aca6e59ad12b0d267 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Mon, 22 Apr 2024 16:52:01 -0700 Subject: [PATCH] Put Swagger UI behind development check (WebApiSample.Api.31) --- .../samples/3.x/WebApiSample.Api.31/Startup.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aspnetcore/web-api/action-return-types/samples/3.x/WebApiSample.Api.31/Startup.cs b/aspnetcore/web-api/action-return-types/samples/3.x/WebApiSample.Api.31/Startup.cs index 8064c77c50..76656ed6a7 100644 --- a/aspnetcore/web-api/action-return-types/samples/3.x/WebApiSample.Api.31/Startup.cs +++ b/aspnetcore/web-api/action-return-types/samples/3.x/WebApiSample.Api.31/Startup.cs @@ -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();