From: William Hayes Date: Sat, 13 Jun 2020 13:23:29 +0000 (-0400) Subject: 📝 Document additional parameters for response_model (#1427) X-Git-Tag: 0.57.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ceedfccde0951dfd445015b39c5dae66ad3897dc;p=thirdparty%2Ffastapi%2Ffastapi.git 📝 Document additional parameters for response_model (#1427) * Documented additional parameters These are included in a recent PR (https://github.com/tiangolo/fastapi/pull/1166) but not in the docs yet. * response_model_exclude_none * response_model_exclude_defaults * 📝 Update note about response_model_exclude_defaults and response_model_exclude_none Co-authored-by: Sebastián Ramírez --- diff --git a/docs/en/docs/tutorial/response-model.md b/docs/en/docs/tutorial/response-model.md index 9dd0b6dee6..dd76eca6ef 100644 --- a/docs/en/docs/tutorial/response-model.md +++ b/docs/en/docs/tutorial/response-model.md @@ -124,6 +124,14 @@ So, if you send a request to that *path operation* for the item with ID `foo`, t !!! info FastAPI uses Pydantic model's `.dict()` with its `exclude_unset` parameter to achieve this. +!!! info + You can also use: + + * `response_model_exclude_defaults=True` + * `response_model_exclude_none=True` + + as described in the Pydantic docs for `exclude_defaults` and `exclude_none`. + #### Data with values for fields with defaults But if your data has values for the model's fields with default values, like the item with ID `bar`: