mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-29 03:04:49 -04:00
📝 Update source examples and docs from Python 3.9 to 3.10 (#14900)
This commit is contained in:
committed by
GitHub
parent
d06ab3f5c7
commit
c9e2277d8b
@@ -1,18 +0,0 @@
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from fastapi import FastAPI, Query
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FilterParams(BaseModel):
|
||||
limit: int = Field(100, gt=0, le=100)
|
||||
offset: int = Field(0, ge=0)
|
||||
order_by: Literal["created_at", "updated_at"] = "created_at"
|
||||
tags: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(filter_query: Annotated[FilterParams, Query()]):
|
||||
return filter_query
|
||||
@@ -1,18 +0,0 @@
|
||||
from typing import Literal
|
||||
|
||||
from fastapi import FastAPI, Query
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FilterParams(BaseModel):
|
||||
limit: int = Field(100, gt=0, le=100)
|
||||
offset: int = Field(0, ge=0)
|
||||
order_by: Literal["created_at", "updated_at"] = "created_at"
|
||||
tags: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(filter_query: FilterParams = Query()):
|
||||
return filter_query
|
||||
@@ -1,20 +0,0 @@
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from fastapi import FastAPI, Query
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FilterParams(BaseModel):
|
||||
model_config = {"extra": "forbid"}
|
||||
|
||||
limit: int = Field(100, gt=0, le=100)
|
||||
offset: int = Field(0, ge=0)
|
||||
order_by: Literal["created_at", "updated_at"] = "created_at"
|
||||
tags: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(filter_query: Annotated[FilterParams, Query()]):
|
||||
return filter_query
|
||||
@@ -1,20 +0,0 @@
|
||||
from typing import Literal
|
||||
|
||||
from fastapi import FastAPI, Query
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FilterParams(BaseModel):
|
||||
model_config = {"extra": "forbid"}
|
||||
|
||||
limit: int = Field(100, gt=0, le=100)
|
||||
offset: int = Field(0, ge=0)
|
||||
order_by: Literal["created_at", "updated_at"] = "created_at"
|
||||
tags: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(filter_query: FilterParams = Query()):
|
||||
return filter_query
|
||||
Reference in New Issue
Block a user