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.
This commit is contained in:
tekh 2025-12-08 10:07:57 +01:00
parent b71ea7d346
commit ae548d530f
2 changed files with 2 additions and 1 deletions

View File

@ -57,7 +57,7 @@ try
#pragma warning restore CS0618
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
if (app.Environment.IsDevelopment() || config.GetValue<bool>("UseSwagger"))
{
app.UseSwagger();
app.UseSwaggerUI();

View File

@ -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;"
},