44 lines
2.2 KiB
C#
44 lines
2.2 KiB
C#
namespace Netina.Api.WebFramework.ScalarUi;
|
||
|
||
public static class ScalarUiConfiguration
|
||
{
|
||
public static void MapScalarUi(this IEndpointRouteBuilder app)
|
||
{
|
||
app.MapGet("/scalar/{documentName}", (string documentName) =>
|
||
{
|
||
|
||
var scalarScript = $$"""
|
||
<!doctype html>
|
||
<html>
|
||
<head>
|
||
<title>Scalar API Reference</title>
|
||
<meta charset="utf-8" />
|
||
<meta
|
||
name="viewport"
|
||
content="width=device-width, initial-scale=1" />
|
||
</head>
|
||
<body>
|
||
<!-- Add your own OpenAPI/Swagger specification URL here: -->
|
||
<!-- Note: The example is our public proxy (to avoid CORS issues). You can remove the `data-proxy-url` attribute if you don’t need it. -->
|
||
<script
|
||
id="api-reference"
|
||
data-url="/swagger/{{documentName}}/swagger.json"></script>
|
||
|
||
<!-- Optional: You can set a full configuration object like this: -->
|
||
<script>
|
||
var configuration = {
|
||
theme: 'bluePlanet',
|
||
}
|
||
|
||
document.getElementById('api-reference').dataset.configuration =
|
||
JSON.stringify(configuration)
|
||
</script>
|
||
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
||
</body>
|
||
</html>
|
||
""";
|
||
|
||
return Results.Content(scalarScript, "text/html");
|
||
}).ExcludeFromDescription();
|
||
}
|
||
} |