diff --git a/SAS/TMSS/src/tmss/tmssapp/validation.py b/SAS/TMSS/src/tmss/tmssapp/validation.py index f1b2c9a788bd2c8a3081af40d001767d114bab7c..2908a80cad68da0c71aea006a2aa9b6787768033 100644 --- a/SAS/TMSS/src/tmss/tmssapp/validation.py +++ b/SAS/TMSS/src/tmss/tmssapp/validation.py @@ -14,13 +14,18 @@ def validate_json_against_schema(json_string: str, schema: str): if type(schema) != str: schema = json.dumps(schema) + # ensure the specification and schema are both valid json in the first place try: - # ensure the specification and schema are both valid json in the first place json_object = json.loads(json_string) + except json.decoder.JSONDecodeError as e: + raise SchemaValidationException("Invalid JSON: %s\n%s" % (str(e), json_string)) + + try: schema_object = json.loads(schema) except json.decoder.JSONDecodeError as e: - raise SchemaValidationException("Invalid JSON: %s" % str(e)) + raise SchemaValidationException("Invalid JSON: %s\n%s" % (str(e), schema)) + # now do the actual validation try: jsonschema.validate(json_object, schema_object) except jsonschema.ValidationError as e: