From ae548d530ff33b1076f5035b4d79f95752d072c9 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 8 Dec 2025 10:07:57 +0100 Subject: [PATCH] Enable Swagger via configuration setting Added a condition in `Program.cs` to enable Swagger when the `UseSwagger` configuration value is `true`, in addition to the development environment. Introduced a new `UseSwagger` setting in `appsettings.json` with a default value of `true`, allowing Swagger to be conditionally enabled in non-development environments. This improves flexibility for Swagger usage across different environments. --- src/ReC.API/Program.cs | 2 +- src/ReC.API/appsettings.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ReC.API/Program.cs b/src/ReC.API/Program.cs index fb9d327..288ab3d 100644 --- a/src/ReC.API/Program.cs +++ b/src/ReC.API/Program.cs @@ -57,7 +57,7 @@ try #pragma warning restore CS0618 // Configure the HTTP request pipeline. - if (app.Environment.IsDevelopment()) + if (app.Environment.IsDevelopment() || config.GetValue("UseSwagger")) { app.UseSwagger(); app.UseSwaggerUI(); diff --git a/src/ReC.API/appsettings.json b/src/ReC.API/appsettings.json index 132953d..987fdbb 100644 --- a/src/ReC.API/appsettings.json +++ b/src/ReC.API/appsettings.json @@ -5,6 +5,7 @@ "Microsoft.AspNetCore": "Warning" } }, + "UseSwagger": true, "ConnectionStrings": { "Default": "Server=SDD-VMP04-SQL19\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;" },