diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14ab506 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# .NET build output +bin/ +obj/ + +# Rider / Visual Studio +.vs/ +.idea/ +*.user + +# Local env / secrets +*.env +.env +appsettings.*.Local.json diff --git a/Program.cs b/Program.cs index e7182f7..dd6d069 100644 --- a/Program.cs +++ b/Program.cs @@ -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(); -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"; }); diff --git a/README.md b/README.md index d0996c0..929b07a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ X-ApplicationId: ## 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í. ## Pokryté agendy