feat: make Swagger/Scalar available outside Development via UseSwagger flag
Previously Swagger UI was only registered in Development. Add a 'UseSwagger' config key so staging/production environments can opt in without code changes.
This commit is contained in:
@@ -383,9 +383,6 @@ try
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseWebAssemblyDebugging();
|
app.UseWebAssemblyDebugging();
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI();
|
|
||||||
app.MapScalarApiReference();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -393,6 +390,14 @@ try
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var useSwagger = app.Environment.IsDevelopment() || config.GetValue<bool>("UseSwagger");
|
||||||
|
if (useSwagger)
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
app.MapScalarApiReference();
|
||||||
|
}
|
||||||
|
|
||||||
// Set CORS policy
|
// Set CORS policy
|
||||||
app.UseCors("AllowSpecificOriginsPolicy");
|
app.UseCors("AllowSpecificOriginsPolicy");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user