Skip to content

Commit a33ebde

Browse files
committed
making schema error more descriptive
1 parent e613557 commit a33ebde

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

JSONLibrary/jsonlibrary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,6 @@ def validate_json_by_schema(json_object, schema) -> None:
313313
try:
314314
jsonschema.validate(json_object, schema)
315315
except jsonschema.ValidationError as e:
316-
fail(f"Json does not match the schema: {e.schema}")
316+
fail(f"{e.message}, Schema path: {' > '.join(e.schema_path)}")
317317
except jsonschema.SchemaError as e:
318318
fail(f"Json schema error: {e}")

acceptance/JSONLibrary.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ TestValidateJsonBySchema
9999
TestValidateJsonBySchemaFileFail
100100
[Documentation] Validate Json by schema file and fail
101101
${new_json} Delete Object From Json ${json_obj_input} $..phoneNumbers
102-
Run Keyword And Expect Error Json does not match the schema: *
102+
Run Keyword And Expect Error * is a required property, Schema path: *
103103
... Validate Json By Schema File ${new_json} ${CURDIR}${/}..${/}tests${/}json${/}example_schema.json
104104

105105
TestValidateJsonBySchemaFail
106106
[Documentation] Validate Json by schema and fail
107107
${schema} Load Json From File ${CURDIR}${/}..${/}tests${/}json${/}example_schema.json
108108
${new_json} Delete Object From Json ${json_obj_input} $..phoneNumbers
109-
Run Keyword And Expect Error Json does not match the schema: *
109+
Run Keyword And Expect Error * is a required property, Schema path: *
110110
... Validate Json By Schema ${new_json} ${schema}
111111

112112
TestValidateJsonByInvalidSchemaFile

0 commit comments

Comments
 (0)