[ { "description": "nested refs", "database": { "schemas": [ { "$ref": "c_212", "$id": "ref_4_0" }, { "$id": "a_212", "type": "integer" }, { "$id": "b_212", "$ref": "a_212" }, { "$id": "c_212", "$ref": "b_212" } ] }, "tests": [ { "description": "nested ref valid", "data": 5, "valid": true, "schema_id": "ref_4_0" }, { "description": "nested ref invalid", "data": "a", "valid": false, "schema_id": "ref_4_0" } ] }, { "description": "ref applies alongside sibling keywords", "database": { "schemas": [ { "properties": { "foo": { "$ref": "reffed_248", "maxItems": 2 } }, "$id": "ref_5_0" }, { "$id": "reffed_248", "type": "array" } ] }, "tests": [ { "description": "ref valid, maxItems valid", "data": { "foo": [] }, "valid": true, "schema_id": "ref_5_0" }, { "description": "ref valid, maxItems invalid", "data": { "foo": [ 1, 2, 3 ] }, "valid": false, "schema_id": "ref_5_0" }, { "description": "ref invalid", "data": { "foo": "string" }, "valid": false, "schema_id": "ref_5_0" } ] }, { "description": "property named $ref that is not a reference", "database": { "schemas": [ { "properties": { "$ref": { "type": "string" } }, "$id": "ref_6_0" } ] }, "tests": [ { "description": "property named $ref valid", "data": { "$ref": "a" }, "valid": true, "schema_id": "ref_6_0" }, { "description": "property named $ref invalid", "data": { "$ref": 2 }, "valid": false, "schema_id": "ref_6_0" } ] }, { "description": "property named $ref, containing an actual $ref", "database": { "schemas": [ { "properties": { "$ref": { "$ref": "is-string_344" } }, "$id": "ref_7_0" }, { "$id": "is-string_344", "type": "string" } ] }, "tests": [ { "description": "property named $ref valid", "data": { "$ref": "a" }, "valid": true, "schema_id": "ref_7_0" }, { "description": "property named $ref invalid", "data": { "$ref": 2 }, "valid": false, "schema_id": "ref_7_0" } ] }, { "description": "$ref to boolean schema true", "database": { "schemas": [ { "$ref": "bool_378", "$id": "ref_8_0" }, { "$id": "bool_378", "extensible": true } ] }, "tests": [ { "description": "any value is valid", "data": "foo", "valid": true, "schema_id": "ref_8_0" } ] }, { "description": "$ref to boolean schema false", "database": { "schemas": [ { "$ref": "bool_400", "$id": "ref_9_0" }, { "$id": "bool_400", "extensible": false, "not": {} } ] }, "tests": [ { "description": "any value is invalid", "data": "foo", "valid": false, "schema_id": "ref_9_0" } ] }, { "description": "refs with quote", "database": { "schemas": [ { "properties": { "foo\"bar": { "$ref": "foo%22bar_550" } }, "$id": "ref_11_0" }, { "$id": "foo%22bar_550", "type": "number" } ] }, "tests": [ { "description": "object with numbers is valid", "data": { "foo\"bar": 1 }, "valid": true, "schema_id": "ref_11_0" }, { "description": "object with strings is invalid", "data": { "foo\"bar": "1" }, "valid": false, "schema_id": "ref_11_0" } ] }, { "description": "$ref boundary resets to loose", "database": { "schemas": [ { "$ref": "target_1465", "$id": "ref_35_0" }, { "$id": "target_1465", "properties": { "foo": { "type": "string" } } } ] }, "tests": [ { "description": "extra property in ref target is invalid (strict by default)", "data": { "foo": "bar", "extra": 1 }, "valid": false, "schema_id": "ref_35_0" } ] }, { "description": "$ref target can enforce strictness", "database": { "schemas": [ { "$ref": "target_1496", "$id": "ref_36_0" }, { "$id": "target_1496", "extensible": false, "properties": { "foo": { "type": "string" } } } ] }, "tests": [ { "description": "extra property in ref target is invalid", "data": { "foo": "bar", "extra": 1 }, "valid": false, "schema_id": "ref_36_0" } ] }, { "description": "strictness: boundary reset at $ref", "database": { "schemas": [ { "extensible": true, "properties": { "inline_child": { "properties": { "a": { "type": "integer" } } }, "ref_child": { "$ref": "strict_node_1544" }, "extensible_ref_child": { "$ref": "extensible_node_1551" } }, "$id": "ref_37_0" }, { "$id": "strict_node_1544", "properties": { "b": { "type": "integer" } } }, { "$id": "extensible_node_1551", "extensible": true, "properties": { "c": { "type": "integer" } } } ] }, "tests": [ { "description": "inline child inherits looseness", "data": { "inline_child": { "a": 1, "extra": 2 } }, "valid": true, "schema_id": "ref_37_0" }, { "description": "ref child resets to strict (default)", "data": { "ref_child": { "b": 1, "extra": 2 } }, "valid": false, "schema_id": "ref_37_0" }, { "description": "ref child with explicit extensible=true is loose", "data": { "extensible_ref_child": { "c": 1, "extra": 2 } }, "valid": true, "schema_id": "ref_37_0" } ] }, { "description": "arrays: ref items inherit strictness (reset at boundary)", "database": { "schemas": [ { "properties": { "list": { "type": "array", "items": { "$ref": "strict_node_1614" } } }, "$id": "ref_38_0" }, { "$id": "strict_node_1614", "properties": { "a": { "type": "integer" } } } ] }, "tests": [ { "description": "ref item with extra property is invalid (strict by default)", "data": { "list": [ { "a": 1, "extra": 2 } ] }, "valid": false, "schema_id": "ref_38_0" } ] }, { "description": "implicit keyword shadowing", "database": { "schemas": [ { "$ref": "parent_1648", "properties": { "type": { "const": "child" }, "age": { "minimum": 15 } }, "$id": "ref_39_0" }, { "$id": "parent_1648", "type": "object", "properties": { "type": { "const": "parent" }, "age": { "minimum": 10, "maximum": 20 } }, "required": [ "type", "age" ] } ] }, "tests": [ { "description": "child type overrides parent type", "data": { "type": "child", "age": 15 }, "valid": true, "schema_id": "ref_39_0" }, { "description": "parent type is now invalid (shadowed)", "data": { "type": "parent", "age": 15 }, "valid": false, "schema_id": "ref_39_0" }, { "description": "child min age (15) is enforced", "data": { "type": "child", "age": 12 }, "valid": false, "schema_id": "ref_39_0" }, { "description": "parent max age (20) is shadowed (replaced) by child definition", "data": { "type": "child", "age": 21 }, "valid": true, "schema_id": "ref_39_0" } ] }, { "description": "Entities extending entities (Physical Birth)", "database": { "types": [ { "name": "entity", "hierarchy": [ "entity" ], "schemas": [ { "$id": "entity", "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" } } } ] }, { "name": "organization", "hierarchy": [ "entity", "organization" ], "schemas": [ { "$id": "organization", "$ref": "entity", "properties": { "name": { "type": "string" } } } ] }, { "name": "person", "hierarchy": [ "entity", "organization", "person" ], "schemas": [ { "$id": "person", "$ref": "organization", "properties": { "first_name": { "type": "string" } } } ] } ], "puncs": [ { "name": "save_org", "schemas": [ { "$id": "save_org.request", "$ref": "organization" } ] } ] }, "tests": [ { "description": "Valid person against organization schema (implicit type allowance from physical hierarchy)", "schema_id": "save_org.request", "data": { "id": "1", "type": "person", "name": "ACME" }, "valid": true }, { "description": "Valid organization against organization schema", "schema_id": "save_org.request", "data": { "id": "2", "type": "organization", "name": "ACME" }, "valid": true }, { "description": "Invalid entity against organization schema (ancestor not allowed)", "schema_id": "save_org.request", "data": { "id": "3", "type": "entity" }, "valid": false, "expect_errors": [ { "code": "TYPE_MISMATCH", "path": "/type" } ] } ] }, { "description": "Viral Infection: Ad-hocs inheriting entity boundaries via $ref", "database": { "types": [ { "name": "entity", "hierarchy": [ "entity" ], "schemas": [ { "$id": "entity", "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" } } } ] }, { "name": "person", "hierarchy": [ "entity", "person" ], "schemas": [ { "$id": "person", "$ref": "entity", "properties": { "first_name": { "type": "string" } } }, { "$id": "person.light", "$ref": "entity", "extensible": false, "properties": { "first_name": { "type": "string" } } } ] } ], "puncs": [ { "name": "save_person_light", "schemas": [ { "$id": "save_person_light.request", "$ref": "person.light", "properties": { "extra_request_field": { "type": "string" } } } ] } ] }, "tests": [ { "description": "Valid person against ad-hoc request schema (request virally inherited person variations)", "schema_id": "save_person_light.request", "data": { "id": "1", "type": "person", "first_name": "John", "extra_request_field": "test" }, "valid": true }, { "description": "Invalid entity against ad-hoc request schema (viral inheritance enforces person boundary)", "schema_id": "save_person_light.request", "data": { "id": "1", "type": "entity", "first_name": "John" }, "valid": false, "expect_errors": [ { "code": "TYPE_MISMATCH", "path": "/type" } ] } ] }, { "description": "Ad-hocs extending ad-hocs (No type property)", "database": { "puncs": [ { "name": "save_address", "schemas": [ { "$id": "address", "type": "object", "properties": { "street": { "type": "string" }, "city": { "type": "string" } } }, { "$id": "us_address", "$ref": "address", "properties": { "state": { "type": "string" }, "zip": { "type": "string" } } }, { "$id": "save_address.request", "$ref": "us_address" } ] } ] }, "tests": [ { "description": "Valid us_address", "schema_id": "save_address.request", "data": { "street": "123 Main", "city": "Anytown", "state": "CA", "zip": "12345" }, "valid": true }, { "description": "Invalid base address against us_address", "schema_id": "save_address.request", "data": { "street": "123 Main", "city": "Anytown" }, "valid": true } ] }, { "description": "Ad-hocs extending ad-hocs (with string type property, no magic)", "database": { "puncs": [ { "name": "save_config", "schemas": [ { "$id": "config_base", "type": "object", "properties": { "type": { "type": "string", "const": "config_base" }, "setting": { "type": "string" } } }, { "$id": "config_advanced", "$ref": "config_base", "properties": { "type": { "type": "string", "const": "config_advanced" }, "advanced_setting": { "type": "string" } } }, { "$id": "save_config.request", "$ref": "config_base" } ] } ] }, "tests": [ { "description": "Valid config_base against config_base", "schema_id": "save_config.request", "data": { "type": "config_base", "setting": "on" }, "valid": true }, { "description": "Invalid config_advanced against config_base (no type magic, const is strictly 'config_base')", "schema_id": "save_config.request", "data": { "type": "config_advanced", "setting": "on", "advanced_setting": "off" }, "valid": false } ] } ]