[
    {
        "description": "inline dereferencing",
        "schema": {
            "id": "http://foo.bar/baz#",
            "type": "number",
            "allOf": [{ "$ref": "#qux" }],
            "definitions": {
                "woo": {
                    "id": "#qux",
                    "maximum": 42
              }
            }
        },
        "tests": [
            {
                "description": "matches schema",
                "data": 41,
                "valid": true
            },
            {
                "description": "does not match schema",
                "data": 43,
                "valid": false
            }
        ]
    },

    {
        "description": "inline dereferencing of a JSON pointer",
        "schema": {
            "id": "http://foo.bar/schema1#",
            "type": "object",
            "properties": {
            "name": { "$ref": "#/definitions/name" }
            },
            "definitions": {
            "name": {
              "type": "object",
              "required": ["first", "last"],
              "properties": {
                "first": { "type": "string" },
                "last": { "type": "string" }
              }
            }
            }
        },
        "tests": [
            {
                "description": "matches schema",
                "data": {
                    "name": {
                        "first": "Mohammed",
                        "last": "Chang"
                    }
                },
                "valid": true
            },
            {
                "description": "does not match schema",
                "data": {
                    "name": {
                        "last": "Chang"
                    }
                },
                "valid": false
            }
        ]
    },

    {
        "description": "inline dereferencing of a JSON pointer in an anonymous schema",
        "schema": {
            "type": "object",
            "properties": {
            "name": { "$ref": "#/definitions/name" }
            },
            "definitions": {
            "name": {
              "type": "object",
              "required": ["first", "last"],
              "properties": {
                "first": { "type": "string" },
                "last": { "type": "string" }
              }
            }
            }
        },
        "tests": [
            {
                "description": "matches schema",
                "data": {
                    "name": {
                        "first": "Mohammed",
                        "last": "Chang"
                    }
                },
                "valid": true
            },
            {
                "description": "does not match schema",
                "data": {
                    "name": {
                        "last": "Chang"
                    }
                },
                "valid": false
            }
        ]
    },

    {
        "description": "use the correct resolution scope",
        "schema": {
          "type": "object",
          "id": "http://foo.bar/baz#",
          "properties": {
            "people": {
              "type": "array",
              "items": { "$ref": "#/definitions/name" }
            }
          },

          "definitions": {
            "name": {
              "type": "object",
              "required": ["first", "last"],
              "properties": {
                "first": { "type": "string" },
                "last": { "type": "string" }
              }
            }
          }
        },
        "tests": [
            {
                "description": "matches schema",
                "data": {
                  "people": [ { "first": "Mohammed", "last": "Chang" } ]
                },
                "valid": true
            },
            {
                "description": "does not match schema",
                "data": {
                  "people": [ { "last": "Chang" } ]
                },
                "valid": false
            }
        ]
    },

    {
        "description": "handle urn schema ids",
        "schema": {
          "type": "object",
          "id": "urn:foo:bar",
          "properties": {
            "people": {
              "type": "array",
              "items": { "$ref": "#/definitions/name" }
            }
          },

          "definitions": {
            "name": {
              "type": "object",
              "required": ["first", "last"],
              "properties": {
                "first": { "type": "string" },
                "last": { "type": "string" }
              }
            }
          }
        },
        "tests": [
            {
                "description": "matches schema",
                "data": {
                  "people": [ { "first": "Mohammed", "last": "Chang" } ]
                },
                "valid": true
            },
            {
                "description": "does not match schema",
                "data": {
                  "people": [ { "last": "Chang" } ]
                },
                "valid": false
            }
        ]
    },
    {
        "description": "deep nested refs",
        "schema": {
            "definitions": {
                "a": {"type": "integer"},
                "b": {"$ref": "#/definitions/a"},
                "c": {"$ref": "#/definitions/b"},
                "d": {"$ref": "#/definitions/c"},
                "e": {"$ref": "#/definitions/d"},
                "f": {"$ref": "#/definitions/e"},
                "g": {"$ref": "#/definitions/f"},
                "h": {"$ref": "#/definitions/g"},
                "i": {"$ref": "#/definitions/h"}
            },
            "$ref": "#/definitions/i"
        },
        "tests": [
            {
                "description": "nested ref valid",
                "data": 5,
                "valid": true
            },
            {
                "description": "nested ref invalid",
                "data": "a",
                "valid": false
            }
        ]
    },
    {
        "description": "deep nested refs (too deep)",
        "schema": {
            "definitions": {
                "a": {"type": "integer"},
                "b": {"$ref": "#/definitions/a"},
                "c": {"$ref": "#/definitions/b"},
                "d": {"$ref": "#/definitions/c"},
                "e": {"$ref": "#/definitions/d"},
                "f": {"$ref": "#/definitions/e"},
                "g": {"$ref": "#/definitions/f"},
                "h": {"$ref": "#/definitions/g"},
                "i": {"$ref": "#/definitions/h"},
                "j": {"$ref": "#/definitions/i"}
            },
            "$ref": "#/definitions/j"
        },
        "tests": [
            {
                "description": "nested ref invalid",
                "data": "a",
                "valid": false
            }
        ]
    },
    {
        "description": "circular refs should not cause infinite loop",
        "schema": {
            "definitions": {
                "a": {"$ref": "#/definitions/b"},
                "b": {"$ref": "#/definitions/a"}
            },
            "$ref": "#/definitions/b"
        },
        "tests": [
            {
                "description": "nested ref invalid",
                "data": "a",
                "valid": false
            }
        ]
    }
]
