2020def 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
3734def 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
4752def 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 (
0 commit comments