📝 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:
John PatonandSebastián Ramírez authored and GitHub committed 2020-03-29 21:43:31 +02:00
1 parent be21b74ad5
commit 016a4b7491
2 files changed
+30 -2

No files matched your search

+17
View 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