Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dictionary generation to throw exception if a profile property is missing #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions rdebej/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,14 +1043,21 @@ def build_requirements(obj, required_properties, entity, entity_repo):
for prop in obj['PropertyRequirements'].items():
if isinstance(prop[1], dict): # prop[0] is the prop name, prop[1] is the prop requirements
# find the entry in the entity_repo that corresponds to this property
is_found = False
for entity_repo_prop in entity_repo[entity][ENTITY_REPO_TUPLE_PROPERTY_LIST_INDEX]:
if prop[0] == entity_repo_prop[ENTITY_REPO_ENTRY_PROPERTY_NAME]:
is_found = True
required_properties[entity].append(prop[0])
if entity_repo_prop[ENTITY_REPO_ENTRY_TYPE] == 'Set' or \
entity_repo_prop[ENTITY_REPO_ENTRY_TYPE] == 'Enum' or \
entity_repo_prop[ENTITY_REPO_ENTRY_TYPE] == 'Array' :
build_requirements(prop[1], required_properties,
entity_repo_prop[ENTITY_REPO_ENTRY_REFERENCE], entity_repo)
# Throw an error if the profile property is not found in the schema
# (ignore annotation properties)
if not is_found and '@' not in prop[0]:
raise Exception("Profile property not found in schema", prop[0])

if 'Values' in obj: # For enums
if entity not in required_properties:
required_properties[entity] = []
Expand Down