mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-18 21:39:22 -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
24
docs_src/path_operation_configuration/tutorial003_py39.py
Normal file
24
docs_src/path_operation_configuration/tutorial003_py39.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
price: float
|
||||
tax: Optional[float] = None
|
||||
tags: set[str] = set()
|
||||
|
||||
|
||||
@app.post(
|
||||
"/items/",
|
||||
response_model=Item,
|
||||
summary="Create an item",
|
||||
description="Create an item with all the information, name, description, price, tax and a set of unique tags",
|
||||
)
|
||||
async def create_item(item: Item):
|
||||
return item
|
||||
Reference in New Issue
Block a user