Skip to content

Show multiple versions in scalar viewer in a quirky manner#182

Merged
LucHeart merged 1 commit intoOpenShock:developfrom
Docteh:urls
Apr 20, 2025
Merged

Show multiple versions in scalar viewer in a quirky manner#182
LucHeart merged 1 commit intoOpenShock:developfrom
Docteh:urls

Conversation

@Docteh
Copy link
Copy Markdown
Contributor

@Docteh Docteh commented Apr 18, 2025

So for whatever reason, the routing really doesn't like the idea of routing to a single field, like /favicon.ico or /scalar
To work around this, I propose we add some additional routing so that we can access the API documentation at /scalar/viewer so that users can go there and then choose which version of the API they wish to view

Screenshot of what I'm talking about:
image

So for whatever reason, the routing really doesn't like the idea of routing
to a single field, like /favicon.ico or /scalar
To work around this, I propose we add some additional routing so that we can
access the API documentation at /scalar/viewer so that users can go there and
then choose which version of the API they wish to view
@LucHeart
Copy link
Copy Markdown
Member

I'm not sure I understand? Why wouldn't a top level path work?

@LucHeart
Copy link
Copy Markdown
Member

so scalar does support multiple versions with s selector also?

@Docteh
Copy link
Copy Markdown
Contributor Author

Docteh commented Apr 18, 2025

So if you visit https://api.openshock.app/scalar/ you get this sort of response where it is considering scalar to be a version

{"type":"https://docs.api-versioning.org/problems#invalid","title":"Invalid API version","status":400,"detail":"The HTTP resource that matches the request URI 'https://api.openshock.app/scalar/' does not support the API version 'scalar'.","traceId":"00-5de463b17daaa109d66234e9da0d96b5-8e832d76733ff076-00"}

I did some digging around, and tinkering, if you add routes like this to Program.cs the one for /test also gives an error, specifically test is an invalid version, the other two routes function normally

app.MapGet("/", () => "Hello World!1");
app.MapGet("/test", () => "Hello World!2");
app.MapGet("/test/test", () => "Hello World!3");

For scalar, it does support multiple versions with a selector, downside is that you have to specify which documents to show. Which is done by the two calls to AddDocument. They added it a month ago in scalar/scalar#5029

2025-04-18.12-50-54.mp4

@LucHeart LucHeart merged commit e0ca22a into OpenShock:develop Apr 20, 2025
3 of 5 checks passed
@Docteh Docteh deleted the urls branch May 13, 2025 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants