fixed swagger
This commit is contained in:
+12
-4
@@ -80,17 +80,25 @@ var app = builder.Build();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(settings.RootPath))
|
||||
{
|
||||
app.UsePathBase(settings.RootPath);
|
||||
// UsePathBase requires a leading slash; tolerate ROOT_PATH configured without one.
|
||||
var basePath = settings.RootPath.StartsWith('/') ? settings.RootPath : "/" + settings.RootPath;
|
||||
app.UsePathBase(basePath);
|
||||
}
|
||||
|
||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||
|
||||
app.UseSwagger();
|
||||
// Serve the OpenAPI document under the same /docs prefix as the UI so a relative endpoint
|
||||
// resolves correctly both locally and behind a reverse-proxy path base (ROOT_PATH).
|
||||
app.UseSwagger(options =>
|
||||
{
|
||||
options.RouteTemplate = "docs/{documentName}/swagger.json";
|
||||
});
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
// Serve the interactive docs at /docs (matching the sibling microsoft-365-service).
|
||||
// Interactive docs at /docs (matching the sibling microsoft-365-service).
|
||||
options.RoutePrefix = "docs";
|
||||
options.SwaggerEndpoint("/swagger/v1/swagger.json", $"{settings.AppName} v1");
|
||||
// Relative endpoint — resolves to {pathBase}/docs/v1/swagger.json in the browser.
|
||||
options.SwaggerEndpoint("v1/swagger.json", $"{settings.AppName} v1");
|
||||
options.DocumentTitle = $"{settings.AppName} – API docs";
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user