feat(api): add Scalar API reference with independent toggle
Decouple Scalar from Swagger so each can be enabled/disabled separately via the UseScalar config flag. When Scalar is enabled without Swagger, the bare OpenAPI JSON endpoint is still registered so Scalar has a spec to load from. - Add UseScalar flag to appsettings.json (default: true) - Resolve useScalar from config in Program.cs - Map Scalar only when useScalar is true - Ensure UseSwagger() is called if Scalar needs it but Swagger UI is off
This commit is contained in:
@@ -391,10 +391,19 @@ try
|
||||
}
|
||||
|
||||
var useSwagger = app.Environment.IsDevelopment() || config.GetValue<bool>("UseSwagger");
|
||||
var useScalar = app.Environment.IsDevelopment() || config.GetValue<bool>("UseScalar");
|
||||
|
||||
if (useSwagger)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
if (useScalar)
|
||||
{
|
||||
if (!useSwagger)
|
||||
app.UseSwagger(); // Scalar requires the OpenAPI JSON endpoint
|
||||
|
||||
app.MapScalarApiReference();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"UseSwagger": true,
|
||||
"UseScalar": true,
|
||||
"UseDbMigration": false,
|
||||
"DiPMode": true,
|
||||
"Logging": {
|
||||
|
||||
Reference in New Issue
Block a user