You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def _extend_validator_with_defaults(self, validator_class):
original_validator = validator_class.VALIDATORS["properties"]
def _properties_set_defaults(validator, properties, instance, schema):
# set the defaults before anything else. Then we will validate also the defaults
for property, subschema in properties.items():
if "default" in subschema:
instance.setdefault(property, subschema["default"])
if property in instance:
yield from validator.descend(
instance[property],
subschema,
path=property,
schema_path=property,
)
yield from original_validator(validator, properties, instance, schema)
return validators.extend(validator_class, {
"properties": _properties_set_defaults,
})
As soon as I descend into a reference (which contains a subschema), the custom validator is not called anymore.
The text was updated successfully, but these errors were encountered:
I have created a custom validator, Extending Draft7Validator to set defaults following the example in https://python-jsonschema.readthedocs.io/en/stable/faq/#why-doesn-t-my-schema-s-default-property-set-the-default-on-my-instance
As soon as I descend into a reference (which contains a subschema), the custom validator is not called anymore.
The text was updated successfully, but these errors were encountered: