openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Fix array `minItems`/`maxItems` bugs

Open simonsolnes opened this issue 4 months ago • 2 comments

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:examples run (only applicable for openapi-typescript)

simonsolnes avatar Dec 10 '25 21:12 simonsolnes

⚠️ No Changeset found

Latest commit: 2c1266efac46e1ddc2c86ef2df329c854e883f83

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Dec 10 '25 21:12 changeset-bot[bot]

Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
Latest commit 2c1266efac46e1ddc2c86ef2df329c854e883f83

netlify[bot] avatar Dec 10 '25 21:12 netlify[bot]