🐛 Fix convert_underscores=False for header Pydantic models (#13515)

This commit is contained in:
Sebastián Ramírez
2025-03-23 20:48:54 +00:00
committed by GitHub
parent c08a3e8f22
commit 2537d9d1c2
12 changed files with 457 additions and 8 deletions

View 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