Closed
Description
When a type can be multiple simple types but not all types, the resulting interface is not correct.
See https://github.com/bcherny/json-schema-to-typescript/blob/master/dist/index.d.ts#L46
and https://spacetelescope.github.io/understanding-json-schema/reference/type.html
I observed this problem with a larger schema and created this simple test case to demonstrate:
export var schema = {
"title": "Example Schema",
"description": "My cool schema",
"type": "object",
"properties": {
"value": {
"type": ["number", "string"]
},
"anotherValue": {
"type": ["null", "string"]
}
},
"required": ["value"]
}
export var types = `/** My cool schema */
export interface ExampleSchema {
value: number | string;
anotherValue: null | string;
}`
I haven't had time to investigate a fix.... but could try if someone else isn't able to get to it before me.
Metadata
Metadata
Assignees
Labels
No labels