Fastapi: Support for pydantic exclude_none

Created on 28 Feb 2020  路  2Comments  路  Source: tiangolo/fastapi

Is your feature request related to a problem

I want to exclude from the output values set to None.
pydantic has support for this: <object>.json(exclude_none=true)

The solution you would like

Similar to the parameter response_model_exclude_unset but to exclude the Nones.

Describe alternatives you've considered

Not setting any None... Lot of boiler plate code.

enhancement

Most helpful comment

In the latest versions you can set it in the path operation decorator with response_model_exclude_none=True.

The current latest version is 0.54.1.

All 2 comments

In the latest versions you can set it in the path operation decorator with response_model_exclude_none=True.

The current latest version is 0.54.1.

Thanks 馃憤

Was this page helpful?
0 / 5 - 0 ratings