mirror of https://github.com/tiangolo/fastapi.git
19 lines
422 B
Python
19 lines
422 B
Python
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
|