mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-31 21:21:56 -04:00
✨ Add docs and tests for Python 3.9 and Python 3.10 (#3712)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
This commit is contained in:
committed by
GitHub
parent
83f6781037
commit
d08a062ee2
26
docs_src/body_nested_models/tutorial006_py39.py
Normal file
26
docs_src/body_nested_models/tutorial006_py39.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel, HttpUrl
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class Image(BaseModel):
|
||||
url: HttpUrl
|
||||
name: str
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
price: float
|
||||
tax: Optional[float] = None
|
||||
tags: set[str] = set()
|
||||
images: Optional[list[Image]] = None
|
||||
|
||||
|
||||
@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