typescript-json-schema
typescript-json-schema copied to clipboard
annotations will be ignored if use a referred type
for example, i have an interface UserInfo
whose extra
property is another interface, and there are some annotations:
interface AddressInfo {
/**
* @default xxx
*/
address: string;
}
interface UserInfo {
/**
* @default xxx
* @label xxx
*/
name: string;
/**
* some desc ...
*
* @label xxx
*/
extra: AddressInfo
}
when i tried generate schema with TJS.generateSchema(program, "UserInfo", { validationKeywords: [ 'label' ] });
, i got:
(From https://github.com/YousefED/typescript-json-schema/issues/251 i know that custom annotations should be declared in validationKeyowrds
)
{
"type": "object",
"properties": {
"name": {
"default": "xxx",
"label": "xxx",
"type": "string"
},
"extra": {
"$ref": "#/definitions/AddressInfo",
"description": "some desc ..."
}
},
"required": [
"extra",
"name"
],
"definitions": {
"AddressInfo": {
"type": "object",
"properties": {
"address": {
"default": "xxx",
"type": "string"
}
},
"required": [
"address"
]
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
name
has the property default
and label
,but extra
only has description
, label
is ignored.
Is it a bug or how can i do with that?
I have just verified this with the latest version and it is working as expected. Please close the bug.