ts-json-schema-generator
ts-json-schema-generator copied to clipboard
Support for `Required<T>` typescript helper
export type T = Required<{ a?: string }>;
Actual:
{
"$ref": "#/definitions/T",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"T": {
"additionalProperties": false,
"properties": {
"a": {
"type": "string"
}
},
"type": "object"
}
}
}
Expected:
{
"$ref": "#/definitions/T",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"T": {
"additionalProperties": false,
"properties": {
"a": {
"type": "string"
}
},
"required": ["a"],
"type": "object"
}
}
}
/**
* Make all properties in T required
*/
type Required<T> = {
[P in keyof T]-?: T[P];
};
Thank you for filing the issue. Yes, we have indeed not implemented support for the -?. Can you send a PR to implement it?