Skip to content
Snippets Groups Projects

ENH: JsonSchemaExporter accepts do_not_create parameter.

Merged Daniel Hornung requested to merge f-more-jsonschema-export into dev
5 unresolved threads
Files
4
@@ -262,3 +262,27 @@ class DataModel(dict):
all_ents[prop.name] = prop
return list(all_ents.values())
def get_deep(self, name: str, visited: set = None):
"""Attempt to resolve references for the given ``name``.
This methods only uses data which is available in this datamodel, which acts kind of like a
cache pool.
"""
entity = self.get(name)
if not entity:
return entity
if not visited:
visited = set()
# new_props = []
for prop in list(entity.get_properties()): # Make a change-resistant list copy.
if prop.name in visited:
continue
visited.add(prop.name)
if prop.name in self:
entity.remove_property(prop).add_property(self.get_deep(prop.name,
visited=visited))
else:
print(f"Referenced property \"{prop.name}\" not found in data model.")
return entity
Loading