0

我正在使用 PyPi jsonschema 来验证我的测试模式。

以下是 test_schema.json 的内容:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema#",
  "title": "Single IV Run JSON Schema",
  "description": "Schema for single IV run sequence",
  "type": "object",
  "properties": {
    "allOf": [
      { "$ref": "/schemas/test/dut.json"},
      {
        "properties": {
          "IV": {"$ref": "/schemas/test/iv.json"}
        }
      }
    ]
  },
  "required": ["IV"]
}

使用 jsonschema.Draft7Validator.check_schema(test_schema),我收到以下错误,即使我从官方草案 7 示例中复制了一般模式结构:

Traceback (most recent call last):
  File "C:/Users/william.su/workspaces/speedit_sandbox/schema_parser.py", line 129, in <module>
    Draft7Validator.check_schema(schema)
  File "C:\Users\william.su\Miniconda3\lib\site-packages\jsonschema\validators.py", line 294, in check_schema
    raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: [{'$ref': '/schemas/test/dut.json'}, {'properties': {'IV': {'$ref': '/schemas/test/iv.json'}}}] is not of type 'object', 'boolean'
4

0 回答 0