Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting error messages for jsonschema: how to use -F key of the validator?

Tags:

jsonschema

When I run the python jsonschema validator it formats error messages in a very lengthy way. It seems that first it cites the whole schema, where the error has occured, after that mentioned the problematic element and finally tells the error message itself.

If the problem is in the root schema, the resulting message become very verbose. What values do you put in -F key when you run the validator?

like image 663
ganqqwerty Avatar asked Oct 16 '25 16:10

ganqqwerty


1 Answers

It seems that I figured it out. The formatting string to -F option must be in the form suitable to pass it to python format function. So we can use the properties of the error variable, which are listed here.

Here is an example:

jsonschema hbp_prov_schema_v3.json \
-i tests/hbp_prov_example_real.json \ 
-F "ERROR: {error.path} {error.message}
"

This will provide a lot more readable output.

like image 177
ganqqwerty Avatar answered Oct 19 '25 14:10

ganqqwerty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!