JSON schema $ref does not work for relative path (refResolutionError)

360 views
Skip to first unread message

Jiajie Duan

unread,
Aug 6, 2014, 12:06:21 PM8/6/14
to jsons...@googlegroups.com

I have 3 schemas:

child schema:

{
    "title": "child_schema",
    "type": "object",
    "properties": {
        "wyx":{
            "type": "number"
        }
     },
    "additionalProperties": false,
    "required": ["wyx"]
}

parent schema:

{
    "title": "parent",
    "type": "object",
    "properties": {
        "x": {
            "type": "number"
        },
        "y": {
            "type": "number"
        },
        "child": {
            "$ref": "file:child.json"
        }
    }
}

grandpa schema:

{
    "type": "object",
    "title": "grandpa",
    "properties": {
        "reason": {
            "$ref": "file:parent.json"
        }
    },
    "additionalProperties": false
}

As you can see, gradpa has a ref to parent and parent has a ref to child. All these 3 files are inside the same folder. When I use python validator to validate grandpa schema, I will keep on getting an error called RefResolutionError.

HOWEVER, if I do not have grandpa and I just use parent schema and child schema, everything worked!! So the issue is I cannot have a ref pointing to a ref(2 levels). But I can have a ref pointing to a schema(just 1 level.)

I wonder why

Reply all
Reply to author
Forward
0 new messages