Coverage for docs_src/body_multiple_params/tutorial003_py310.py: 100%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from fastapi import Body, FastAPI 1abc
2from pydantic import BaseModel 1abc
4app = FastAPI() 1abc
7class Item(BaseModel): 1abc
8 name: str 1abc
9 description: str | None = None 1abc
10 price: float 1abc
11 tax: float | None = None 1abc
14class User(BaseModel): 1abc
15 username: str 1abc
16 full_name: str | None = None 1abc
19@app.put("/items/{item_id}") 1abc
20async def update_item(item_id: int, item: Item, user: User, importance: int = Body()): 1abc
21 results = {"item_id": item_id, "item": item, "user": user, "importance": importance} 1abc
22 return results 1abc