]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Document additional parameters for response_model (#1427)
authorWilliam Hayes <william.s.hayes@gmail.com>
Sat, 13 Jun 2020 13:23:29 +0000 (09:23 -0400)
committerGitHub <noreply@github.com>
Sat, 13 Jun 2020 13:23:29 +0000 (15:23 +0200)
* 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 <tiangolo@gmail.com>
docs/en/docs/tutorial/response-model.md

index 9dd0b6dee66247b42b731767acf9cdcf5fba480e..dd76eca6ef18ce56b1a443ee87be40b5a211ea05 100644 (file)
@@ -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 <a href="https://pydantic-docs.helpmanual.io/usage/exporting_models/#modeldict" class="external-link" target="_blank">its `exclude_unset` parameter</a> to achieve this.
 
+!!! info
+    You can also use:
+
+    * `response_model_exclude_defaults=True`
+    * `response_model_exclude_none=True`
+
+    as described in <a href="https://pydantic-docs.helpmanual.io/usage/exporting_models/#modeldict" class="external-link" target="_blank">the Pydantic docs</a> 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`: