Skip to content

wildcard string None fix #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flask_restx/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def _append(k, v):
_append(key, value)
while True:
value = field.output(dkey, data, ordered=ordered)
if value is None or value == field.container.format(
if value is None or (field.default is not None and value == field.container.format(
field.default
):
)):
break
key = field.key
_append(key, value)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ def test_marshal_with_skip_none(self):
output = marshal(marshal_dict, model, skip_none=True)
assert output == {"foo": "bar"}

def test_marshal_wildcard_none_str(self):
wild = fields.Wildcard(fields.String)
model = OrderedDict([("*", wild)])
marshal_dict = OrderedDict(
[("a", "None"), ("b", "tata")]
)
output = marshal(marshal_dict, model)
assert output == {"a": "None", "b": "tata"}

def test_marshal_wildcard_with_skip_none(self):
wild = fields.Wildcard(fields.String)
model = OrderedDict([("foo", fields.Raw), ("*", wild)])
Expand Down