Json oneOf运算符内的属性未按我的要求进行验证

Json oneOf运算符内的属性未按我的要求进行验证,json,json-schema-validator,Json,Json Schema Validator,我无法验证/理解操作员的操作 JSON模式: { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "QuerySpecification": { "type": "array", "minItems": 1,

我无法验证/理解操作员的操作

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"
    }]
}
找到了答案

JSON SCHEMA:

{   
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "QuerySpecification": {
            "type": "array",
            "minItems": 1,
            "items": {
                "type": "object",
                "properties": {
                    "FieldName": {
                        "type": "string"
                    },
                    "SimpleQuery": {
                        "type": "string"
                    },
                    "CompositeQuery": {
                        "type": "string"
                    }
                },
                "oneOf": [{
                    "required": ["SimpleQuery"]
                },{
                    "required": ["CompositeQuery"]
                }],
                "required": [
                    "FieldName"
                ],
                "additionalProperties": false
            }
        }
    }, "required": ["QuerySpecification"]
}
此架构将不会使用进行验证

{
    "QuerySpecification": [{
        "FieldName": "Andreas"
    }]
}
…但是这个

{
    "QuerySpecification": [{
        "FieldName": "Andreas",
        "SimpleQuery": "hei"
    }]
}

将验证

oneOf元素应仅包含所需元素+所需属性。