Merge pull request 'Applied api reference redirect on root path' (#3) from payments into master
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Asp.Versioning.Builder;
|
||||
using k8s.Models;
|
||||
using LiteCharms.Features.Extensions;
|
||||
using LiteCharms.Features.Mediator;
|
||||
using LiteCharms.Features.MidrandBooks.Extensions;
|
||||
@@ -74,6 +75,10 @@ app.UseHealthChecks("/ready");
|
||||
|
||||
app.MapOpenApi();
|
||||
|
||||
var apiVersions = app.DescribeApiVersions()
|
||||
.OrderByDescending(o => o.ApiVersion.MajorVersion)
|
||||
.ToList();
|
||||
|
||||
foreach (var description in app.DescribeApiVersions().OrderByDescending(o => o.ApiVersion.MajorVersion))
|
||||
app.MapScalarApiReference($"/openapi/{description.GroupName}", (options, context) =>
|
||||
{
|
||||
@@ -84,6 +89,10 @@ foreach (var description in app.DescribeApiVersions().OrderByDescending(o => o.A
|
||||
options.Authentication = new ScalarAuthenticationOptions { PreferredSecuritySchemes = ["Bearer"] };
|
||||
});
|
||||
|
||||
var latestVersionGroup = apiVersions.FirstOrDefault()?.GroupName ?? "v1";
|
||||
|
||||
app.MapGet("/", () => Results.Redirect($"/openapi/{latestVersionGroup}"))
|
||||
.ExcludeFromDescription();
|
||||
|
||||
if (!app.Environment.IsDevelopment())
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
|
||||
Reference in New Issue
Block a user