Skip to content

Default values for webargs #32

@jmcarp

Description

@jmcarp

Now that webargs is using marshmallow internally, we specify default argument values using the missing parameter:

arg = fields.Str(missing='foo')

But apispec doesn't check the missing key when introspective parameter defaults--it only checks default. To get the correct swagger default, we have to specify both parameters:

arg = fields.Str(missing='foo', default='foo')

Which isn't ideal.

Since we're using the same logic to introspect fields and schemas that are used for serialization and deserialization, one approach would be to tell field2property and related methods whether they're introspecting load or dump. For the specific case of parameter defaults, we'd check default for dump and missing for load.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions