Coverage for docs_src / schema_extra_example / tutorial003_py310.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
1from fastapi import Body, FastAPI 1aefbcd
2from pydantic import BaseModel 1aefbcd
4app = FastAPI() 1aefbcd
7class Item(BaseModel): 1aefbcd
8 name: str 1abcd
9 description: str | None = None 1aefbcd
10 price: float 1abcd
11 tax: float | None = None 1aefbcd
14@app.put("/items/{item_id}") 1aefbcd
15async def update_item( 1aefbcd
16 item_id: int,
17 item: Item = Body(
18 examples=[
19 {
20 "name": "Foo",
21 "description": "A very nice Item",
22 "price": 35.4,
23 "tax": 3.2,
24 }
25 ],
26 ),
27):
28 results = {"item_id": item_id, "item": item} 1ghij
29 return results 1ghij