Coverage for docs_src/body_multiple_params/tutorial001_py310.py: 100%
16 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 FastAPI, Path 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
14@app.put("/items/{item_id}") 1abc
15async def update_item( 1abc
16 *,
17 item_id: int = Path(title="The ID of the item to get", ge=0, le=1000),
18 q: str | None = None,
19 item: Item | None = None,
20):
21 results = {"item_id": item_id} 1abc
22 if q: 1abc
23 results.update({"q": q}) 1abc
24 if item: 1abc
25 results.update({"item": item}) 1abc
26 return results 1abc