Coverage for docs_src / schema_extra_example / tutorial002_py310.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from fastapi import FastAPI 1abc
2from pydantic import BaseModel, Field 1abc
4app = FastAPI() 1abc
7class Item(BaseModel): 1abc
8 name: str = Field(examples=["Foo"]) 1abc
9 description: str | None = Field(default=None, examples=["A very nice Item"]) 1abc
10 price: float = Field(examples=[35.4]) 1abc
11 tax: float | None = Field(default=None, examples=[3.2]) 1abc
14@app.put("/items/{item_id}") 1abc
15async def update_item(item_id: int, item: Item): 1abc
16 results = {"item_id": item_id, "item": item} 1def
17 return results 1def