Coverage for docs_src / schema_extra_example / tutorial002_py310.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from fastapi import FastAPI 1abcdefgh

2from pydantic import BaseModel, Field 1abcdefgh

3 

4app = FastAPI() 1abcdefgh

5 

6 

7class Item(BaseModel): 1abcdefgh

8 name: str = Field(examples=["Foo"]) 1abcdefgh

9 description: str | None = Field(default=None, examples=["A very nice Item"]) 1abcdefgh

10 price: float = Field(examples=[35.4]) 1abcdefgh

11 tax: float | None = Field(default=None, examples=[3.2]) 1abcdefgh

12 

13 

14@app.put("/items/{item_id}") 1abcdefgh

15async def update_item(item_id: int, item: Item): 1abcdefgh

16 results = {"item_id": item_id, "item": item} 1ijkl

17 return results 1ijkl