Coverage for docs_src/dataclasses/tutorial002.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-06 08:24 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-06 08:24 +0000
1from dataclasses import dataclass, field 1abcdef
2from typing import List, Union 1abcdef
4from fastapi import FastAPI 1abcdef
7@dataclass 1abcdef
8class Item: 1abcdef
9 name: str 1abcdef
10 price: float 1abcdef
11 tags: List[str] = field(default_factory=list) 1abcdef
12 description: Union[str, None] = None 1abcdef
13 tax: Union[float, None] = None 1abcdef
16app = FastAPI() 1abcdef
19@app.get("/items/next", response_model=Item) 1abcdef
20async def read_next_item(): 1abcdef
21 return { 1ghijkl
22 "name": "Island In The Moon",
23 "price": 12.99,
24 "description": "A place to be playin' and havin' fun",
25 "tags": ["breater"],
26 }