mirror of https://github.com/tiangolo/fastapi.git
20 lines
406 B
Python
20 lines
406 B
Python
from typing import Set, Union
|
|
|
|
from fastapi import FastAPI, status
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class Item(BaseModel):
|
|
name: str
|
|
description: Union[str, None] = None
|
|
price: float
|
|
tax: Union[float, None] = None
|
|
tags: Set[str] = set()
|
|
|
|
|
|
@app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
|
|
async def create_item(item: Item):
|
|
return item
|