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 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}
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_withdecorator, which allows askip_noneparameter to be passed in (docs). The solution for this would be to allow therespondsdecorator to similarly take askip_nonebool parameter (defaulting toFalse), which would filter out anyNonevalue 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: