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 useSwagger = app.Environment.IsDevelopment() || config.GetValue<bool>("UseSwagger");
|
||||||
|
var useScalar = app.Environment.IsDevelopment() || config.GetValue<bool>("UseScalar");
|
||||||
|
|
||||||
if (useSwagger)
|
if (useSwagger)
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useScalar)
|
||||||
|
{
|
||||||
|
if (!useSwagger)
|
||||||
|
app.UseSwagger(); // Scalar requires the OpenAPI JSON endpoint
|
||||||
|
|
||||||
app.MapScalarApiReference();
|
app.MapScalarApiReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"UseSwagger": true,
|
"UseSwagger": true,
|
||||||
|
"UseScalar": true,
|
||||||
"UseDbMigration": false,
|
"UseDbMigration": false,
|
||||||
"DiPMode": true,
|
"DiPMode": true,
|
||||||
"Logging": {
|
"Logging": {
|
||||||
|
|||||||
Reference in New Issue
Block a user