mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-18 13:27:45 -04:00
🐛 Fix convert_underscores=False for header Pydantic models (#13515)
This commit is contained in:
committed by
GitHub
parent
c08a3e8f22
commit
2537d9d1c2
17
docs_src/header_param_models/tutorial003_py310.py
Normal file
17
docs_src/header_param_models/tutorial003_py310.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: str | None = None
|
||||
traceparent: 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