我有一个父模式,引用另一个目录中的子模式。
我有父模式:
{
"properties":{
"description": {
"type": "object",
"after": {"type": "string"},
"before": {"type": "string"}
},
"ranges": {
"$ref": "Fields/Ranges.json"
},
"resets": {
"$ref": "Fields/Resets.json"
},
"values": {
"$ref": "Fields/Values.json"
},
"display": {
"type": ["string", "null"]
},
"name": {
"type": "string"
}
}
}
And Child schema:
字段/ Ranges.json
{
"id": "http://example.com/json/schema/aig_doc_schema/models/Fields/Ranges.json",
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"type": "array",
"start": {"type": "number"},
"width": {"type": "number"},
}
}
但是当我尝试使用json-spec验证它时,我收到此错误:
Traceback (most recent call last):
File "/usr/local/bin/json", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/jsonspec/cli.py", line 541, in main
args.func(args)
File "/usr/local/lib/python2.7/site-packages/jsonspec/cli.py", line 205, in __call__
return self.run(args)
File "/usr/local/lib/python2.7/site-packages/jsonspec/cli.py", line 484, in run
validated = load(args.schema).validate(args.document)
File "/usr/local/lib/python2.7/site-packages/jsonspec/validators/draft04.py", line 320, in validate
obj = validator.validate_default_properties(obj, pointer)
File "/usr/local/lib/python2.7/site-packages/jsonspec/validators/draft04.py", line 374, in validate_default_properties
if name not in obj and validator.has_default():
File "/usr/local/lib/python2.7/site-packages/jsonspec/validators/bases.py", line 87, in has_default
return self.validator.has_default()
File "/usr/local/lib/python2.7/site-packages/jsonspec/validators/bases.py", line 83, in validator
self._validator = self.context.resolve(self.pointer)
File "/usr/local/lib/python2.7/site-packages/jsonspec/validators/factorize.py", line 48, in resolve
return self.factory(self.registry.resolve(pointer),
File "/usr/local/lib/python2.7/site-packages/jsonspec/reference/bases.py", line 45, in resolve
obj, fetcher = self.prototype(dp)
File "/usr/local/lib/python2.7/site-packages/jsonspec/reference/bases.py", line 93, in prototype
obj = self[dp.document]
File "/usr/local/lib/python2.7/site-packages/jsonspec/reference/bases.py", line 100, in __getitem__
raise NotFound('{!r} not registered'.format(uri))
jsonspec.reference.exceptions.NotFound: u'http://example.com/json/schema/models/Fields/Ranges.json' not registered
我尝试过添加子模式的完整路径和添加文件等其他内容://但它们都不起作用。有没有人得到一个解决这个问题的工作? 谢谢你的时间。