docs_src/body_multiple_params/tutorial005_an_py310.py
raw| 1 | from typing import Annotated |
| 2 | |
| 3 | from fastapi import Body, FastAPI |
| 4 | from pydantic import BaseModel |
| 5 | |
| 6 | app = FastAPI() |
| 7 | |
| 8 | |
| 9 | class Item(BaseModel): |
| 10 | name: str |
| 11 | description: str | None = None |
| 12 | price: float |
| 13 | tax: float | None = None |
| 14 | |
| 15 | |
| 16 | @app.put("/items/{item_id}") |
| 17 | async def update_item(item_id: int, item: Annotated[Item, Body(embed=True)]): |
| 18 | results = {"item_id": item_id, "item": item} |
| 19 | return results |