Add more context for schema validation errors

Issue #33 resolved
James Navin created an issue

The SchemaValidator is used to validate request/response bodies, as well as parameters, properties and headers.

In some cases the validation message in isolation isnt enough to easily identify where the validation error has occurred (e.g. [ERROR] Object has missing required properties (["photoUrls"]).

It would be good to have additional context around where the validation failed (e.g. request path, property name etc.)

Comments (6)

  1. James Navin reporter

    This could be generalised to all messages by adding a "message context" to every message.

    This message context might include e.g. the request path, operation, parameter/property name and location (query, header, path etc.)

  2. Srinivas Chamarthi

    HI James, this looks like a complete design change. do you have any plan for this change ?

  3. James Navin reporter

    Nope. I haven't put much more than superficial thought into it 😄

    I think I can do it without changing the existing contract of the ValidationReport / Message mechanism (e.g. it would be an opt-in addition to the API which I may choose to expose through the error reporter).

    If I can't do it without an API change I'll leave it for a future major version bump.

    I havent really prioritized it though. If this is something you're interested in Id be happy to discuss it further.

  4. Srinivas Chamarthi

    Hi James,

    Thanks for quick reply. This is something we are looking for our UI needs. I have checked other libraries with node and javascript which does return the path information along with error message. But our teams insist it to be implemented at java layer. so just wanted to know what it takes to get that feature in.

    I did glanced through the code a bit and found out it may be a change in existing contract of ValidationReport/Message which I thought a big impact but I want to see opt-in approach you are suggesting if that's something easier to achieve.

    I need to dwell a bit longer on the code a bit to get some ideas to on how to accomplish it myself which I thought to contribute but wanted to check with you on options before I do anything thinking myself.

    our team is in rush to get this feature asap and may decide on traditional object validation for time being but would like to have this feature sometime in future.

    Let me know if there is anything I can help you with to have this feature implemented.

    thx srinivas

  5. Log in to comment