mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-18 05:15:46 -04:00
📝 Add documentation of example kwarg of Field (#1106)
* Add documentation of example kwarg of Field * 📝 Update info about schema examples * 🚚 Move example file to new directory Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
17
docs_src/body_fields/tutorial003.py
Normal file
17
docs_src/body_fields/tutorial003.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str = Field(..., example="Foo")
|
||||
description: str = Field(None, example="A very nice Item")
|
||||
price: float = Field(..., example=35.4)
|
||||
tax: float = Field(None, example=3.2)
|
||||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
Reference in New Issue
Block a user