From a1174e3b4299df19e229272b716e0d82d08b228d Mon Sep 17 00:00:00 2001 From: ThompsonNye Date: Sun, 15 Jun 2025 11:29:46 +0200 Subject: [PATCH] Expose swagger UI again --- src/Vegasco.Server.Api/Common/StartupExtensions.cs | 14 +++++++++++++- src/Vegasco.Server.Api/Vegasco.Server.Api.csproj | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Vegasco.Server.Api/Common/StartupExtensions.cs b/src/Vegasco.Server.Api/Common/StartupExtensions.cs index 679a213..ada640e 100644 --- a/src/Vegasco.Server.Api/Common/StartupExtensions.cs +++ b/src/Vegasco.Server.Api/Common/StartupExtensions.cs @@ -1,4 +1,5 @@ -using Vegasco.Server.Api.Endpoints; +using Asp.Versioning.ApiExplorer; +using Vegasco.Server.Api.Endpoints; using Vegasco.Server.ServiceDefaults; namespace Vegasco.Server.Api.Common; @@ -36,6 +37,17 @@ internal static class StartupExtensions if (app.Environment.IsDevelopment()) { app.MapOpenApi("/swagger/{documentName}/swagger.json"); + app.UseSwaggerUI(o => + { + // Create a Swagger endpoint for each API version + IReadOnlyList apiVersions = app.DescribeApiVersions(); + foreach (ApiVersionDescription apiVersionDescription in apiVersions) + { + string url = $"/swagger/{apiVersionDescription.GroupName}/swagger.json"; + string name = apiVersionDescription.GroupName.ToUpperInvariant(); + o.SwaggerEndpoint(url, name); + } + }); } return app; diff --git a/src/Vegasco.Server.Api/Vegasco.Server.Api.csproj b/src/Vegasco.Server.Api/Vegasco.Server.Api.csproj index f09473e..6b8436f 100644 --- a/src/Vegasco.Server.Api/Vegasco.Server.Api.csproj +++ b/src/Vegasco.Server.Api/Vegasco.Server.Api.csproj @@ -31,6 +31,7 @@ +