Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Schema: Make error messages more descriptive #49

Closed
Reikhard opened this issue Nov 17, 2022 · 3 comments
Closed

Validate Schema: Make error messages more descriptive #49

Reikhard opened this issue Nov 17, 2022 · 3 comments

Comments

@Reikhard
Copy link
Contributor

When Validate Json By Schema throws a jsonschema.ValidationError it is hard to know where or what exactly the Problem is.
example:
Json does not match the schema: {'type': 'object', 'enum': ['SUCCESS', 'ERROR', 'UNDEFINED', 'BUSINESS_ERROR']}
there is no Info what exactly the problem is.

I would propose to change the error message from
except jsonschema.ValidationError as e: fail(f"Json does not match the schema: {e.schema}")
to
except jsonschema.ValidationError as e: fail(f"{e.message}, Schema path: {' > '.join(e.schema_path)}")

So the error in the example would instead read:
'SUCCESS' is not one of ['ERROR', 'UNDEFINED', 'BUSINESS_ERROR'], Schema path: properties > state > enum

which makes more sense to me. What do you think?

@elrandira
Copy link
Collaborator

That seems good.

Please open a pull requests with your changes, don't forget to update acceptance/JSONLibrary.robot and tests/test_JSONLibrary.py if necessary.

@elrandira
Copy link
Collaborator

you closed your MR instead of merging it (which I think you can't do yourself). Your code is not merged into master.

@Reikhard
Copy link
Contributor Author

oh sorry. First time contributing. I've merged with master and tried again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants