Skip to content

Instantly share code, notes, and snippets.

@dj-nitehawk
Last active January 30, 2025 08:40
Show Gist options
  • Save dj-nitehawk/c7052f01f3f650e67fb6782c84d3b5f0 to your computer and use it in GitHub Desktop.
Save dj-nitehawk/c7052f01f3f650e67fb6782c84d3b5f0 to your computer and use it in GitHub Desktop.
API Visualization with Scalar
using Scalar.AspNetCore; //dotnet add package Scalar.AspNetCore
var bld = WebApplication.CreateBuilder(args);
bld.Services
.AddFastEndpoints()
.SwaggerDocument(); //define a swagger doc - v1 by default
var app = bld.Build();
app.UseFastEndpoints();
if (app.Environment.IsDevelopment())
{
//scalar by default looks for the swagger json file here:
app.UseOpenApi(c => c.Path = "/openapi/{documentName}.json");
app.MapScalarApiReference();
}
app.Run();
//scalar ui can be accessed at: http://localhost:{port}/scalar/v1
@mkosucu
Copy link

mkosucu commented Jan 29, 2025

If I use this approach, the Model names include namespaces too, i.e. ScalartestMyRequest I tried multiple ways, but could not transform the model names, expected name MyRequest, Do you have any idea how to resolve this? @dj-nitehawk

@dj-nitehawk
Copy link
Author

@mkosucu
that has nothing to do with scalar. pls refer to the following docs:
schema names: https://fast-endpoints.com/docs/swagger-support#short-schema-names
endpoint names: https://fast-endpoints.com/docs/swagger-support#short-endpoint-names

@mkosucu
Copy link

mkosucu commented Jan 30, 2025

I have been looking somewhere completely irrelevant! Many thanks for your help @dj-nitehawk . Appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment