diff --git a/JSONLibrary/jsonlibrary.py b/JSONLibrary/jsonlibrary.py index 2154490..b3469d5 100644 --- a/JSONLibrary/jsonlibrary.py +++ b/JSONLibrary/jsonlibrary.py @@ -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}") diff --git a/acceptance/JSONLibrary.robot b/acceptance/JSONLibrary.robot index e8d86c3..6f27c60 100644 --- a/acceptance/JSONLibrary.robot +++ b/acceptance/JSONLibrary.robot @@ -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