ts-json-schema-generator
ts-json-schema-generator copied to clipboard
Required<T> types do not generate required properties
Define two types as follows:
export type MyType = {
prop1?: string
prop2?: string
}
export type MyRequiredType = Required<MyType>
Expected to see the json schema generated to show prop1 and prop2 listed as required for MyRequiredType
However, they are not:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"MyType": {
"type": "object",
"properties": {
"prop1": {
"type": "string"
},
"prop2": {
"type": "string"
}
},
"additionalProperties": false
},
"MyRequiredType": {
"type": "object",
"properties": {
"prop1": {
"type": "string"
},
"prop2": {
"type": "string"
}
},
"additionalProperties": false
}
}
}