We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command: npx ts-json-schema-generator --path '*.ts' --type Zoo
npx ts-json-schema-generator --path '*.ts' --type Zoo
Input:
export interface Animal { name: string; } export interface Dog extends Animal { breed: string; } export interface Cat extends Animal { color: string; } export class Zoo { animals:Array<Animal>[]; }
Output:
{ "$ref": "#/definitions/Zoo", "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "Animal": { "additionalProperties": false, "properties": { "name": { "type": "string" } }, "required": [ "name" ], "type": "object" }, "Zoo": { "additionalProperties": false, "properties": { "animals": { "items": { "items": { "$ref": "#/definitions/Animal" }, "type": "array" }, "type": "array" } }, "required": [ "animals" ], "type": "object" } } }
In this case I think it would be useful if the definition of items for the animals array was:
items
animals
"items": { "anyOf": [ { "$ref": "#/definitions/Cat" }, { "$ref": "#/definitions/Dog" }, { "$ref": "#/definitions/Animal" } ] }
And the Cat and Dog definitions were included in the schema.
Cat
Dog
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Command:
npx ts-json-schema-generator --path '*.ts' --type Zoo
Input:
Output:
In this case I think it would be useful if the definition of
items
for theanimals
array was:And the
Cat
andDog
definitions were included in the schema.The text was updated successfully, but these errors were encountered: