Replies: 1 comment
-
Hi, ellyx13.
And I set openapi version by extending openapi but it doesn't fix error.
Fastapi seems refer pydantic.version and currently it doesn't seem possible to create openapi document using pydantic model v1 and v2 at the same time. Line 23 in e04d397 |
Beta Was this translation helpful? Give feedback.
0 replies
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 using FastAPI 0.110.3 and pydantic v2.7.1. Previously I used pydantic v1 and am planning to migrate to pydantic v2. But I have a problem that FastAPI cannot declare 2 api at the same time using BaseModel of pydantic v1 and pydantic v2.
I did some research and found out that pydantic v1 uses openapi.json 3.0 and pydantic v2 uses openapi.json 3.1, so I think the two versions of openapi.json conflict with each other.
I want fastapi to load the api using pydantic v1 in /v1/api path. And the api using pydantic v2 will be in the v2/api path. But I get error
Operating System
Linux
Operating System Details
pydantic version: 2.7.1
pydantic-core version: 2.18.2
pydantic-core build: profile=release pgo=true
install path: /home/kietpham/python/pydantic/venv/lib/python3.10/site-packages/pydantic
python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
platform: Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
related packages: fastapi-0.110.3 typing_extensions-4.11.0
commit: unknown
FastAPI Version
0.110.3
Pydantic Version
2.7.1
Python Version
Python 3.12.3
Additional Context
Library version from pip freeze:
annotated-types==0.6.0
anyio==4.3.0
click==8.1.7
exceptiongroup==1.2.1
fastapi==0.110.3
h11==0.14.0
httptools==0.6.1
idna==3.7
pydantic==2.7.1
pydantic_core==2.18.2
python-dotenv==1.0.1
PyYAML==6.0.1
sniffio==1.3.1
starlette==0.37.2
typing_extensions==4.11.0
uvicorn==0.29.0
uvloop==0.19.0
watchfiles==0.21.0
websockets==12.0
Beta Was this translation helpful? Give feedback.
All reactions