mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-01 18:47:55 -05:00
* Fix for - [FEATURE] Remove *, where it's not needed #1234 * 🔥 Remove unnecessary arg *, * 🎨 Update docs format highlight lines Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
29 lines
645 B
Python
29 lines
645 B
Python
from typing import Set
|
|
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class Item(BaseModel):
|
|
name: str
|
|
description: str = None
|
|
price: float
|
|
tax: float = None
|
|
tags: Set[str] = []
|
|
|
|
|
|
@app.post("/items/", response_model=Item, summary="Create an item")
|
|
async def create_item(item: Item):
|
|
"""
|
|
Create an item with all the information:
|
|
|
|
- **name**: each item must have a name
|
|
- **description**: a long description
|
|
- **price**: required
|
|
- **tax**: if the item doesn't have tax, you can omit this
|
|
- **tags**: a set of unique tag strings for this item
|
|
"""
|
|
return item
|