【发布时间】:2014-08-05 17:45:33
【问题描述】:
我有 3 个架构:
子架构:
{
"title": "child_schema",
"type": "object",
"properties": {
"wyx":{
"type": "number"
}
},
"additionalProperties": false,
"required": ["wyx"]
}
父架构:
{
"title": "parent",
"type": "object",
"properties": {
"x": {
"type": "number"
},
"y": {
"type": "number"
},
"child": {
"$ref": "file:child.json"
}
}
}
爷爷架构:
{
"type": "object",
"title": "grandpa",
"properties": {
"reason": {
"$ref": "file:parent.json"
}
},
"additionalProperties": false
}
如您所见,gradpa 有一个对 parent 的 ref,而 parent 有一个对 child 的 ref。 所有这 3 个文件都在同一个文件夹中。 当我使用 python 验证器验证爷爷模式时,我会不断收到一个名为 RefResolutionError 的错误。
但是,如果我没有爷爷,我只使用父模式和子模式,一切正常!!所以问题是我不能有一个 ref 指向一个 ref(2 个级别)。但我可以让 ref 指向一个模式(只有 1 级。)
不知道为什么
【问题讨论】:
-
我在使用 jaySchema 模块时遇到了这样的问题,这是我的解决方案:stackoverflow.com/questions/26920482/…
标签: json jsonschema json-schema-validator