Coverage for docs_src / response_model / tutorial001_01_py310.py: 100%

15 statements  

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

1from fastapi import FastAPI 1aghbcdef

2from pydantic import BaseModel 1aghbcdef

3 

4app = FastAPI() 1aghbcdef

5 

6 

7class Item(BaseModel): 1aghbcdef

8 name: str 1abcdef

9 description: str | None = None 1aghbcdef

10 price: float 1abcdef

11 tax: float | None = None 1aghbcdef

12 tags: list[str] = [] 1aghbcdef

13 

14 

15@app.post("/items/") 1aghbcdef

16async def create_item(item: Item) -> Item: 1aghbcdef

17 return item 1ijklmnop

18 

19 

20@app.get("/items/") 1aghbcdef

21async def read_items() -> list[Item]: 1aghbcdef

22 return [ 1qrst

23 Item(name="Portal Gun", price=42.0), 

24 Item(name="Plumbus", price=32.0), 

25 ]