openapi-typescript
openapi-typescript copied to clipboard
Fix array `minItems`/`maxItems` bugs
Changes
Fix bugs related to minItems and maxItems when using --array-length
Issue: https://github.com/openapi-ts/openapi-typescript/issues/1781
Fix incorrectly generating tuples from 0 to (max-min) elements instead of min to max elements.
For example, minItems: 1, maxItems: 3 was producing [] | [T] | [T, T] instead of [T] | [T, T] | [T, T, T].
When an array's items was also an array type with minItems equal to maxItems,
the generated TypeScript was getting incorrectly double-nested
(e.g. string[][] instead of string[]).
How to Review
The tests shows the expected results
Checklist
- [x] Unit tests updated
- [~]
docs/updated (if necessary) - [~]
pnpm run update:examplesrun (only applicable for openapi-typescript)