Skip to content

Fill root default if empty #32

@larsmaxfield

Description

@larsmaxfield

Currently the default at the root of a schema or subschema is not applied (it's not even looked for) in fill_default if the corresponding level of the instance is empty.

Root defaults should be applied if the corresponding level of the instance is empty.

Modified example from #30 (comment):

schema = {
    "properties": {
        "pool": {
            "properties": {
                "max_connections": {"type": "integer"},
                "min_connections": {"type": "integer"}
            }
        }
    },
    "default": {
        "pool": {
            "max_connections": 8,
            "min_connections": 0
        }
    }
}

instance = {}
fill_default(instance, schema)
assert instance == {"pool": {"max_connections": 8, "min_connections": 0}}, instance

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions