From 12b515e16b47d55c71562af7e41c12dd74969d33 Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Mon, 6 Nov 2023 22:03:52 -0800 Subject: [PATCH 1/2] add statistics to validation output --- validate_coverage.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/validate_coverage.py b/validate_coverage.py index b317951..070c764 100644 --- a/validate_coverage.py +++ b/validate_coverage.py @@ -202,10 +202,13 @@ def validate_coverage(map_json, input_path=None, verbose=False): mappings.VERBOSE = True # read the schema and generate a scaffold + if "openapi_url" not in map_json: + print("No openapi_url schema available") + return None schema = MoHSchema(map_json["openapi_url"]) if schema is None: print(f"Did not find an openapi schema at {map_json['openapi_url']}; please check link") - return + return None # if --input was specified, we can check data frame completeness coverage: # if input_path is not None: @@ -221,7 +224,8 @@ def validate_coverage(map_json, input_path=None, verbose=False): # print(json.dumps(schema.validation_results, indent=4)) return { "errors": schema.validation_errors, - "warnings": schema.validation_warnings + "warnings": schema.validation_warnings, + "statistics": schema.statistics } def main(args): From 97c31b51118a6538c878d5aff77d09be618fe00d Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Mon, 6 Nov 2023 22:19:32 -0800 Subject: [PATCH 2/2] better errors --- validate_coverage.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/validate_coverage.py b/validate_coverage.py index 070c764..df0d17b 100644 --- a/validate_coverage.py +++ b/validate_coverage.py @@ -203,12 +203,10 @@ def validate_coverage(map_json, input_path=None, verbose=False): # read the schema and generate a scaffold if "openapi_url" not in map_json: - print("No openapi_url schema available") - return None + return {"message": "No openapi_url schema available"} schema = MoHSchema(map_json["openapi_url"]) if schema is None: - print(f"Did not find an openapi schema at {map_json['openapi_url']}; please check link") - return None + return {"message": f"Did not find an openapi schema at {map_json['openapi_url']}; please check link"} # if --input was specified, we can check data frame completeness coverage: # if input_path is not None: