|
29 | 29 | CASE2_PASSING_DOCUMENT = {"test": "some data"} |
30 | 30 | CASE2_FAILING_DOCUMENT = {"test": {"foo": "bar"}} |
31 | 31 |
|
| 32 | +CASE3_MAIN_SCHEMA = { |
| 33 | + "type": "object", |
| 34 | + "properties": { |
| 35 | + "pupils": { |
| 36 | + "type": "array", |
| 37 | + "items": {"$ref": "../person/person.schema.json"}, |
| 38 | + } |
| 39 | + }, |
| 40 | +} |
| 41 | +CASE3_PERSON_SCHEMA = { |
| 42 | + "type": "object", |
| 43 | + "properties": {"address": {"$ref": "../address/address.schema.json"}}, |
| 44 | +} |
| 45 | +CASE3_ADDRESS_SCHEMA = { |
| 46 | + "type": "object", |
| 47 | + "properties": {"zip_code": {"type": "number"}}, |
| 48 | +} |
| 49 | +CASE3_PASSING_DOCUMENT = {"pupils": [{"address": {"zip_code": 12345}}]} |
| 50 | + |
32 | 51 |
|
33 | 52 | def _prep_files(tmp_path, main_schema, other_schema_data, instance): |
34 | 53 | main_schemafile = tmp_path / "main_schema.json" |
@@ -75,6 +94,24 @@ def test_local_ref_schema( |
75 | 94 | run_line_simple(["--schemafile", schemafile, str(doc)]) |
76 | 95 |
|
77 | 96 |
|
| 97 | +def test_nested_local_ref_schema(run_line_simple, tmp_path): |
| 98 | + school_dir = tmp_path / "school" |
| 99 | + person_dir = tmp_path / "person" |
| 100 | + address_dir = tmp_path / "address" |
| 101 | + school_dir.mkdir() |
| 102 | + person_dir.mkdir() |
| 103 | + address_dir.mkdir() |
| 104 | + |
| 105 | + main_schemafile = school_dir / "school.schema.json" |
| 106 | + main_schemafile.write_text(json.dumps(CASE3_MAIN_SCHEMA)) |
| 107 | + (person_dir / "person.schema.json").write_text(json.dumps(CASE3_PERSON_SCHEMA)) |
| 108 | + (address_dir / "address.schema.json").write_text(json.dumps(CASE3_ADDRESS_SCHEMA)) |
| 109 | + doc = school_dir / "school.example.json" |
| 110 | + doc.write_text(json.dumps(CASE3_PASSING_DOCUMENT)) |
| 111 | + |
| 112 | + run_line_simple(["--schemafile", str(main_schemafile), str(doc)]) |
| 113 | + |
| 114 | + |
78 | 115 | @pytest.mark.parametrize( |
79 | 116 | "main_schema, other_schema_data, instance, expect_err", |
80 | 117 | [ |
|
0 commit comments