jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

Inclusion of InstanceLocation for required and additionalProperties errors

Open sazzer opened this issue 3 years ago • 2 comments

I've just come across this and it's working great :) However, one thing I've noticed that's a bit awkward is - any errors caused by a violation of a required or additionalProperties rule doesn't tell you where in the JSON the violation occurred.

For everything else I get an InstanceLocation that is the JSON Pointer to the property that was invalid. For these two I just get "", so I can't have my service indicate which property was either missing but required, or was unexpectedly present.

I do get this come through in the Message so the validator obviously knows which property it is, but it just doesn't actually return it to the client.

Cheers

sazzer avatar Nov 30 '21 17:11 sazzer

i guess instanceLocation should point to some thing that is present in the input json document.

if a required property is missing, the instanceLocation pointing to that missing property when evaluated on input document it evaluates to nothing.

santhosh-tekuri avatar Dec 02 '21 09:12 santhosh-tekuri

The instance location for required should be the object that's supposed to contain the required properties, rather than individual properties. The actual missing properties would have to be listed in the message.

The instance location for additionalProperties should be the instance object that failed against the subschema. At least I'm pretty sure of that — I'm not an expert on the output requirements.

handrews avatar Jun 15 '22 22:06 handrews