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

16 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from typing import Annotated 1abc

2 

3from fastapi import Body, FastAPI 1abc

4from pydantic import BaseModel 1abc

5 

6app = FastAPI() 1abc

7 

8 

9class Item(BaseModel): 1abc

10 name: str 1abc

11 description: str | None = None 1abc

12 price: float 1abc

13 tax: float | None = None 1abc

14 

15 

16class User(BaseModel): 1abc

17 username: str 1abc

18 full_name: str | None = None 1abc

19 

20 

21@app.put("/items/{item_id}") 1abc

22async def update_item( 1abc

23 item_id: int, item: Item, user: User, importance: Annotated[int, Body()] 

24): 

25 results = {"item_id": item_id, "item": item, "user": user, "importance": importance} 1abc

26 return results 1abc