验证 Json 架构草案 V4
Validate Json Schema Draft V4
我有一个如下所示的 Json 架构,当我在像 http://jsonschemalint.com/draft4/# 这样的在线验证器上验证它时,它说它的 valid.I 更改为 "type" 到 "object" , "array" , "string" 并保持结构的其余部分相同。它仍然表示有效模式。我的理解是什么时候
type=object 应该有 "properties"
当 type=array 时应该有"items"
{
"title": "Example Schema",
"type": "string",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
}
},
"required": [
"firstName",
"lastName"
]
}
Some validation keywords only apply to one or more primitive types.
When the primitive type of the instance cannot be validated by a given
keyword, validation for this keyword and instance SHOULD succeed.
所以你提到的行为是正确的。
我有一个如下所示的 Json 架构,当我在像 http://jsonschemalint.com/draft4/# 这样的在线验证器上验证它时,它说它的 valid.I 更改为 "type" 到 "object" , "array" , "string" 并保持结构的其余部分相同。它仍然表示有效模式。我的理解是什么时候 type=object 应该有 "properties" 当 type=array 时应该有"items"
{
"title": "Example Schema",
"type": "string",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
}
},
"required": [
"firstName",
"lastName"
]
}
Some validation keywords only apply to one or more primitive types. When the primitive type of the instance cannot be validated by a given keyword, validation for this keyword and instance SHOULD succeed.
所以你提到的行为是正确的。