Skip to content

feat: support customizing the docs renderer config#1024

Merged
wolveix merged 4 commits into
danielgtaylor:mainfrom
johnletey:feat/scalar-docs-config
May 28, 2026
Merged

feat: support customizing the docs renderer config#1024
wolveix merged 4 commits into
danielgtaylor:mainfrom
johnletey:feat/scalar-docs-config

Conversation

@johnletey
Copy link
Copy Markdown
Contributor

No description provided.

@wolveix
Copy link
Copy Markdown
Collaborator

wolveix commented May 28, 2026

Hey @johnletey! This is a cool contribution, thank you :)

I want to consider whether this may be usable by the other renderers too before considering merging. I'm a little limited on time right now, so if you happen to want to help with this, it'd be greatly appreciated!

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.07%. Comparing base (3ec3f74) to head (8ab93aa).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1024      +/-   ##
==========================================
+ Coverage   92.98%   93.07%   +0.09%     
==========================================
  Files          23       23              
  Lines        4858     4883      +25     
==========================================
+ Hits         4517     4545      +28     
+ Misses        276      274       -2     
+ Partials       65       64       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johnletey johnletey force-pushed the feat/scalar-docs-config branch from 1200bb2 to aaa0c2e Compare May 28, 2026 14:47
@johnletey johnletey changed the title feat: support customizing the Scalar docs renderer config feat: support customizing the docs renderer config May 28, 2026
@johnletey
Copy link
Copy Markdown
Contributor Author

Thanks @wolveix! Looked at both.

SwaggerUI was a good fit, so I've added it. Its config is just the SwaggerUIBundle({...}) object, so DocsRendererConfig merges straight in. Only catch was CSP: the inline script is pinned by a sha256 hash, so I pass the config via a data-config attribute (same trick as Scalar) and read it at runtime. The script body stays static, so its hash stays valid.

Stoplight Elements doesn't fit the same shape though. It's configured via attributes on <elements-api> (router, layout, etc.), not one JSON object, so there's nowhere clean for an any to land. Left it out for now, but happy to do something dedicated if you'd prefer.

@wolveix
Copy link
Copy Markdown
Collaborator

wolveix commented May 28, 2026

Awesome stuff, thank you so much @johnletey! Would you mind also adding/reworking the docs to demonstrate how these can be configured, please? I think all three docs examples can be simplified to utilize the DocsRenderer field, and could include a simple configurable map as an example with an // Optional. tag. Does that make sense to you?

here: https://github.com/johnletey/huma/blob/feat/scalar-docs-config/docs/docs/features/api-docs.md

@johnletey
Copy link
Copy Markdown
Contributor Author

@wolveix Is that what you had in mind?

@wolveix wolveix merged commit ffc1eb5 into danielgtaylor:main May 28, 2026
2 checks passed
@wolveix
Copy link
Copy Markdown
Collaborator

wolveix commented May 28, 2026

Awesome stuff, thanks so much @johnletey!

@johnletey johnletey deleted the feat/scalar-docs-config branch May 28, 2026 15:59
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