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:
2026-09-24 12:02:08 +02:00
parent 454dd0b6cc
commit 32a9d008a4
2 changed files with 10 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -1,5 +1,6 @@
{
"UseSwagger": true,
"UseScalar": true,
"UseDbMigration": false,
"DiPMode": true,
"Logging": {