我现在已经在这个问题上花了几个多小时,我觉得是时候寻求一些帮助了,因为显然我遗漏了一些关于JSON模式验证的基本概念,我认为我已经理解了这些概念.
以下是我实际上希望不会通过我创建的某些模式的验证的一些JSON:
{
"requests": {
"Interface1": [
{
"foo": "bar",
"id": 9999,
"text": "foo"
}
]
}
}
当我清楚地指出addtionalProperties为FALSE并且在数组的每个嵌套对象中列出"foo"和"id"作为必需的属性名称时,以下模式为什么认为上述JSON是OK:
{
"type": "object",
"properties": {
"requests": {
"type": "object",
"properties": {
"interfacename": {
"type": "array",
"items": {
"type": "object",
"properties": {
"foo": {
"type": "string"
},
"id": {
"type": "number"
}
},
"required": [
"foo",
"id"
],
"additionalProperties": false
}
}
},
"required": [
"Interface1"
]
}
}
}