[backend/openapi] Switch to native Scalar support for multiple OpenAPI documents

This commit is contained in:
Laura Hausmann 2025-03-19 15:33:14 +01:00
parent eb65294219
commit c5650fe3ae
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 5 additions and 3 deletions

View file

@ -62,6 +62,9 @@ public static class WebApplicationExtensions
app.MapScalarApiReference("/scalar", options =>
{
options.WithTitle("Iceshrimp API documentation")
.AddDocument("iceshrimp", "Iceshrimp.NET")
.AddDocument("federation", "Federation")
.AddDocument("mastodon", "Mastodon")
.WithOpenApiRoutePattern("/openapi/{documentName}.json")
.WithModels(false)
.WithCustomCss("""

View file

@ -45,7 +45,7 @@
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="Scalar.AspNetCore" Version="2.0.15" />
<PackageReference Include="Scalar.AspNetCore" Version="2.1.0" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.8-iceshrimp" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />

View file

@ -1,5 +1,4 @@
@page "/openapi"
@attribute [Route("/scalar")]
@using Microsoft.Extensions.Options
@using Swashbuckle.AspNetCore.SwaggerGen
@inject IOptions<SwaggerGenOptions> Options;
@ -18,7 +17,7 @@
<td>
<a href="/openapi/@(doc.Key).json">JSON</a> -
<a href="/swagger/index.html?urls.primaryName=@(doc.Value.Title)">SwaggerUI</a> -
<a href="/scalar/@(doc.Key)">ScalarUI</a>
<a href="/scalar/?api=@(doc.Key)">ScalarUI</a>
</td>
</tr>
}