Repository navigation
fix(openapi): describe tuple rest elements as repeated items - #8152
Conversation
A rest element was emitted as a fixed position with items:false and a maxItems cap, so schemas rejected valid tuples like [string, ...number[]]. Emit it as repeated items instead, keep a leading rest permissive, and leave tuples without rest unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 7 Skipped Deployments
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
trpc-bot
left a comment
There was a problem hiding this comment.
The new test fails on main (the three rest cases) and passes here.
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Why
@trpc/openapiemits an exact-length schema for a tuple with a rest element ([string, ...number[]]), so valid values fail validation and generated clients send or accept the wrong shape.What
itemsinstead of a fixedprefixItemsentry, and dropmaxItems.minItemsat the number of required elements, so an optional element before the rest stays optional.Links
None
Alternatives considered
contains: JSON Schema cannot express item order there; a permissive item schema is the honest representation.Testing
Regression check:
packages/openapi/test/restTuple.test.tsfails on main (3 rest cases) and passes here; the fulltrpc-openapisuite is 217/217. Typecheck, lint and format pass.AI model
deepseek-v4.1-flash-mb (max effort)
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit
Bug Fixes
undefinedare now correctly reflected in minimum item counts.Tests