-
Notifications
You must be signed in to change notification settings - Fork 1
Option to not create missing parents if sub-properties have defaults #34
Copy link
Copy link
Closed
Description
... Let's say we have a database configuration described by a JSON schema.
schema = { "properties": { "pool": { "properties": { "max_connections": {"type": "int", "default": 8}, "min_connections": {"type": "int", "default": 0} } } } } instance = {} fill_default(instance, schema) assert instance == {}, instanceThe "pool" is optional and a user did not provide a config, so defaults are not expected.
But if a user provided an empty pool config:instance = {"pool": {}}Then defaults should be filled (because the user provided the "pool" config, it is just empty).
It is also possible to have a root default:
schema = { "properties": { "pool": { "properties": { "max_connections": {"type": "int", "default": 8}, "min_connections": {"type": "int", "default": 0} } } }, "default": { "pool": { "max_connections": 8, "min_connections": 0 } } }In this case, if a user provides an empty config, the root's default will be used.
Originally posted by @litteratum in #30
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels