-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
I noticed a bug with the OpenAPI code generation output where a property that references an array item schema is being typed as an array in the generated TypeScript.
After bundling with swagger-parser bundler (because the original schema used an relative YAML file reference), the final JSON OpenAPI schema looks like this:
"components": {
"schemas": {
"DogNames": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
},
"Dog": {
"type": "object",
"properties": {
"dogName": {
"$ref": "#/components/schemas/DogNames/items"
}
}
}
}
}In the Dog schema, the property dogName references #/components/schemas/DogNames/items, which means it should be typed as a single object that matches the item structure from the DogNames array.
export type DogNames = {
name?: string;
}[];
export type Dog = {
dogName?: DogNames; // <-- This is incorrect
};Expected output:
export type DogNames = {
name?: string;
}[];
export type Dog = {
dogName?: DogNames[number];
}Metadata
Metadata
Assignees
Labels
No labels