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
class Optional(lt.Optional):
def __init__(self, *args, **kwargs):
if 'load_default' in kwargs:
kwargs.pop('load_default')
super(Optional, self).__init__(*args, load_default=s.MISSING, **kwargs)
def load(self, data, context=None, *args, **kwargs):
if data is s.MISSING:
return self.load_default(context)
elif data is None:
return data
return super(Optional, self).load(
self.inner_type.load(data, context=context, *args, **kwargs),
*args, **kwargs
)
With that use following code to see the failure
>>> import lollipop.types as lt
>>> from lollipop_jsonschema import json_schema as lollipop2jsonschema
>>>
>>> lollipop2jsonschema(lt.Optional(s.String()))
OrderedDict([('type', 'string')])
>>> lollipop2jsonschema(Optional(s.String()))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/lollipop_jsonschema/jsonschema.py", line 140, in json_schema
js['default'] = schema.inner_type.dump(default)
File "/usr/local/lib/python2.7/dist-packages/lollipop/types.py", line 212, in dump
self._fail('required')
File "/usr/local/lib/python2.7/dist-packages/lollipop/errors.py", line 63, in _fail
raise ValidationError(msg)
lollipop.errors.ValidationError: Invalid data: 'Value is required'
The text was updated successfully, but these errors were encountered:
We have a custom type like this
With that use following code to see the failure
The text was updated successfully, but these errors were encountered: