Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type when using prefixItems #1892

Open
2 tasks done
zyoshoka opened this issue Aug 31, 2024 · 0 comments · May be fixed by #1893
Open
2 tasks done

Incorrect type when using prefixItems #1892

zyoshoka opened this issue Aug 31, 2024 · 0 comments · May be fixed by #1893
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library

Comments

@zyoshoka
Copy link

Description

Using prefixItems generates incorrect type.

Name Version
openapi-typescript 7.3.3
Node.js 20.17.0

Reproduction

The following schema

type: array
items:
  type: number
prefixItems:
  - number
  - number

generates incorrect type:

[number, number];

Expected result

This should generate open-tuple type according to JSON Schema 2020-12 draft1:

[number, number, ...number[]];

and closed-tuple type should be generated23 by

type: array
items: false
prefixItems:
  - number
  - number

or

type: array
unevaluatedItems: false
prefixItems:
  - number
  - number

Checklist

Footnotes

  1. https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-01#name-prefixitems

  2. https://json-schema.org/draft/2020-12/release-notes#closed-tuple

  3. https://json-schema.org/understanding-json-schema/reference/array#unevaluateditems

@zyoshoka zyoshoka added bug Something isn't working openapi-ts Relevant to the openapi-typescript library labels Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant