-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
validation_error_definition schema is incorrect when detecting an error in an array #3790
Comments
I just stumbled across this error by using https://schemathesis.readthedocs.io/en/stable/ and I agree this should be fixed. The schema should match the schema of Pydantic's "loc" found here: |
I'm working on a PR for this but it breaks lots of tests because the |
It passes the tests, so shouldn't this issue be closed? |
No. Issues are closed when problems are solved on the last release of the package. |
Thanks for the clarification |
Thanks for the report @silversurfer34! 🤓 This was solved on #3810 by @dconatha 🙇 🍰 It will be available in FastAPI |
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs. |
First Check
Commit to Help
Example Code
Description
Run the sample program and call the /items/ api with this body:
You will get a 422 like this
But this 422 response does not follow the validation_error_definition schema :
So the 422 response from fastapi does not respect the schema of the response...
The issue comes from the error in the array, pydantic returns 0 as index of the error, but it is not a string, it is an integer. And it makes sense to return an integer, otherwise we wouldn't know if it is a key in a dict or an index.
As a developer I can workaround this issue by redefining validation_error_definition in my own code
But it would be better to do the change directly in the code. What is your opinion ?
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.68.1
Python Version
3.7.9
Additional Context
No response
The text was updated successfully, but these errors were encountered: