tg.start_soon(process_fn, sub_value.read)
value = serialize_sequence_value(field=field, value=results)
if value is not None:
- values[field.name] = value
+ values[field.alias] = value
for key, value in received_body.items():
if key not in values:
values[key] = value
from dirty_equals import IsDict
from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
-from pydantic import BaseModel
+from pydantic import BaseModel, Field
from typing_extensions import Annotated
app = FastAPI()
lastname: str
age: Optional[int] = None
tags: List[str] = ["foo", "bar"]
+ alias_with: str = Field(alias="with", default="nothing")
@app.post("/form/")
"lastname": "Sanchez",
"age": "70",
"tags": ["plumbus", "citadel"],
+ "with": "something",
},
)
assert response.status_code == 200, response.text
"lastname": "Sanchez",
"age": 70,
"tags": ["plumbus", "citadel"],
+ "with": "something",
}
"lastname": "Sanchez",
"age": None,
"tags": ["foo", "bar"],
+ "with": "nothing",
}
"type": "missing",
"loc": ["body", "username"],
"msg": "Field required",
- "input": {"tags": ["foo", "bar"]},
+ "input": {"tags": ["foo", "bar"], "with": "nothing"},
},
{
"type": "missing",
"loc": ["body", "lastname"],
"msg": "Field required",
- "input": {"tags": ["foo", "bar"]},
+ "input": {"tags": ["foo", "bar"], "with": "nothing"},
},
]
}