ts-json-schema-generator
ts-json-schema-generator copied to clipboard
Invalid schema generated with circular dependencies - minimal case
Property schema incorrectly referenced when there is a circular reference
Affected version: ts-json-schema-generator@1.3.0
Types
export type Foo = {
id: number;
bars: Array<Bar>;
};
export type Broken = Pick<Foo, "id" | "bars">;
export type Bar = {
broken: Broken;
};
Generated Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Bar": {
"additionalProperties": false,
"properties": {
"broken": {
"$ref": "#/definitions/Broken"
}
},
"required": [
"broken"
],
"type": "object"
},
"Broken": {
"additionalProperties": false,
"properties": {
"bars": {
"$ref": "#/definitions/Foo"
},
"id": {
"$ref": "#/definitions/Foo"
}
},
"required": [
"id",
"bars"
],
"type": "object"
},
"Foo": {
"additionalProperties": false,
"properties": {
"bars": {
"items": {
"$ref": "#/definitions/Bar"
},
"type": "array"
},
"id": {
"type": "number"
}
},
"required": [
"id",
"bars"
],
"type": "object"
}
}
Properties id, bars on Broken type are incorrectly referenced to original type instead of fields on type Foo