json-spec
json-spec copied to clipboard
Recursion error
I was looking at validating hyper-schema documents and figured I could use the draft4 compiler since hyper-schema is just an extension. It fails however, with a maximum recursion depth exceeded error, this was my approach for a simple test -
from jsonspec.validators import load, Factory
from jsonspec.reference.providers import SpecProvider
data = {
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
"id": "http://my.com/customer#",
"type": "object",
"properties": {
"name": {
"description": "Name of the customer",
"type": "string",
"pattern": "[a-zA-Z\\s]+"
}
},
"required": ["name"],
"links": [
{
"title": "Create",
"description": "Create a customer.",
"href": "/customers",
"method": "POST",
"rel": "create",
"schema": {
"$ref": "#"
},
"targetSchema": {
"$ref": "#"
}
}
]
}
Factory.compilers['http://json-schema.org/draft-04/hyper-schema#'] = \
Factory.compilers['http://json-schema.org/draft-04/schema#']
provider = SpecProvider()
validator = load(provider['draft-04/hyper-schema'], provider=provider)
validator.validate(data)