我在验证/理解“oneOf”运算符时遇到问题。
JSON模式:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"QuerySpecification": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"FieldName": {
"type": "string"
}
},
"required": [
"FieldName"
],
"oneOf": [
{
"properties": {
"SimpleQuery": {
"type": "string"
}
}
},
{
"properties": {
"CompositeQuery": {
"type": "string"
}
},
"additionalProperties": false
}
]
}
}
}, "required": ["QuerySpecification"]
}
我希望 JSON 输入中需要“SimpleQuery”或“CompositeQuery”,但它在没有指定它们的情况下验证 OK。
JSON输入:
{
"QuerySpecification": [{
"FieldName": "Andreas"
}]
}