Skip to content

Documenting callable default #196

Closed
Closed
@lafrech

Description

@lafrech

When a default/missing value is a callable, it is called when generating the documentation.

    if default is not marshmallow.missing:
        if callable(default):
            ret['default'] = default()
        else:
            ret['default'] = default

This can be wrong if the value of the callable depends on the moment it is called. Typically, if it is dt.datetime.now. There should be an opt-out for this allowing to specify an alternative text to write in the docs.

Not sure how to do that. Maybe a default_doc attribute in the Schema that would take precedence over default/missing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions