diff --git a/test/leaf.cfgdb b/test/leaf.cfgdb new file mode 100644 index 00000000..54ebc6ea --- /dev/null +++ b/test/leaf.cfgdb @@ -0,0 +1,17 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$comment": "PR#112 Verify nested references", + "$defs": { + "comp": { + "type": "object", + "properties": { + "a": { + "type": "string" + }, + "b": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/mid.cfgdb b/test/mid.cfgdb new file mode 100644 index 00000000..878b085d --- /dev/null +++ b/test/mid.cfgdb @@ -0,0 +1,14 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$comment": "PR#112 Verify nested references", + "$defs": { + "mid-obj": { + "type": "object", + "properties": { + "inner": { + "$ref": "leaf/$defs/comp" + } + } + } + } +} \ No newline at end of file diff --git a/test/test-external.cfgdb b/test/test-external.cfgdb index 17a8bf46..bcb0c678 100644 --- a/test/test-external.cfgdb +++ b/test/test-external.cfgdb @@ -7,6 +7,10 @@ }, "colors": { "$ref": "test-config-enum/properties/colors" + }, + "nested-ref": { + "$comment": "PR#112 Verify nested references", + "$ref": "mid/$defs/mid-obj" } } } \ No newline at end of file diff --git a/tools/dbgen.py b/tools/dbgen.py index 019293d6..807e9102 100644 --- a/tools/dbgen.py +++ b/tools/dbgen.py @@ -834,6 +834,7 @@ def create_object_property(obj: Object) -> Property: if obj := ref_node.get('object'): if obj.schema_id != parent_prop.obj.schema_id: database.external_objects[object_ref] = obj + databases[parent_prop.obj.schema_id].external_objects[object_ref] = obj return create_object_property(obj) if next_ref := ref_node.get('$ref'): @@ -875,6 +876,7 @@ def create_object_and_property(Class) -> Property: db.object_defs[object_ref] = obj if obj.schema_id != parent_prop.obj.schema_id: database.external_objects[object_ref] = obj + databases[parent_prop.obj.schema_id].external_objects[object_ref] = obj fields['object'] = obj return create_object_property(obj)