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
from openapi_core import openapi_request_validator
#allows u to iter through all the errors found, in this way, you could use the error information for reporting and such
openapi_request_validator.iter_errors
Existing fuctionality: validate_request(request=request, spec=spec)
Only raises errors, no way of iterating through them
Why is this needed?
Errors do not need to be raised necessarily, there are cases when you would want to iterate and do actions for certain errors, gather information and so on
References
No response
Would you like to implement a feature?
No
The text was updated successfully, but these errors were encountered:
validate_request is just a shortcut for validation. Iteration over errors withiter_errors is still available (although not documented) under validator class
Dear @p1c2u, thank you for this lib and responding to the question from @itsMGA.
In our project we are iterating over the errors and want to return a list of validation errors with the response:
...
spec = Spec.from_file_path(settings.OPENAPI_LOCAL_SPEC_FILE)
openapi_request = FlaskOpenAPIRequest(flask.request)
errors = [str(error) for error in list(V31RequestValidator(spec).iter_errors(openapi_request))]
if len(errors) == 0:
return f(*args, **kwargs)
raise SchemaValidationException('Schema Validation Error:', errors)
...
Unfortunately the response has only one general entry:
{
"error": "Request body validation error"
}
Is it possible to get the list of specific errors, to give more details to the API-consumer?
Suggested Behavior
In the depreciated version there was:
Existing fuctionality:
validate_request(request=request, spec=spec)
Only raises errors, no way of iterating through them
Why is this needed?
Errors do not need to be raised necessarily, there are cases when you would want to iterate and do actions for certain errors, gather information and so on
References
No response
Would you like to implement a feature?
No
The text was updated successfully, but these errors were encountered: