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

14 statements  

« 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 1abc

3 

4app = FastAPI() 1abc

5 

6 

7class Item(BaseModel): 1abc

8 name: str 1abc

9 price: float 1abc

10 

11 

12class ResponseMessage(BaseModel): 1abc

13 message: str 1abc

14 

15 

16@app.post("/items/", response_model=ResponseMessage) 1abc

17async def create_item(item: Item): 1abc

18 return {"message": "item received"} 1def

19 

20 

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

22async def get_items(): 1abc

23 return [ 1ghi

24 {"name": "Plumbus", "price": 3}, 

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

26 ]