Skip to content
Snippets Groups Projects
Commit 64bf9a5e authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-907: added faulty json to exception message

parent 428c2bb1
No related branches found
No related tags found
1 merge request!127Resolve TMSS-173 (2nd try)
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment