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