Skip to content

Instantly share code, notes, and snippets.

@dj-nitehawk
Last active February 22, 2026 05:16
Show Gist options
  • Select an option

  • Save dj-nitehawk/c7052f01f3f650e67fb6782c84d3b5f0 to your computer and use it in GitHub Desktop.

Select an option

Save dj-nitehawk/c7052f01f3f650e67fb6782c84d3b5f0 to your computer and use it in GitHub Desktop.
API Visualization with Scalar
using FastEndpoints.Swagger;
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(); //must come before the UseOpenApi() call
if (app.Environment.IsDevelopment())
{
app.UseOpenApi(c => c.Path = "/openapi/{documentName}.json"); //scalar by default looks for the swagger json file here
app.MapScalarApiReference(o => o.AddDocument("v1")); //inform scalar your doc names
}
app.Run();
//scalar ui can be accessed at: http://localhost:{port}/scalar
@dj-nitehawk
Copy link
Author

dj-nitehawk commented Jan 16, 2026

@matthewj-dev
sorry i just saw your question. github didn't send a notification for some reason.
there's no way around having to tell scalar what your "non-default" document name is. but you only need to specify the document name like so:

app.MapScalarApiReference(o => o.AddDocument("my-api-v1"));

visiting /scalar will automatically load up that document since scalar knows about it.
or you'd have to manually visit /scalar/my-api-v1

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