Skip to content

Feature - allow inheriting load_default from nested schema populated with from_dict #2889

@nneul

Description

@nneul

Using with APIFlask

class APICreateTicketIn(Schema):
    notify = fields.Nested(
        Schema.from_dict(
            {
                "reviewer": fields.Boolean(load_default=False),
                "requestor": fields.Boolean(load_default=False),
                "responsible": fields.Boolean(load_default=False),
            },
            name="APICreateTicketIn_Notify",
        ),
        load_default={
            "reviewer": False,
            "requestor": False,
            "responsible": False,
        },
        required=False,
    )

If only the 'load_default' in the nested "notify" schema are supplied, it doesn't actually get any defaults - had to add the raw load_default in the top level schema object. (I think the load_default in the from_dict isn't used at all.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions