docs_src/path_operation_configuration/tutorial003_py310.py
raw| 1 | from fastapi import FastAPI |
| 2 | from pydantic import BaseModel |
| 3 | |
| 4 | app = FastAPI() |
| 5 | |
| 6 | |
| 7 | class Item(BaseModel): |
| 8 | name: str |
| 9 | description: str | None = None |
| 10 | price: float |
| 11 | tax: float | None = None |
| 12 | tags: set[str] = set() |
| 13 | |
| 14 | |
| 15 | @app.post( |
| 16 | "/items/", |
| 17 | summary="Create an item", |
| 18 | description="Create an item with all the information, name, description, price, tax and a set of unique tags", |
| 19 | ) |
| 20 | async def create_item(item: Item) -> Item: |
| 21 | return item |