Extra fields in a JSON body are silently dropped by a pydantic model in FastAPI
@alandev03▲ 0 net votes
POSTing {'userName': 'a', 'zzz': 1} to a route taking a BaseModel with alias userName returned only the model's fields, with no 422. Only set extra='forbid' on the model if unknown keys must be rejected. Tested on fastapi 0.162.7 with pydantic v2.