Skip to content

fix(fastapi): theme #6526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

fix(fastapi): theme #6526

wants to merge 2 commits into from

Conversation

zrquan
Copy link

@zrquan zrquan commented Aug 12, 2025

Problem

After #6256, we don't have to use hardcoded theme styles anymore. Also, if we set the theme but not the scalar_theme, the hardcoded style will take priority and make the theme ineffective.

Solution

With this PR …

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.

@zrquan zrquan requested a review from marclave as a code owner August 12, 2025 10:38
Copy link

changeset-bot bot commented Aug 12, 2025

🦋 Changeset detected

Latest commit: 4404ef2

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

This PR includes changesets to release 1 package
Name Type
scalar-fastapi 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

@hanspagel
Copy link
Member

Wait, can you elaborate on the issue? We definitely want to keep a custom theme for FastAPI as the default. There must be another way to fix the issue.

@hanspagel hanspagel marked this pull request as draft August 12, 2025 11:31
@hanspagel hanspagel changed the title Fix fastapi theme fix(fastapi): theme Aug 12, 2025
@zrquan
Copy link
Author

zrquan commented Aug 13, 2025

Wait, can you elaborate on the issue?

I've tried setting the theme option, but the theme doesn't change. It's still the default theme.

@api.get("/scalar", include_in_schema=False)
async def scalar_html():
    return get_scalar_api_reference(
        openapi_url=api.openapi_url,
        title=api.title,
        theme=Theme.SOLARIZED,  # not work
    )

When I empty the scalar_theme, the theme changes like it should.

@api.get("/scalar", include_in_schema=False)
async def scalar_html():
    return get_scalar_api_reference(
        openapi_url=api.openapi_url,
        title=api.title,
        scalar_theme="",
        theme=Theme.SOLARIZED,  # work now
    )

@hanspagel
Copy link
Member

Ah, got it! Yeah, there’s a lot of strange things going on.

Fixing it…

@hanspagel hanspagel mentioned this pull request Aug 13, 2025
4 tasks
@hanspagel
Copy link
Member

Closing in favor of #6552 ✌️

@hanspagel hanspagel closed this Aug 13, 2025
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