jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

Error message for "additionalProperties" not easily reproducible with data available in the ValidationError

Open pierrecamilleri opened this issue 2 years ago • 3 comments

This is a follow-up to the discussion in #971 (sorry for the delay).

To reproduce the error message of "additionalProperties", some preprocessing needs to be done based on the data readily available in the ValidationError.

Especially, the offending properties are computed with private function find_additional_properties.

pierrecamilleri avatar Aug 31 '22 16:08 pierrecamilleri

Hi. I'd like to add a +1 for getting this fixed as I've hit the same problem. It's also an issue for "required" properties - the error object does not hold the name of the missing required key making it cumbersome to reformat the error message. Thanks for this great package though!

LukeJones123 avatar Oct 31 '22 12:10 LukeJones123

Linking to https://github.com/python-jsonschema/jsonschema/issues/119

Also to +1 this issue.

odscjames avatar Jun 28 '23 07:06 odscjames

+1 to this issue and #119

My use case is as follows: There are existing community supported schemas that have additionalProperties: false I would prefer to catch in code any additional properties that have been added to the instances, rather than modify the schemas. In order to determine if the additional property is one of the known ones, or something that should cause a validation error, I would need to inspect the .message string. Then I would need to remove the properties that I know about, and raise the error without them... thus having the property names reported in the Error would be immensely useful

azaroth42 avatar Jul 27 '23 18:07 azaroth42