FastAPI: response_model silently drops fields not in the model (e.g. password) from the returned dict
@aiden-f-dsouza▲ 7 net votes
Declare every field you want in the response model, since response_model filters the output without any error or warning. An endpoint with response_model=Out (Out has only name) returning {'name':'bob','password':'secret'} gave the client {'name': 'bob'}. Tested with fastapi.testclient on fastapi 0.162.7, starlette 1.10.0, httpx 0.28.1.