具有特定属性的ref中的Json模式验证

时间:2018-07-20 17:14:43

标签: json-schema-validator

请帮助。找不到答案

我有下一个模式。并且somedict在几个somelist中重复,但是仅在其中一个中,我需要检查somedict中是否具有特定属性“ someproperties2” 我创建了这个架构,但是当我进行验证时我得到了错误 [{'somedict':{'$ ref':'#/ definitions / somedict'}},{'someproperties2':{'type':'array'},'required':['someproperties2']}]不是类型为“对象” 请帮助

schema = {
    "definitions": {
        'somelist': {"type": "array",
                     'items': {"type": "object",
                               "properties": {'somestring': {'type': 'string'},
                                              'somedict': {"$ref": "#/definitions/analyticTerm"}
                                              },
                               'required': ['somestring', 'somedict'],
                               "additionalProperties": False
                               }
                     },
        'somedict': {"type": "object",
                     "properties": {
                         'someproperties1': {'type': 'string'},
                         'someproperties2': {'type': 'array'},
                     },
                     'required': ['someproperties1'],
                     "additionalProperties": False
                     }
    },
    "type": "object",
    "properties": {
        'somelist': {"$ref": "#/definitions/somelist",
                     'properties': {
                         'allOf':
                             [
                                 {'somedict': {"$ref": "#/definitions/somedict"}
                                  },
                                 {'someproperties2': {'type': 'array'},
                                  "required": ["someproperties2"]
                                  }
                             ]
                     }
                     }
    }
}


request = {
    "somelist": [
        {
            "somestring": "Y",
            "somedict": {
                "someproperties1": "Name",
                "someproperties2": {
                    "someproperties2": "YNU"
                }
            }
        }
    ]
}

0 个答案:

没有答案