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

16 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from typing import Any 1abc

2 

3from fastapi import FastAPI 1abc

4from pydantic import BaseModel 1abc

5 

6app = FastAPI() 1abc

7 

8 

9class Item(BaseModel): 1abc

10 name: str 1abc

11 description: str | None = None 1abc

12 price: float 1abc

13 tax: float | None = None 1abc

14 tags: list[str] = [] 1abc

15 

16 

17@app.post("/items/", response_model=Item) 1abc

18async def create_item(item: Item) -> Any: 1abc

19 return item 1defghi

20 

21 

22@app.get("/items/", response_model=list[Item]) 1abc

23async def read_items() -> Any: 1abc

24 return [ 1jkl

25 {"name": "Portal Gun", "price": 42.0}, 

26 {"name": "Plumbus", "price": 32.0}, 

27 ]