mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-23 10:19:24 -04:00
🐛 Fix convert_underscores=False for header Pydantic models (#13515)
This commit is contained in:
1 parent
c08a3e8f22
commit
2537d9d1c2
12 files changed
+457
-8
No files matched your search
@@ -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