Fix prefixItems / minItems / maxItems tuple generation (#2053) #2148
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.
🗣️ Discussion
This PR is an extraction of some work that has already landed in the 8.x branch. This is my first step in porting those changes to the 7.x branch.
Closes #2048
Changes
minItems
/maxItems
tuple generationArray.prototype.filter(Boolean)
patternitems: false; prefixItems: …
schemas; treatprefixItems
as explicit tuple value.items: […schemas]
, treatingitems
as explicit tuple value.How to Review
--experimental-array-spread-members
flagopenapi-ts
typests-reset
behaviors should not be active in plain repo withopenapi-ts
dependencyopenapi-ts
for programmatic use shouldn't start allowingts-reset
behaviors.ts-reset
types don't affect generated typesopenapi-typescript
-generated types shouldn't start allowingts-reset
behavior.🔧 Backwards-compatibility
In order to get a sense for the backwards-compatibility of this PR I pulled the full suite of tests from
array.test.ts
and ran them inmain
. Test outputMany test cases in this corpus cover behavior not-yet-tested in
main
, so this gives us a better sense of what will actually change.Many of the new tests (expectedly) failed in this older context, and the errors fell into four categories.
--experimental-array-spread-members
flag.immutable: true
is setimmutable: true
is set--array-length
withminItems: 1
generates empty array #2048 problem)Checklist
docs/
updated (if necessary)pnpm run update:examples
run (only applicable for openapi-typescript)