Coverage for docs_src/pydantic_v1_in_v2/tutorial003_an_py310.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from fastapi import FastAPI 1abcd

2from pydantic import BaseModel as BaseModelV2 1abcd

3from pydantic.v1 import BaseModel 1abcd

4 

5 

6class Item(BaseModel): 1abcd

7 name: str 1abcd

8 description: str | None = None 1abcd

9 size: float 1abcd

10 

11 

12class ItemV2(BaseModelV2): 1abcd

13 name: str 1abcd

14 description: str | None = None 1abcd

15 size: float 1abcd

16 

17 

18app = FastAPI() 1abcd

19 

20 

21@app.post("/items/", response_model=ItemV2) 1abcd

22async def create_item(item: Item): 1abcd

23 return item 1efgh