Coverage for docs_src / schema_extra_example / tutorial001_py310.py: 100%
13 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 FastAPI 1abghcdef
2from pydantic import BaseModel 1abghcdef
4app = FastAPI() 1abghcdef
7class Item(BaseModel): 1abghcdef
8 name: str 1abcdef
9 description: str | None = None 1abghcdef
10 price: float 1abcdef
11 tax: float | None = None 1abghcdef
13 model_config = { 1abghcdef
14 "json_schema_extra": {
15 "examples": [
16 {
17 "name": "Foo",
18 "description": "A very nice Item",
19 "price": 35.4,
20 "tax": 3.2,
21 }
22 ]
23 }
24 }
27@app.put("/items/{item_id}") 1abghcdef
28async def update_item(item_id: int, item: Item): 1abghcdef
29 results = {"item_id": item_id, "item": item} 1ijkl
30 return results 1ijkl