Skip to content

Commit 2d09bfd

Browse files
NPA-3895: Code tidyup
1 parent e392e76 commit 2d09bfd

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

scripts/validate_schema.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
def main(openapi_schema: dict):
2121
"""Main entrypoint"""
2222
args = sys.argv
23-
print("args:")
24-
print(args)
25-
print("******")
2623
if len(args) != 3:
2724
print("Require schema reference and file to validate")
2825
exit()
@@ -35,28 +32,38 @@ def main(openapi_schema: dict):
3532

3633

3734
def schema_lookup(schema: str) -> str:
35+
"""Returns the schema reference to use
36+
37+
Args:
38+
schema (str): The type of record being validated
39+
40+
Returns:
41+
str: The schema reference
42+
"""
3843
schema = schema.lower()
3944
if schema == "consent":
4045
return "#/components/schemas/ConsentBundle"
4146
if schema == "relatedperson":
4247
return "#/components/schemas/RelatedPersonBundle"
43-
44-
print("")
48+
if schema == "operationoutcome":
49+
return "#/components/schemas/OperationOutcome"
4550

4651

4752
def validate_consent(schema: dict, schema_ref: str, file: str) -> None:
4853
schema["$ref"] = schema_ref
49-
# openapi_schema["$ref"] = [
50-
# "#/components/schemas/ConsentBundle",
51-
# "#/components/schemas/Consent",
52-
# "#/components/schemas/CodeableConcept"
53-
# ]
54-
json_contents = load_example_file(file)
54+
json_contents = load_yaml_file_as_json(file)
5555
OAS30Validator(schema).validate(json_contents)
5656

5757

58-
def load_example_file(file: str) -> dict:
58+
def load_yaml_file_as_json(file: str) -> dict:
59+
"""Loads the specified yaml file
60+
61+
Args:
62+
file (str): Path to the file
5963
64+
Returns:
65+
dict: File converted as json dict
66+
"""
6067
patch = path.join(path.dirname(path.realpath(__file__)), file)
6168
yamlfile = safe_load(load_file(patch))
6269
jsonstr = json.dumps(

specification/validated-relationships-service-api.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ components:
14531453
enum:
14541454
[
14551455
"http://terminology.hl7.org/CodeSystem/v3-RoleCode",
1456+
"http://hl7.org/fhir/ValueSet/relatedperson-relationshiptype",
14561457
"https://fhir.hl7.org.uk/CodeSystem/UKCore-AdditionalPersonRelationshipRole"
14571458
]
14581459
code:

0 commit comments

Comments
 (0)