Skip to content
Snippets Groups Projects
Commit dacb88ab authored by Sebastian Böckelmann's avatar Sebastian Böckelmann
Browse files

FIX: Consider Dependencies of schemas on all layers

parent c2ac4fff
No related branches found
No related tags found
No related merge requests found
......@@ -100,17 +100,28 @@ class MiddlewareLoader:
raise ValueError('Unexpected structure of Open API Component')
def determine_api_object_loading_order(self, components: dict):
def find_reference_dependencies(dictionary: dict)->list[str]:
if "$ref" in dictionary:
return [dictionary['$ref'].split('/')[-1]]
else:
dependencies = []
for value in dictionary.values():
if isinstance(value, dict):
if (found := find_reference_dependencies(value)) is not None:
dependencies.extend(found)
elif isinstance(value, list):
for list_item in value:
if isinstance(list_item, dict):
if (found := find_reference_dependencies(list_item)) is not None:
dependencies.extend(found)
return dependencies
ts = TopologicalSorter()
for component_key, component in components.items():
if 'properties' in component:
for component_property in component['properties'].values():
if '$ref' in component_property:
referer = component_property['$ref'].split('/')[-1]
ts.add(component_key, referer)
else:
ts.add(component_key)
else:
ts.add(component_key)
references = find_reference_dependencies(component)
for reference in references:
ts.add(component_key, reference)
result = list(ts.static_order())
return result
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment