"index_source": {"title": "Index source","type": "integer","x-nullable": true},
def xnullable_type(validator, types, instance, schema):if instance is None and schema.get('x-nullable', False):returnreturn type_draft4(validator, types, instance, schema)SwaggerValidator = validators.extend(Draft4Validator, validators={'type': xnullable_type,})
Your code also uses type_draft4, which I *suspect* means you've imported jsonschema._validators.type_draft4, which is quite clearly private :). I gave you the public thing you should be using instead.-J
def xnullable_type(validator, types, instance, schema):if instance is None and schema.get('x-nullable', False):return
return Draft4Validator.VALIDATORS['type'](validator, types, instance, schema)
--
You received this message because you are subscribed to the Google Groups "jsonschema - An implementation of JSON Schema for Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonschema+...@googlegroups.com.
To post to this group, send email to jsons...@googlegroups.com.
Yep
super().validate_type(...)
validator.type = MethodType(xnullable_type, validator)
def xnullable_type(validator, types, instance, schema):if instance is None and schema.get('x-nullable', False):returnreturn Draft4Validator.VALIDATORS['type'](validator, types, instance, schema)
def xnullable_enum(validator, types, instance, schema):
if instance is None and schema.get('x-nullable', False):return
return Draft4Validator.VALIDATORS['enum'](validator, types, instance, schema)
SwaggerValidator = validators.extend(Draft4Validator, validators={'type': xnullable_type,
'enum': xnullable_enum,})