Skip to content

Commit

Permalink
Fixed too-early resolving of use/extend in included schema (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus authored Sep 19, 2023
1 parent 1241a6a commit 6f56a64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions oarepo_model_builder/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,20 @@ def _resolve_shortcuts(self, element):
def _resolve_references(self, element, stack):
if isinstance(element, dict):
# find a reference and if there is one, resolve it
for key in list(element.keys()):
if key not in (self.USE_KEYWORD, self.REF_KEYWORD, self.EXTEND_KEYWORD):
continue
self._resolve_reference_key(element, key, stack)
modified = True
while modified:
modified = False
for key in list(element.keys()):
if key not in (
self.USE_KEYWORD,
self.REF_KEYWORD,
self.EXTEND_KEYWORD,
):
continue
self._resolve_reference_key(element, key, stack)
# it is possible that the reference introduced another reference,
# so try it once again
modified = True

for k, v in element.items():
self._resolve_references(v, stack + [k])
Expand Down Expand Up @@ -211,7 +221,6 @@ def _resolve_reference_key(self, element, key, stack):

def _load_and_merge_reference(self, element, key, name, stack):
included_data = self._load_included_file(name)
self._resolve_references(included_data, stack)

context = {}
for rp in self._reference_processors[key]:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder
version = 4.0.43
version = 4.0.44
description = A utility library that generates OARepo required data model files from a JSON specification file
authors = Miroslav Bauer <[email protected]>, Miroslav Simek <[email protected]>
readme = README.md
Expand Down

0 comments on commit 6f56a64

Please sign in to comment.