例如,在JSON模式中,具有$ref
且在同一模式中具有其他属性是有效的。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "My schema",
"properties": {
"scripts": {
"$ref": "#/definitions/scriptsBase",
"description": "More docs.",
"minLength": 10
}
},
"definitions": {
"scriptsBase": {
"type": "string",
"description": "Base Description",
"minLength": 5
}
}
}
如果这是允许的,那么解决$ref
ed和$ref
ing模式(在此示例中为minLength
和{{1 }}。但是如果description
等在两者中都定义,则可能会变得更加复杂。
答案 0 :(得分:1)
在json schema property description and "$ref" usage中找到了答案,基本上,如果$ ref存在,所有其他属性都将被忽略。
https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3
语法
JSON参考是一个JSON对象,其中包含名为
的成员 “ $ ref”,具有JSON字符串值。示例:{“ $ ref”:“ http://example.com/example.json#/foo/bar”}
如果JSON值不具有这些特征,则应 不能解释为JSON参考。
“ $ ref”字符串值包含一个URI [RFC3986],用于标识 所引用的JSON值的位置。这是一个错误
字符串值不符合URI语法规则的情况。
JSON参考对象中除“ $ ref”以外的任何成员都应
忽略。