You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if there was a way to filter out any fields where the return value is None. Flask-RESTX provides this functionality in their marshal_with decorator, which allows a skip_none parameter to be passed in (docs). The solution for this would be to allow the responds decorator to similarly take a skip_none bool parameter (defaulting to False), which would filter out any None value fields produced in the serialized object.
I can try and get a tested solution put into a PR. I think it should just be something like this in def responds:
if skip_none:
serialized = {k:v for k, v in serialized.items() if v is not None}
The text was updated successfully, but these errors were encountered:
Hi,
It would be nice if there was a way to filter out any fields where the return value is
None
. Flask-RESTX provides this functionality in theirmarshal_with
decorator, which allows askip_none
parameter to be passed in (docs). The solution for this would be to allow theresponds
decorator to similarly take askip_none
bool parameter (defaulting toFalse
), which would filter out anyNone
value fields produced in the serialized object.I can try and get a tested solution put into a PR. I think it should just be something like this in
def responds
:The text was updated successfully, but these errors were encountered: