[ { "description": "punc-specific resolution and local refs", "enums": [], "types": [ { "name": "global_thing", "schemas": [ { "$id": "global_thing", "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "type": { "type": "string" } }, "required": [ "id", "type" ] } ] }, { "name": "punc_entity", "schemas": [ { "$id": "punc_entity", "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "type": { "type": "string" } }, "required": [ "id", "type" ] } ] }, { "name": "punc_person", "schemas": [ { "$id": "punc_person", "$ref": "punc_entity", "properties": { "first_name": { "type": "string", "minLength": 1 }, "last_name": { "type": "string", "minLength": 1 }, "address": { "type": "object", "properties": { "street": { "type": "string" }, "city": { "type": "string" } }, "required": [ "street", "city" ] } } } ] } ], "puncs": [ { "name": "public_ref_test", "public": true, "schemas": [ { "$id": "public_ref_test.request", "$ref": "punc_person" } ] }, { "name": "private_ref_test", "public": false, "schemas": [ { "$id": "private_ref_test.request", "$ref": "punc_person" } ] }, { "name": "punc_with_local_ref_test", "public": false, "schemas": [ { "$id": "local_address", "type": "object", "properties": { "street": { "type": "string" }, "city": { "type": "string" } }, "required": [ "street", "city" ] }, { "$id": "punc_with_local_ref_test.request", "$ref": "local_address" } ] }, { "name": "punc_with_local_ref_to_global_test", "public": false, "schemas": [ { "$id": "local_user_with_thing", "type": "object", "properties": { "user_name": { "type": "string" }, "thing": { "$ref": "global_thing" } }, "required": [ "user_name", "thing" ] }, { "$id": "punc_with_local_ref_to_global_test.request", "$ref": "local_user_with_thing" } ] } ], "tests": [ { "description": "valid instance with address passes in public punc", "schema_id": "public_ref_test.request", "data": { "id": "1", "type": "person" }, "valid": true }, { "description": "punc local ref resolution", "schema_id": "punc_with_local_ref_test.request", "data": { "street": "123 Main St", "city": "Anytown" }, "valid": true }, { "description": "punc local ref missing requirement", "schema_id": "punc_with_local_ref_test.request", "data": {}, "valid": false, "expect_errors": [ { "code": "REQUIRED_FIELD_MISSING", "path": "/city" } ] }, { "description": "punc local ref to global type - invalid format", "schema_id": "punc_with_local_ref_to_global_test.request", "data": {}, "valid": false, "expect_errors": [ { "code": "FORMAT_INVALID", "path": "/thing/id" } ] } ] }, { "description": "punc refs global enum", "enums": [ { "name": "status_enum", "values": [ "active", "inactive" ], "schemas": [ { "$id": "status_enum", "type": "string", "enum": [ "active", "inactive" ] } ] } ], "puncs": [ { "name": "enum_test_punc", "public": true, "schemas": [ { "$id": "enum_test_punc.request", "type": "object", "properties": { "status": { "$ref": "status_enum" } }, "required": [ "status" ] } ] } ], "tests": [ { "description": "valid enum value", "schema_id": "enum_test_punc.request", "data": { "status": "active" }, "valid": true }, { "description": "invalid enum value", "schema_id": "enum_test_punc.request", "data": { "status": "pending" }, "valid": false, "expect_errors": [ { "code": "ENUM_VIOLATED", "path": "/status" } ] } ] }, { "description": "inheritance type matching and overrides", "types": [ { "name": "entity", "schemas": [ { "$id": "entity", "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "type": { "type": "string" } } } ] }, { "name": "job", "schemas": [ { "$id": "job", "$ref": "entity", "properties": { "type": { "type": "string", "const": "job", "override": true }, "job_id": { "type": "string" } } } ] }, { "name": "super_job", "schemas": [ { "$id": "super_job", "$ref": "job", "properties": { "type": { "type": "string", "const": "super_job", "override": true }, "manager_id": { "type": "string" } } }, { "$id": "super_job.short", "$ref": "super_job", "properties": { "name": { "type": "string", "maxLength": 10 } } } ] } ], "tests": [ { "description": "valid job instance", "schema_id": "job", "data": { "id": "1", "type": "job", "name": "my job", "job_id": "job123" }, "valid": true }, { "description": "invalid job instance - wrong type const", "schema_id": "job", "data": { "id": "1", "type": "not_job", "name": "my job", "job_id": "job123" }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/type" } ] }, { "description": "valid super_job instance", "schema_id": "super_job", "data": { "id": "1", "type": "super_job", "name": "my super job", "job_id": "job123", "manager_id": "mgr1" }, "valid": true }, { "description": "valid super_job.short instance", "schema_id": "super_job.short", "data": { "id": "1", "type": "super_job", "name": "short", "job_id": "job123", "manager_id": "mgr1" }, "valid": true }, { "description": "invalid super_job.short - type must be super_job not job", "schema_id": "super_job.short", "data": { "id": "1", "type": "job", "name": "short", "job_id": "job123", "manager_id": "mgr1" }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/type" } ] } ] }, { "description": "union type matching with const discriminators", "types": [ { "name": "union_base", "schemas": [ { "$id": "union_base", "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" } }, "required": [ "id", "type" ] } ] }, { "name": "union_a", "schemas": [ { "$id": "union_a", "$ref": "union_base", "properties": { "type": { "const": "union_a", "override": true }, "prop_a": { "type": "string" } }, "required": [ "prop_a" ] } ] }, { "name": "union_b", "schemas": [ { "$id": "union_b", "$ref": "union_base", "properties": { "type": { "const": "union_b", "override": true }, "prop_b": { "type": "number" } }, "required": [ "prop_b" ] } ] }, { "name": "union_c", "schemas": [ { "$id": "union_c", "base": "union_base", "$ref": "union_base", "properties": { "type": { "const": "union_c", "override": true }, "prop_c": { "type": "boolean" } }, "required": [ "prop_c" ] } ] } ], "puncs": [ { "name": "union_test", "public": true, "schemas": [ { "$id": "union_test.request", "type": "object", "properties": { "union_prop": { "oneOf": [ { "$ref": "union_a" }, { "$ref": "union_b" }, { "$ref": "union_c" } ] } } } ] } ], "tests": [ { "description": "valid union variant A", "schema_id": "union_test.request", "data": { "union_prop": { "id": "123", "type": "union_a", "prop_a": "hello" } }, "valid": true }, { "description": "valid union variant B", "schema_id": "union_test.request", "data": { "union_prop": { "id": "456", "type": "union_b", "prop_b": 123 } }, "valid": true }, { "description": "invalid variant - wrong discriminator", "schema_id": "union_test.request", "data": { "union_prop": { "id": "789", "type": "union_b", "prop_a": "hello" } }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/union_prop/type" } ] }, { "description": "valid union variant C", "schema_id": "union_test.request", "data": { "union_prop": { "id": "789", "type": "union_c", "prop_c": true } }, "valid": true }, { "description": "invalid instance - base type should fail due to override", "schema_id": "union_test.request", "data": { "union_prop": { "id": "101", "type": "union_base", "prop_a": "world" } }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/union_prop/type" } ] } ] }, { "description": "nullable union validation", "types": [ { "name": "thing_base", "schemas": [ { "$id": "thing_base", "type": "object", "properties": { "type": { "type": "string", "const": "thing_base" }, "id": { "type": "string" } }, "required": [ "type", "id" ] } ] }, { "name": "thing_a", "schemas": [ { "$id": "thing_a", "base": "thing_base", "$ref": "thing_base", "properties": { "type": { "type": "string", "const": "thing_a", "override": true }, "prop_a": { "type": "string" } }, "required": [ "prop_a" ] } ] }, { "name": "thing_b", "schemas": [ { "$id": "thing_b", "base": "thing_base", "$ref": "thing_base", "properties": { "type": { "type": "string", "const": "thing_b", "override": true }, "prop_b": { "type": "string" } }, "required": [ "prop_b" ] } ] } ], "puncs": [ { "name": "nullable_union_test", "public": true, "schemas": [ { "$id": "nullable_union_test.request", "type": "object", "properties": { "nullable_prop": { "oneOf": [ { "$ref": "thing_a" }, { "$ref": "thing_b" }, { "type": "null" } ] } } } ] } ], "tests": [ { "description": "valid thing_a", "schema_id": "nullable_union_test.request", "data": { "nullable_prop": { "id": "123", "type": "thing_a", "prop_a": "hello" } }, "valid": true }, { "description": "valid thing_b", "schema_id": "nullable_union_test.request", "data": { "nullable_prop": { "id": "456", "type": "thing_b", "prop_b": "goodbye" } }, "valid": true }, { "description": "valid null", "schema_id": "nullable_union_test.request", "data": { "nullable_prop": null }, "valid": true }, { "description": "invalid base type", "schema_id": "nullable_union_test.request", "data": { "nullable_prop": { "id": "789", "type": "thing_base", "prop_a": "should fail" } }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/nullable_prop/type" } ] }, { "description": "invalid type (string)", "schema_id": "nullable_union_test.request", "data": { "nullable_prop": "not_an_object_or_null" }, "valid": false, "expect_errors": [ { "code": "TYPE_MISMATCH", "path": "/nullable_prop" } ] } ] }, { "description": "type hierarchy descendants matching (family schemas)", "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": { "type": { "const": "organization", "override": true }, "name": { "type": "string" } } } ] }, { "name": "person", "hierarchy": [ "entity", "organization", "person" ], "schemas": [ { "$id": "person", "$ref": "organization", "properties": { "type": { "const": "person", "override": true }, "first_name": { "type": "string" } } } ] } ], "tests": [ { "description": "derived type (person) matches base schema (organization) via family ref", "schema_id": "organization", "data": { "id": "p1", "type": "person", "name": "John", "first_name": "John" }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/type" }, { "code": "ADDITIONAL_PROPERTIES_NOT_ALLOWED", "path": "/first_name" } ] }, { "description": "base type matches its own schema", "schema_id": "organization", "data": { "id": "o1", "type": "organization", "name": "ACME" }, "valid": true }, { "description": "ancestor type (entity) fails derived schema (organization)", "schema_id": "organization", "data": { "id": "e1", "type": "entity" }, "valid": false, "expect_errors": [ { "code": "ENUM_VIOLATED", "path": "/type" } ] }, { "description": "unrelated type (job) fails derived schema (organization)", "schema_id": "organization", "data": { "id": "job-1", "type": "job", "name": "Should Fail" }, "valid": false, "expect_errors": [ { "code": "ENUM_VIOLATED", "path": "/type" } ] } ] }, { "description": "complex punc type matching with oneOf and nested refs", "types": [ { "name": "entity", "schemas": [ { "$id": "entity", "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "type": { "type": "string" } } } ] }, { "name": "job", "schemas": [ { "$id": "job", "$ref": "entity", "properties": { "type": { "type": "string", "const": "job", "override": true }, "job_id": { "type": "string" } } } ] }, { "name": "super_job", "schemas": [ { "$id": "super_job", "$ref": "job", "extensible": false, "properties": { "type": { "type": "string", "const": "super_job", "override": true }, "manager_id": { "type": "string" } } }, { "$id": "super_job.short", "$ref": "super_job", "properties": { "name": { "type": "string", "maxLength": 10 } } } ] }, { "name": "organization", "hierarchy": [ "entity", "organization" ], "schemas": [ { "$id": "organization", "$ref": "entity", "properties": { "type": { "const": "organization", "override": true }, "name": { "type": "string" } } } ] }, { "name": "person", "hierarchy": [ "entity", "organization", "person" ], "schemas": [ { "$id": "person", "$ref": "organization", "properties": { "type": { "const": "person", "override": true }, "first_name": { "type": "string" } } } ] } ], "puncs": [ { "name": "type_test_punc", "public": true, "schemas": [ { "$id": "type_test_punc.request", "type": "object", "properties": { "root_job": { "$ref": "job" }, "nested_or_super_job": { "oneOf": [ { "$ref": "super_job" }, { "type": "object", "properties": { "my_job": { "$ref": "job" } }, "required": [ "my_job" ] } ] } }, "required": [ "root_job", "nested_or_super_job" ] } ] }, { "name": "polymorphic_org_punc", "public": false, "schemas": [ { "$id": "polymorphic_org_punc.request", "$family": "organization" } ] }, { "name": "strict_org_punc", "public": false, "schemas": [ { "$id": "strict_org_punc.request", "$ref": "organization" } ] }, { "name": "invalid_family_punc", "public": false, "schemas": [ { "$id": "invalid_family_punc.request", "$family": "organization", "properties": { "extra": { "type": "string" } } } ] } ], "tests": [ { "description": "valid punc instance with mixed job types", "schema_id": "type_test_punc.request", "data": { "root_job": { "type": "job", "name": "root job", "job_id": "job456" }, "nested_or_super_job": { "type": "super_job", "name": "nested super job", "job_id": "job789", "manager_id": "mgr2" } }, "valid": true }, { "description": "invalid type at punc root ref (job expected, entity given)", "schema_id": "type_test_punc.request", "data": { "root_job": { "type": "entity", "name": "root job", "job_id": "job456" }, "nested_or_super_job": { "type": "super_job", "name": "nested super job", "job_id": "job789", "manager_id": "mgr2" } }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/root_job/type" } ] }, { "description": "invalid type at punc nested ref (job expected, entity given)", "schema_id": "type_test_punc.request", "data": { "root_job": { "type": "job", "name": "root job", "job_id": "job456" }, "nested_or_super_job": { "my_job": { "type": "entity", "name": "nested job" } } }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/nested_or_super_job/my_job/type" } ] }, { "description": "invalid type at punc oneOf ref (super_job expected, job given)", "schema_id": "type_test_punc.request", "data": { "root_job": { "type": "job", "name": "root job", "job_id": "job456" }, "nested_or_super_job": { "type": "job", "name": "nested super job", "job_id": "job789", "manager_id": "mgr2" } }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/nested_or_super_job/type" } ] }, { "description": "valid person against organization punc (polymorphic)", "schema_id": "polymorphic_org_punc.request", "data": { "id": "person-1", "type": "person", "name": "John Doe", "first_name": "John" }, "valid": true }, { "description": "valid organization against organization punc (polymorphic)", "schema_id": "polymorphic_org_punc.request", "data": { "id": "org-1", "type": "organization", "name": "ACME Corp" }, "valid": true }, { "description": "invalid job against organization punc (polymorphic)", "schema_id": "polymorphic_org_punc.request", "data": { "id": "job-1", "type": "job", "name": "My Job" }, "valid": false, "expect_errors": [ { "code": "ONE_OF_FAILED", "path": "" } ] }, { "description": "valid organization against strict punc", "schema_id": "strict_org_punc.request", "data": { "id": "org-2", "type": "organization", "name": "Strict Corp" }, "valid": true }, { "description": "invalid person against strict punc (type mismatch + extra fields)", "schema_id": "strict_org_punc.request", "data": { "id": "person-2", "type": "person", "name": "Jane Doe", "first_name": "Jane" }, "valid": false, "expect_errors": [ { "code": "CONST_VIOLATED", "path": "/type" }, { "code": "ADDITIONAL_PROPERTIES_NOT_ALLOWED", "path": "/first_name" } ] }, { "description": "invalid schema due to family exclusivity violation", "schema_id": "invalid_family_punc.request", "data": { "id": "org-2", "type": "organization", "name": "Strict Corp", "extra": "value" }, "valid": false, "expect_errors": [ { "code": "INVALID_SCHEMA", "path": "" } ] } ] }, { "description": "dependency merging across inheritance", "types": [ { "name": "entity", "schemas": [ { "$id": "entity", "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "type": { "type": "string" }, "created_by": { "type": "string", "format": "uuid" }, "creating": { "type": "boolean" }, "name": { "type": "string" } }, "required": [ "id", "type", "created_by" ], "dependencies": { "creating": [ "name" ] } } ] }, { "name": "user", "schemas": [ { "$id": "user", "$ref": "entity", "properties": { "password": { "type": "string", "minLength": 8 } }, "dependencies": { "creating": [ "name" ] } } ] }, { "name": "person", "schemas": [ { "$id": "person", "$ref": "user", "properties": { "first_name": { "type": "string", "minLength": 1 }, "last_name": { "type": "string", "minLength": 1 } }, "dependencies": { "creating": [ "first_name", "last_name" ] } } ] } ], "tests": [ { "description": "dependency merging: fails when missing deps from ancestor and self", "schema_id": "person", "data": { "id": "550e8400-e29b-41d4-a716-446655440000", "type": "person", "created_by": "550e8400-e29b-41d4-a716-446655440001", "creating": true, "password": "securepass" }, "valid": false, "expect_errors": [ { "code": "DEPENDENCY_FAILED", "path": "/name" }, { "code": "DEPENDENCY_FAILED", "path": "/first_name" }, { "code": "DEPENDENCY_FAILED", "path": "/last_name" } ] }, { "description": "dependency merging: fails when missing only local dep", "schema_id": "person", "data": { "id": "550e8400-e29b-41d4-a716-446655440000", "type": "person", "created_by": "550e8400-e29b-41d4-a716-446655440001", "creating": true, "password": "securepass", "name": "John Doe", "first_name": "John" }, "valid": false, "expect_errors": [ { "code": "DEPENDENCY_FAILED", "path": "/last_name" } ] } ] } ]