mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-30 20:54:03 -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
27
docs_src/path_operation_configuration/tutorial002_py310.py
Normal file
27
docs_src/path_operation_configuration/tutorial002_py310.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: str | None = None
|
||||
price: float
|
||||
tax: float | None = None
|
||||
tags: set[str] = set()
|
||||
|
||||
|
||||
@app.post("/items/", response_model=Item, tags=["items"])
|
||||
async def create_item(item: Item):
|
||||
return item
|
||||
|
||||
|
||||
@app.get("/items/", tags=["items"])
|
||||
async def read_items():
|
||||
return [{"name": "Foo", "price": 42}]
|
||||
|
||||
|
||||
@app.get("/users/", tags=["users"])
|
||||
async def read_users():
|
||||
return [{"username": "johndoe"}]
|
||||
Reference in New Issue
Block a user