typescript-json-schema
typescript-json-schema copied to clipboard
Array of types vs array of interfaces inconsistency
I think there is an inconsistency when generating custom type/interface array schema. I would expect $ref for both cases when using this config:
{
topRef: true,
ref: true,
aliasRef: true,
}
CardLink as type
type CardLink = {
URL: string;
};
type Card = {
Links: CardLink[];
};
When CardLink is type the resulting schema for CardLink[] is:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"URL": {
"type": "string"
}
}
}
}
CardLink as interface
interface CardLink {
URL: string;
}
type Card = {
Links: CardLink[];
};
When CardLink is interface the resulting schema for CardLink[] is:
{
"type": "array",
"items": {
"$ref": "#/definitions/CardLink"
}
}