mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-04 23:23:38 -04:00
🐛 Fix convert_underscores=False for header Pydantic models (#13515)
This commit is contained in:
committed by
GitHub
parent
c08a3e8f22
commit
2537d9d1c2
19
docs_src/header_param_models/tutorial003.py
Normal file
19
docs_src/header_param_models/tutorial003.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import List, Union
|
||||
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: Union[str, None] = None
|
||||
traceparent: Union[str, None] = None
|
||||
x_tag: List[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(headers: CommonHeaders = Header(convert_underscores=False)):
|
||||
return headers
|
||||
Reference in New Issue
Block a user