Closed DavideCanton closed 9 months ago
No data can be valid for this type: So we not want to support it.
the real issue is this type:
type T = {
[key: number]: string;
foo: number;
};
data for example:
But I got for this type following schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"patternProperties": {
"^[0-9]+$": {
"type": "number"
}
},
"type": "object"
}
I expected to got:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"patternProperties": {
"^[0-9]+$": {
"type": "number"
}
},
"properties": {
"foo": {
"type": "number"
}
},
"type": "object"
}
Schema generation for intersection types is incorrect.
Starting from the following typescript:
if I run the following command:
typescript-json-schema ./tsconfig.json T -o schema.json
I get the following schema:
which is not correct, since the following json does not match:
I get a validation error on the 0:
Incorrect type. Expected "string".
I believe the correct schema should be something like this: