-
-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to get more detailed errors #390
Comments
#230 should change the schema validation code and bring more detailed errors. I'm not sure what you mean with
We can always write more documentation :) |
Now I see the problem. I am in the wrong project. 🤦♂️ I am sorry for the confusion |
After more digging seems like https://github.com/deepmap/oapi-codegen is using this project after all for the validation of the requests. The code to do the validation is around here https://github.com/getkin/kin-openapi/blob/master/openapi3/schema.go Do you think it would be possible to add more details as I was looking for above? Would it be worth looking deeper? |
I mean, now I'm curious. |
Me too.. as I had a previous issue with trying to get line specific details of an error when it's returned. Not sure that is possible.. but the more details, especially if it can be parsed by the consuming caller in a way that could say.. be helpful to allow more specific information provided back to the client.. that would be fantastic. Line number, position in line, and so forth would all be helpful. |
My idea would be to try to add the name of the field with the problem and ideally the schema affected. |
I went ahead and navigated and the code and the problem is not the messages. They are actually pretty nice. It seems to happen in my specific use case of the I now have a better understanding about this and I think this decision is ok. But I believe that it could really help the person getting the validator output to know more about the failure. @fenollp what do you think about returning either the last error or returning all the errors? EDIT: We could also choose the error based on the discriminator if it exists and matches one. |
@fenollp I did an experiment here https://github.com/getkin/kin-openapi/pull/394/files What do you think? |
@fenollp after that PR seems like I still have some vague messages cause by the Can you explain or provide some context why it is used internally? EDIT: To provide some extra context, I have a schema with a |
|
Hi,
When using the
oapi.OapiRequestValidatorWithOptions
is there a way to get a more detailed error?When I have a parameter which is an enum and the value passed is not in the enum would be great to know the field failing the validation.
Instead I get a huge message about the whole schema:
In this case only the field
$type
is wrong not the whole object.Also would be even better if we could let people know what are the valid options.
Any idea if any of this is possible or if this could even be implemented? I would be up to help if some pointers are provided.
The text was updated successfully, but these errors were encountered: