Skip to content

Conversation

@mclean25
Copy link

@mclean25 mclean25 commented Sep 26, 2025

When a title is given, it should be given the highest precedence for use in a friendly name since it's explicity stated and that is the purpose of title.

Closes #6952

Problem

Currently, even when you use title to give your dropdown a friendly name, it wont be used (see #6952).

Solution

title is given the highest precedence since it is explicitly used as a friendly name by the user.

Checklist

I've gone through the following:

  • I've added an explanation why this change is needed.
  • I've added a changeset (pnpm changeset).
  • I've added tests for the regression or new feature.
  • I've updated the documentation. (Looked through and don't see anything pertaining to this explicitly).

Note

Prioritizes title over types/arrays/xml/const when computing schema friendly names and updates tests; adds changeset for minor release.

  • api-reference:
    • get-schema-type.ts:
      • Changes priority so title is used first for friendly names (before const, arrays, xml.name, contentEncoding, refs, raw type).
      • Array handling reflects item title when present (e.g., array Mixed Item[]).
    • Tests (get-schema-type.test.ts):
      • Update expectations to prefer title over array unions and in complex schemas.
      • Use title for arrays even when items are defined; add case for item titles within arrays.
  • Changeset:
    • Minor bump for @scalar/api-reference; note that title has highest precedence for anyof.

Written by Cursor Bugbot for commit 0e69342. This will update automatically on new commits. Configure here.

When a `title` is given, it should be given the highest precedence for
use in a friendly name since it's explicity stated and that is the
purpose of `title`.

Closes scalar#6952
@changeset-bot
Copy link

changeset-bot bot commented Sep 26, 2025

🦋 Changeset detected

Latest commit: 0e69342

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@scalar/api-reference Minor
@scalar/aspire Patch
@scalar/aspnetcore Patch
@scalarapi/docker-api-reference Patch
@scalar/fastify-api-reference Minor
@scalar/webjar Patch
@scalar/nuxt Patch
@scalar/api-reference-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mclean25 mclean25 marked this pull request as ready for review September 26, 2025 22:41
cursor[bot]

This comment was marked as outdated.

Copy link
Member

@amritk amritk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks for the quick PR! It works for me (@hanspagel ?)

also should we bump down const or just delete it? I'm not sure I see the value

@amritk amritk changed the title Ranking explicit title declaration as highest friendly name fix(api-reference): ranking explicit title declaration as highest friendly name Sep 26, 2025
Copy link
Member

@marclave marclave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a minor release?

Copy link
Member

@hanspagel hanspagel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to submit this PR! We should also keep in mind that fastapi users get a title as a default for all types:

Sooo it might be a little bit more complex to serve everyone well.

Just a quick feedback from me, I’ll think about a good solution.

@mclean25
Copy link
Author

mclean25 commented Sep 29, 2025

Thanks for taking the time to submit this PR! We should also keep in mind that fastapi users get a title as a default for all types:

Sooo it might be a little bit more complex to serve everyone well.

Just a quick feedback from me, I’ll think about a good solution.

Got it, was thinking there had to be a reason for it to be this way originally.

Just a thought--shouldn't this be as tool-agnostic as possible? I haven't used fastapi in ages, but from a design philosophy isn't it more strange that fastapi provides titles that aren't meant for display purposes? IE: from my naive vantage point it seems more like a fastapi limitation than a scalar one.

@hanspagel
Copy link
Member

I agree in theory. In practive, I also have to accept that it’s the reality (and won’t change) and the FastAPI user base is huge. Everyone deserves a beautiful API reference.

@tibbe
Copy link

tibbe commented Oct 30, 2025

Just a thought--shouldn't this be as tool-agnostic as possible? I haven't used fastapi in ages, but from a design philosophy isn't it more strange that fastapi provides titles that aren't meant for display purposes? IE: from my naive vantage point it seems more like a fastapi limitation than a scalar one.

Titles are meant for display purposes but they are not the same as types (even in the OpenAPI spec). There are three pieces of data:

  • field name (or query parameter name)
  • type
  • title

The former two are required to use an API correctly. The last one is a nice to have. It can't be used to replace either of the above two (especially not in a scalar case, such as for query parameters).

@hanspagel
Copy link
Member

@tibbe yep

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anyof not showing title when provided

5 participants