[ { "description": "order of evaluation: $id and $ref", "schema": { "$comment": "$id must be evaluated before $ref to get the proper $ref destination", "$id": "/ref1/base.json", "allOf": [ { "$ref": "int.json" } ], "definitions": { "bigint": { "$comment": "canonical uri: /ref1/int.json", "$id": "int.json", "maximum": 10 }, "smallint": { "$comment": "canonical uri: /int.json", "$id": "/int.json", "maximum": 2 } } }, "tests": [ { "description": "data is valid against first definition", "data": 5, "valid": true }, { "description": "data is invalid against first definition", "data": 50, "valid": false } ] }, { "description": "order of evaluation: $id and $anchor and $ref", "schema": { "$comment": "$id must be evaluated before $ref to get the proper $ref destination", "$id": "/ref2/base.json", "allOf": [ { "$ref": "#bigint" } ], "definitions": { "bigint": { "$comment": "canonical uri: /ref2/base.json#/definitions/bigint; another valid uri for this location: /ref2/base.json#bigint", "$id": "#bigint", "maximum": 10 }, "smallint": { "$id": "/ref2/", "definitions": { "bigint": { "$comment": "canonical uri: /ref2/#/definitions/smallint; another valid uri for this location: /ref2/#bigint, /ref2/base.json#/definitions/smallint/definitions/bigint", "$id": "#bigint", "maximum": 2 } } } } }, "tests": [ { "description": "data is valid against first definition", "data": 5, "valid": true }, { "description": "data is invalid against first definition", "data": 50, "valid": false } ] }, { "description": "naive replacement of $ref with its destination is not correct", "schema": { "definitions": { "a_string": { "type": "string" } }, "enum": [ { "$ref": "#/definitions/a_string" } ] }, "tests": [ { "description": "do not evaluate the $ref inside the enum", "data": "this is a string", "valid": false }, { "description": "match the enum exactly", "data": { "$ref": "#/definitions/a_string" }, "valid": true } ] }, { "description": "invalid $ref: invalid anchor fragment", "schema": { "definitions": { "foo": { "$ref": "https://foo.com/bar.json#-not-an-anchor" } } }, "tests": [ { "description": "an invalid anchor fragment", "data": 1, "valid": false } ] }, { "description": "invalid $ref: invalid json-pointer fragment", "schema": { "definitions": { "foo": { "$ref": "https://foo.com/bar.json#/~2/not/json/pointer" } } }, "tests": [ { "description": "an invalid json-pointer fragment", "data": 1, "valid": false } ] }, { "description": "base URI change - change folder in subschema with path from root", "comment": "based on test suite draft7/refRemote.json 'base URI change - change folder in subschema'", "schema": { "$id": "http://localhost:1234/scope_change_defs.json", "type" : "object", "properties": { "list": { "$ref": "#/definitions/baz/definitions/bar" } }, "definitions": { "folderInteger": { "$id": "baseUriChangeFolderInSubschema/folderInteger.json", "type": "integer" }, "baz": { "$id": "baseUriChangeFolderInSubschema/", "definitions": { "bar": { "type": "array", "items": { "$ref": "folderInteger.json" } } } } } }, "tests": [ { "description": "number is valid", "data": {"list": [1]}, "valid": true }, { "description": "string is invalid", "data": {"list": ["a"]}, "valid": false } ] } ]