johnnoone / json-spec

Implements some tools for JSON
BSD 3-Clause "New" or "Revised" License
38 stars 21 forks source link

Recursion error #14

Open misja opened 8 years ago

misja commented 8 years ago

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)