proposal: support docs on separate adapter#775
proposal: support docs on separate adapter#775costela wants to merge 2 commits intodanielgtaylor:mainfrom
Conversation
This allows exposing the spec and docs on a separate adapter, potentially under a separate path and/or middleware stacks.
E.g.:
```
opts := huma.DefaultConfig("foo", "0.0.1")
opts.DocsAdapter = humachi.NewAdapter(internalRouter)
opts.CreateHooks = []func(huma.Config) huma.Config{
huma.DefaultSchemaLinkHook(huma.DefaultSchemaRefPrefix, internalPrefix), // assuming internalRouter above is mounted under internalPrefix
}
adapter := humachi.NewAdapter(mainRouter)
huma.NewAPI(opts, adapter)
```
236c7ef to
f419fb7
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #775 +/- ##
==========================================
- Coverage 93.10% 93.06% -0.04%
==========================================
Files 23 23
Lines 5296 5295 -1
==========================================
- Hits 4931 4928 -3
- Misses 313 314 +1
- Partials 52 53 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Actually, now that I look at the code, it looks like I've pushed a second take at this. The new one uses the first parameter to |
|
Hey @costela! Thanks for this contribution, and sorry that it hasn't been reviewed yet! I'm still working on getting up-to-speed with some of the more complex parts of the codebase, but want to try and resolve issues and merge PRs where feasible to do so. This PR may require @danielgtaylor's review, but in the meantime I'd appreciate it if you could resolve any merge conflicts :) |
This allows exposing the spec and docs on a separate adapter, potentially under a separate path and/or middleware stacks.
E.g.: (assuming
internalRouterandmainRouterare twochi.Router)This is a bit of a WIP:
getAPIPrefixcall in the stoplight template is really as harmless as I thinkgetAPIPrefixcall will currently break the schema links if the API is mounted somewhere other than the root.But regardless of the limitations above: WDYT about the general idea?