mirror of https://github.com/tiangolo/fastapi.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 <tiangolo@gmail.com>
This commit is contained in:
parent
2ee0eedf23
commit
ceedfccde0
|
|
@ -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`:
|
||||
|
|
|
|||
Loading…
Reference in New Issue