mirror of https://github.com/tiangolo/fastapi.git
27 lines
549 B
Python
27 lines
549 B
Python
from dataclasses import dataclass, field
|
|
from typing import List, Optional
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
@dataclass
|
|
class Item:
|
|
name: str
|
|
price: float
|
|
tags: List[str] = field(default_factory=list)
|
|
description: Optional[str] = None
|
|
tax: Optional[float] = None
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/next", response_model=Item)
|
|
async def read_next_item():
|
|
return {
|
|
"name": "Island In The Moon",
|
|
"price": 12.99,
|
|
"description": "A place to be be playin' and havin' fun",
|
|
"tags": ["breater"],
|
|
}
|