-
-
Notifications
You must be signed in to change notification settings - Fork 471
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
fix(openapi-typescript): correct generated type when using prefixItems
#1893
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,8 +258,7 @@ minItems: 2 | |
|
||
```yaml | ||
type: array | ||
items: | ||
type: number | ||
items: false | ||
prefixItems: | ||
- number | ||
- number | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,8 +258,7 @@ minItems: 2 | |
|
||
```yaml | ||
type: array | ||
items: | ||
type: number | ||
items: false | ||
prefixItems: | ||
- number | ||
- number | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,8 +250,7 @@ minItems: 2 | |
|
||
```yaml | ||
type: array | ||
items: | ||
type: number | ||
items: false | ||
prefixItems: | ||
- number | ||
- number | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ describe("transformSchemaObject > array", () => { | |
}, | ||
], | ||
[ | ||
"tuple > prefixItems", | ||
"tuple > prefixItems (open tuple using items)", | ||
{ | ||
given: { | ||
type: "array", | ||
|
@@ -45,6 +45,72 @@ describe("transformSchemaObject > array", () => { | |
want: `[ | ||
number, | ||
number, | ||
number, | ||
...number[] | ||
]`, | ||
// options: DEFAULT_OPTIONS, | ||
}, | ||
], | ||
[ | ||
"tuple > prefixItems (closed tuple using unevaluatedItems)", | ||
{ | ||
given: { | ||
type: "array", | ||
unevaluatedItems: { type: "number" }, | ||
prefixItems: [{ type: "number" }, { type: "number" }, { type: "number" }], | ||
}, | ||
want: `[ | ||
number, | ||
number, | ||
number, | ||
...number[] | ||
]`, | ||
// options: DEFAULT_OPTIONS, | ||
}, | ||
], | ||
[ | ||
"tuple > prefixItems (open tuple not specified)", | ||
{ | ||
given: { | ||
type: "array", | ||
prefixItems: [{ type: "number" }, { type: "number" }, { type: "number" }], | ||
}, | ||
want: `[ | ||
number, | ||
number, | ||
number, | ||
...unknown[] | ||
]`, | ||
// options: DEFAULT_OPTIONS, | ||
}, | ||
], | ||
[ | ||
"tuple > prefixItems (closed tuple using items)", | ||
{ | ||
given: { | ||
type: "array", | ||
items: false, | ||
prefixItems: [{ type: "number" }, { type: "number" }, { type: "number" }], | ||
}, | ||
want: `[ | ||
number, | ||
number, | ||
number | ||
]`, | ||
// options: DEFAULT_OPTIONS, | ||
}, | ||
], | ||
[ | ||
"tuple > prefixItems (closed tuple using unevaluatedItems)", | ||
{ | ||
given: { | ||
type: "array", | ||
unevaluatedItems: false, | ||
prefixItems: [{ type: "number" }, { type: "number" }, { type: "number" }], | ||
}, | ||
want: `[ | ||
number, | ||
number, | ||
number | ||
]`, | ||
// options: DEFAULT_OPTIONS, | ||
|
@@ -179,7 +245,7 @@ describe("transformSchemaObject > array", () => { | |
{ | ||
given: { | ||
type: "array", | ||
items: { type: "number" }, | ||
items: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This specifically is the breaking change I’m referring to—we’ll need to ensure that the original test case of In general, modifying an original test is a good hint that it may be a breaking change. |
||
prefixItems: [{ type: "number" }, { type: "number" }, { type: "number" }], | ||
}, | ||
want: `readonly [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This other modification to an existing test may also technically be a breaking change, but I think because it’s purely additive, could be considered a bugfix. I would be OK with this going in as-is.