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
🐛 Fix JSON Schema for ValidationError
at field loc
#3810
🐛 Fix JSON Schema for ValidationError
at field loc
#3810
Conversation
📝 Docs preview for commit 95ce749 at: https://612e50e590ccc9407a6d3a82--fastapi.netlify.app |
Codecov Report
@@ Coverage Diff @@
## master #3810 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 409 409
Lines 10264 10264
=========================================
Hits 10264 10264
Continue to review full report at Codecov.
|
📝 Docs preview for commit 6caac74 at: https://612ea7456baaa23ddbd68c4c--fastapi.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
📝 Docs preview for commit ae1128a at: https://615f4487606f2867f92c1744--fastapi.netlify.app |
ValidationError
at field loc
Awesome, thanks @dconatha for the work and explanation! 🤓 🍰 This will be available in FastAPI |
Co-authored-by: Devin Conathan <dconatha@amfam.com>
See #3790
Basically, Pydantic's schema for the
loc
field of the error detail isUnion[str, int]
notstr
for e.g. cases when the invalid data is at a particular index of an array:See the type defined in Pydantic's source here:
https://github.com/samuelcolvin/pydantic/blob/5ccbdcb5904f35834300b01432a665c75dc02296/pydantic/error_wrappers.py#L12
The
openapi.json
schema for aValidationError
should match this.This is particularly important for automated testing using https://schemathesis.readthedocs.io/en/stable/ because ValidationErrors that don't match the schema will lead to failing tests.
I've updated the
validation_error_definition
(h/t to @silversurfer34 for creating the issue and supplying the fixed schema 😄 ).Also I had to update all the tests since the
openapi.json
s are hardcoded in that.