Skip to content

Commit

Permalink
Merge pull request #51 from Reikhard/master
Browse files Browse the repository at this point in the history
making schema error more descriptive
  • Loading branch information
elrandira authored Nov 18, 2022
2 parents e613557 + a33ebde commit 53e1d01
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion JSONLibrary/jsonlibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,6 @@ def validate_json_by_schema(json_object, schema) -> None:
try:
jsonschema.validate(json_object, schema)
except jsonschema.ValidationError as e:
fail(f"Json does not match the schema: {e.schema}")
fail(f"{e.message}, Schema path: {' > '.join(e.schema_path)}")
except jsonschema.SchemaError as e:
fail(f"Json schema error: {e}")
4 changes: 2 additions & 2 deletions acceptance/JSONLibrary.robot
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ TestValidateJsonBySchema
TestValidateJsonBySchemaFileFail
[Documentation] Validate Json by schema file and fail
${new_json} Delete Object From Json ${json_obj_input} $..phoneNumbers
Run Keyword And Expect Error Json does not match the schema: *
Run Keyword And Expect Error * is a required property, Schema path: *
... Validate Json By Schema File ${new_json} ${CURDIR}${/}..${/}tests${/}json${/}example_schema.json

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

TestValidateJsonByInvalidSchemaFile
Expand Down

0 comments on commit 53e1d01

Please sign in to comment.