Coverage for docs_src/query_param_models/tutorial002_py310.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from typing import Literal 1abcd
3from fastapi import FastAPI, Query 1abcd
4from pydantic import BaseModel, Field 1abcd
6app = FastAPI() 1abcd
9class FilterParams(BaseModel): 1abcd
10 model_config = {"extra": "forbid"} 1abcd
12 limit: int = Field(100, gt=0, le=100) 1abcd
13 offset: int = Field(0, ge=0) 1abcd
14 order_by: Literal["created_at", "updated_at"] = "created_at" 1abcd
15 tags: list[str] = [] 1abcd
18@app.get("/items/") 1abcd
19async def read_items(filter_query: FilterParams = Query()): 1abcd
20 return filter_query 1efghijkl