fix(core): keep alias out of the OpenAPI doc; mutable doc-array types - #24
Merged
Merged
Conversation
Two fixes from adoption feedback: - route() destructured alias out but Object.assign'd it back enumerable, so the doc generator copied it into every operation object, contrary to the documented "stripped from the OpenAPI document". Now defined non-enumerable, like getRoutingPath; still readable as route.alias. - ZodapiRouteConfig accepts readonly security/tags/servers/parameters (needed for as-const contracts), but zod-to-openapi's OperationObject types them mutable, so a readonly-captured array made the built route unassignable to app.openapi() and collapsed c.req.valid() to never. ZodapiRoute now maps those four fields through DeepWritable; the runtime value is a plain array either way. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197TQhAzcfxR5LQigesnfmv
christensena
force-pushed
the
fix/route-doc-leaks
branch
from
September 1, 2026 22:08
7834c2a to
596700a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes from adoption feedback (group-track), stacked on #22.
aliasleaked into the OpenAPI document.route()destructuresaliasout of the config butObject.assigned it back enumerable, so the doc generator — which copies enumerable config keys into the operation object — emitted analiaskey in every aliased operation, contrary to the documented "stripped from the OpenAPI document". It is now defined non-enumerable, mirroringgetRoutingPath. Every consumer (client dispatch, error guards, codegen) reads it by direct property access, so behaviour is otherwise unchanged.readonly doc arrays broke
app.openapi().ZodapiRouteConfigacceptsreadonlysecurity/tags/servers/parameters(needed soas constcontract values type-check), but zod-to-openapi'sOperationObjecttypes them mutable — so a readonly-captured array (anas constvalue, or even a plain inline literal, whichroute()'sconsttype parameter infers readonly) made the built route unassignable toapp.openapi(...), failing the overload and collapsingc.req.valid()tonever.ZodapiRoutenow maps those four fields through aDeepWritable, so the built route's type is mutable-armed while configs stay readonly-friendly. The runtime value is the same plain array either way.Tests: alias non-enumerability in core; a hono test mounting a route with
as constsecurity + inline tags (compiling at all is the type regression test —c.req.validwould error otherwise) and asserting the generated document carriessecurity/tagsbut noalias; a type test pinning the readonly→mutable mapping. Changeset:@zodapi/corepatch.-- Claude
🤖 Generated with Claude Code
https://claude.ai/code/session_0197TQhAzcfxR5LQigesnfmv