quicktype
quicktype copied to clipboard
Support Typescript extends while converting to JSONSchema
Hey guys
interface Statement {
[key: string]: any;
}
interface Declaration {
[key: string]: any;
}
export interface VariableDeclaration extends Statement, Declaration {
attributes: {
kind: "let" | "const" | "var";
};
}
Produces this output
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Statement": {
"title": "Statement",
"type": "object",
"additionalProperties": {}
},
"Declaration": {
"title": "Declaration",
"type": "object",
"additionalProperties": {}
},
"VariableDeclaration": {
"title": "VariableDeclaration",
"type": "object",
"properties": {
"attributes": {
"type": "object",
"properties": {
"kind": {
"enum": [
"const",
"let",
"var"
],
"type": "string",
"title": "kind"
}
},
"required": [
"kind"
],
"title": "attributes"
}
},
"required": [
"attributes"
]
}
}
}
https://app.quicktype.io?share=5zNZSMfizoUwqZGplo7i
My understanding is that inheritance can be expressed in JSonSchema with $allOf. Would be really great for quicktype to support this.
Edit1: updated example