From f3cedee02a2a541ff4ddde9386c25826e131805a Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Mon, 22 Apr 2024 16:50:08 -0700 Subject: [PATCH] Put Swagger UI behind an environment check --- .../samples/2.1/TodoApi.NSwag/Startup.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/2.1/TodoApi.NSwag/Startup.cs b/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/2.1/TodoApi.NSwag/Startup.cs index 846609ac4f..097449ae83 100644 --- a/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/2.1/TodoApi.NSwag/Startup.cs +++ b/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/2.1/TodoApi.NSwag/Startup.cs @@ -28,10 +28,13 @@ namespace TodoApi // Register the Swagger generator and the Swagger UI middlewares app.UseOpenApi(); - app.UseSwaggerUi3(); + if (app.Environment.IsDevelopment()) + { + app.UseSwaggerUi3(); + } app.UseMvc(); } // } -} \ No newline at end of file +}