From 0ba54c3b0765d816fdd4a911d670c011c541cf85 Mon Sep 17 00:00:00 2001 From: Balaji Natrajan Date: Fri, 9 Oct 2020 15:52:53 -0500 Subject: [PATCH 1/3] Throw error if profile property not present in schema --- rdebej/dictionary.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rdebej/dictionary.py b/rdebej/dictionary.py index 281b068..8e08c4b 100644 --- a/rdebej/dictionary.py +++ b/rdebej/dictionary.py @@ -1043,14 +1043,19 @@ 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) + if not is_found and prop[0][0] is not '@': + 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] = [] From f4d6d6315621bc204b7002438631a2d538dd02ee Mon Sep 17 00:00:00 2001 From: Balaji Natrajan Date: Fri, 9 Oct 2020 16:58:56 -0500 Subject: [PATCH 2/3] Ignore annotation properties --- rdebej/dictionary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdebej/dictionary.py b/rdebej/dictionary.py index 8e08c4b..ddf585a 100644 --- a/rdebej/dictionary.py +++ b/rdebej/dictionary.py @@ -1053,7 +1053,7 @@ def build_requirements(obj, required_properties, entity, entity_repo): entity_repo_prop[ENTITY_REPO_ENTRY_TYPE] == 'Array' : build_requirements(prop[1], required_properties, entity_repo_prop[ENTITY_REPO_ENTRY_REFERENCE], entity_repo) - if not is_found and prop[0][0] is not '@': + 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 From dca6c11018c02ec2ce5fe2e8279b33df4d0d26e3 Mon Sep 17 00:00:00 2001 From: Balaji Natrajan Date: Fri, 9 Oct 2020 17:11:33 -0500 Subject: [PATCH 3/3] Fixes --- rdebej/dictionary.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rdebej/dictionary.py b/rdebej/dictionary.py index ddf585a..526bd67 100644 --- a/rdebej/dictionary.py +++ b/rdebej/dictionary.py @@ -1053,6 +1053,8 @@ def build_requirements(obj, required_properties, entity, entity_repo): 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])