Coverage for docs_src/body_multiple_params/tutorial003_py310.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-05 00:03 +0000

1from fastapi import Body, FastAPI 1abcd

2from pydantic import BaseModel 1abcd

3 

4app = FastAPI() 1abcd

5 

6 

7class Item(BaseModel): 1abcd

8 name: str 1abcd

9 description: str | None = None 1abcd

10 price: float 1abcd

11 tax: float | None = None 1abcd

12 

13 

14class User(BaseModel): 1abcd

15 username: str 1abcd

16 full_name: str | None = None 1abcd

17 

18 

19@app.put("/items/{item_id}") 1abcd

20async def update_item(item_id: int, item: Item, user: User, importance: int = Body()): 1abcd

21 results = {"item_id": item_id, "item": item, "user": user, "importance": importance} 1efgh

22 return results 1efgh