Skip to content

Commit

Permalink
Allow default value for fields to be callable.
Browse files Browse the repository at this point in the history
  • Loading branch information
NightBlues committed Jun 29, 2017
1 parent 47a3d98 commit 541f45b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apispec/ext/marshmallow/swagger.py
Expand Up @@ -232,7 +232,10 @@ def field2property(field, spec=None, use_refs=True, dump=True, name=None):

default = field.default if dump else field.missing
if default is not marshmallow.missing:
ret['default'] = default
try:
ret['default'] = default()
except TypeError:
ret['default'] = default

choices = field2choices(field)
if choices:
Expand Down

0 comments on commit 541f45b

Please sign in to comment.