fixed swagger

This commit is contained in:
JiriUhlir
2026-06-12 14:29:01 +02:00
parent 06b22dfa4e
commit aad8ba3d03
3 changed files with 26 additions and 5 deletions
+13
View File
@@ -0,0 +1,13 @@
# .NET build output
bin/
obj/
# Rider / Visual Studio
.vs/
.idea/
*.user
# Local env / secrets
*.env
.env
appsettings.*.Local.json
+12 -4
View File
@@ -80,17 +80,25 @@ var app = builder.Build();
if (!string.IsNullOrWhiteSpace(settings.RootPath)) 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.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 => 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.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"; options.DocumentTitle = $"{settings.AppName} API docs";
}); });
+1 -1
View File
@@ -62,7 +62,7 @@ X-ApplicationId: <application id>
## Swagger / OpenAPI ## Swagger / OpenAPI
Interaktivní dokumentace běží na **`/docs`**, surový OpenAPI dokument na `/swagger/v1/swagger.json`. Interaktivní dokumentace běží na **`/docs`**, surový OpenAPI dokument na `/docs/v1/swagger.json`.
Každý agendový endpoint má ve Swaggeru zdokumentované credential hlavičky i popisky operací. Každý agendový endpoint má ve Swaggeru zdokumentované credential hlavičky i popisky operací.
## Pokryté agendy ## Pokryté agendy