Coverage for docs_src / generate_clients / tutorial002_py310.py: 100%
20 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 1abcd
2from pydantic import BaseModel 1abcd
4app = FastAPI() 1abcd
7class Item(BaseModel): 1abcd
8 name: str 1abcd
9 price: float 1abcd
12class ResponseMessage(BaseModel): 1abcd
13 message: str 1abcd
16class User(BaseModel): 1abcd
17 username: str 1abcd
18 email: str 1abcd
21@app.post("/items/", response_model=ResponseMessage, tags=["items"]) 1abcd
22async def create_item(item: Item): 1abcd
23 return {"message": "Item received"} 1efg
26@app.get("/items/", response_model=list[Item], tags=["items"]) 1abcd
27async def get_items(): 1abcd
28 return [ 1hij
29 {"name": "Plumbus", "price": 3},
30 {"name": "Portal Gun", "price": 9001},
31 ]
34@app.post("/users/", response_model=ResponseMessage, tags=["users"]) 1abcd
35async def create_user(user: User): 1abcd
36 return {"message": "User received"} 1klm