Coverage for docs_src/header_param_models/tutorial002_py310.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-05 00:03 +0000

1from fastapi import FastAPI, Header 1abcd

2from pydantic import BaseModel 1abcd

3 

4app = FastAPI() 1abcd

5 

6 

7class CommonHeaders(BaseModel): 1abcd

8 model_config = {"extra": "forbid"} 1abcd

9 

10 host: str 1abcd

11 save_data: bool 1abcd

12 if_modified_since: str | None = None 1abcd

13 traceparent: str | None = None 1abcd

14 x_tag: list[str] = [] 1abcd

15 

16 

17@app.get("/items/") 1abcd

18async def read_items(headers: CommonHeaders = Header()): 1abcd

19 return headers 1efghijkl