When I attempt to validate some data with a schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "splash::schema::user",
"type": "object",
"title": "User Schema",
"definitions": {
"authenticator": {
"type": "object",
"required": [
"issuer",
"subject"
],
"properties": {
"issuer": {
"type": "string",
"description": "name of the issuer"
},
"subject": {
"type": "string",
"description": "unique subject id"
}
}
}
},
"authenticators": {
"type": "array",
"items": {
"$ref": "#/definitions/authenticator"
}
},
"required": [
"uid",
"name"
]
}
I am getting this error from the python jsonschema library:
File "site-packages/jsonschema/validators.py", line 774, in resolve_from_url
document = self.store[url]
File "site-packages/jsonschema/_utils.py", line 22, in __getitem__
return self.store[self.normalize(uri)]
KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "site-packages/jsonschema/validators.py", line 777, in resolve_from_url
document = self.resolve_remote(url)
File "site-packages/jsonschema/validators.py", line 863, in resolve_remote
with urlopen(uri) as url:
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 511, in open
req = Request(fullurl, data)
File "/usr/lib/python3.6/urllib/request.py", line 329, in __init__
self.full_url = url
File "/usr/lib/python3.6/urllib/request.py", line 355, in full_url
self._parse()
File "/usr/lib/python3.6/urllib/request.py", line 384, in _parse
raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "site-packages/flask_restful/__init__.py", line 468, in wrapper
resp = resource(*args, **kwargs)
File "site-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "site-packages/flask_restful/__init__.py", line 583, in dispatch_request
resp = meth(*args, **kwargs)
File "splash-server/splash/resource/base.py", line 40, in post
issues = self.service.validate(data)
File "splash-server/splash/service/base.py", line 25, in validate
for error in errors:
File "splash-server/env/lib/python3.6/site-packages/jsonschema/validators.py", line 328, in iter_errors
for error in errors:
File "splash-server/env/lib/python3.6/site-packages/jsonschema/_validators.py", line 286, in properties
schema_path=property,
File "splash-server/env/lib/python3.6/site-packages/jsonschema/validators.py", line 344, in descend
for error in self.iter_errors(instance, schema):
File "splash-server/env/lib/python3.6/site-packages/jsonschema/validators.py", line 328, in iter_errors
for error in errors:
File "splash-server/env/lib/python3.6/site-packages/jsonschema/_validators.py", line 81, in items
for error in validator.descend(item, items, path=index):
File "splash-server/env/lib/python3.6/site-packages/jsonschema/validators.py", line 344, in descend
for error in self.iter_errors(instance, schema):
File "splash-server/env/lib/python3.6/site-packages/jsonschema/validators.py", line 328, in iter_errors
for error in errors:
File "splash-server/env/lib/python3.6/site-packages/jsonschema/_validators.py", line 259, in ref
scope, resolved = validator.resolver.resolve(ref)
File "splash-server/env/lib/python3.6/site-packages/jsonschema/validators.py", line 766, in resolve
return url, self._remote_cache(url)
File "splash-server/env/lib/python3.6/site-packages/jsonschema/validators.py", line 779, in resolve_from_url
raise exceptions.RefResolutionError(exc)
jsonschema.exceptions.RefResolutionError: unknown url type: ''
The jsonschema library shouldn't be trying to make a request to a url. I don't understand why it isn't just referencing the definitions
field in the file. When I replaced the "items": {"$ref": "#/definitions/authenticator"}
with the corresponding definition it worked fine. So I assume that jsonschema is erroneously trying to request a remote url.