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

Incorrect type when using `prefixItems`

Open zyoshoka opened this issue 1 year ago • 0 comments

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 draft^1:

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

and closed-tuple type should be generated^2 by

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

or

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

Checklist

zyoshoka avatar Aug 31 '24 08:08 zyoshoka