forked from platypush/platypush
Marshmallow has replaced field.default
with field.dump_default
.
This commit is contained in:
parent
8fd5009553
commit
e1b6be7673
1 changed files with 14 additions and 4 deletions
|
@ -59,6 +59,10 @@ class RstExtensionsMixin:
|
||||||
|
|
||||||
return cls._expand_module(docstr, ex_name, match, obj)
|
return cls._expand_module(docstr, ex_name, match, obj)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _field_default(field):
|
||||||
|
return getattr(field, "dump_default", getattr(field, "default", None))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _expand_schema(cls, docstr: str, match: re.Match) -> str:
|
def _expand_schema(cls, docstr: str, match: re.Match) -> str:
|
||||||
from marshmallow import missing
|
from marshmallow import missing
|
||||||
|
@ -98,19 +102,25 @@ class RstExtensionsMixin:
|
||||||
+ (
|
+ (
|
||||||
(
|
(
|
||||||
'"'
|
'"'
|
||||||
+ field.metadata.get("example", field.default)
|
+ field.metadata.get(
|
||||||
|
"example", cls._field_default(field)
|
||||||
|
)
|
||||||
+ '"'
|
+ '"'
|
||||||
if isinstance(
|
if isinstance(
|
||||||
field.metadata.get("example", field.default),
|
field.metadata.get(
|
||||||
|
"example", cls._field_default(field)
|
||||||
|
),
|
||||||
str,
|
str,
|
||||||
)
|
)
|
||||||
else str(
|
else str(
|
||||||
field.metadata.get("example", field.default)
|
field.metadata.get(
|
||||||
|
"example", cls._field_default(field)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if not (
|
if not (
|
||||||
field.metadata.get("example") is None
|
field.metadata.get("example") is None
|
||||||
and field.default is missing
|
and cls._field_default(field) is missing
|
||||||
)
|
)
|
||||||
else "..."
|
else "..."
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue