Pydantic 2 Regression - TypeError: unhashable type on json_schema_extra examples #11489
Unanswered
angely-dev
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I am aware of the discussion #10097. I did comment on it but since it is closed, I guess nobody gets notified. It seems the issue (#10321) has been fixed for
Field
examples but not forjson_schema_extra
examples.Reproduce with Pydantic v2
Then go to: http://localhost:8000/docs
Same working example with Pydantic v1
Downgrade to Pydantic v1:
(venv) $ pip uninstall pydantic (venv) $ pip install pydantic==v1.10.15 (venv) $ python -c "import pydantic; print(pydantic.version.VERSION)" 1.10.15
Then go to: http://localhost:8000/docs
Workaround with Pydantic v2
I have to use
model_dump
on each model instances:Operating System
Linux
Operating System Details
No response
FastAPI Version
0.110.2
Pydantic Version
2.7.1
Python Version
3.10.12
Additional Context
Edit: after more research, it appears to be an issue of Pydantic as per pydantic/pydantic#7625. @dmontagu did mention the fix doesn't affect
json_extra_schema
examples:Beta Was this translation helpful? Give feedback.
All reactions