You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using "github.com/pb33f/libopenapi-validator" to validate HTTP requests (converted from fasthttp). The validation works as expected, and the error messages provide meaningful reasons.
However, I need to extract the JSON path of the problematic item in the request payload. The Location field in the validation failure only provides the schema path from the OpenAPI (Swagger) YAML, while both DeepLocation and AbsoluteLocation are empty strings.
Upon debugging in VS Code, I found that within OriginalError, there is a Causes field. By recursively unwrapping the errors inside Causes, I eventually reach a v6.ValidatorError instance, whose InstanceLocation field correctly holds the JSON path as a []string array.
My Questions:
Is this the expected behavior, where InstanceLocation is deeply nested inside OriginalError -> Causes?
Is there a helper method in libopenapi-validator that allows me to directly retrieve the JSON path of the payload error without manually unwrapping the causes?
Feature Suggestion:
I think returning the JSON path of the problematic payload more directly could be very helpful for users to precisely locate the problematic item, especially when dealing with large and complex payloads. Would it be possible to expose this information in a more accessible way?
Any guidance or recommendations would be greatly appreciated.
The text was updated successfully, but these errors were encountered:
I can't control how it works down there, only use what is available, in the best way I can.
I have done by best to hide the API from consumers, because, it's not great to be honest. Your suggestions are good ones and I agree, extracting the JSON path from the string slice would be valuable.
There are no mechanisms in place to do this for you today, it would need to be added as new methods on the validator. So to give you a (not great) answer, there isn't anything that will help you today in the lib - but you have basically defined the new feature and how it should work.
I am using "github.com/pb33f/libopenapi-validator" to validate HTTP requests (converted from fasthttp). The validation works as expected, and the error messages provide meaningful reasons.
However, I need to extract the JSON path of the problematic item in the request payload. The Location field in the validation failure only provides the schema path from the OpenAPI (Swagger) YAML, while both DeepLocation and AbsoluteLocation are empty strings.
Upon debugging in VS Code, I found that within OriginalError, there is a Causes field. By recursively unwrapping the errors inside Causes, I eventually reach a v6.ValidatorError instance, whose InstanceLocation field correctly holds the JSON path as a []string array.
My Questions:
Feature Suggestion:
I think returning the JSON path of the problematic payload more directly could be very helpful for users to precisely locate the problematic item, especially when dealing with large and complex payloads. Would it be possible to expose this information in a more accessible way?
Any guidance or recommendations would be greatly appreciated.
The text was updated successfully, but these errors were encountered: