validate() fails claiming optional property is mandatory
jayvdb opened this issue · 0 comments
jayvdb commented
When creating a Document for https://github.com/citation-style-language/schema/blob/master/csl-data.json , validate()
fails indicating an optional field is mandatory.
>>> import json, requests
>>> from json_document.document import Document
>>> SCHEMA_URL = 'https://raw.githubusercontent.com/citation-style-language/schema/master/csl-data.json'
>>> SCHEMA = json.loads(requests.get(SCHEMA_URL).content)
>>> doc = Document([], SCHEMA)
>>> doc.value.append({})
>>> doc.validate()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/json_document/document.py", line 191, in validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 100, in validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 114, in validate_toplevel
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 126, in _validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 430, in _validate_items
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 123, in _validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 316, in _validate_properties
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 159, in _report_error
json_schema_validator.errors.ValidationError: ValidationError: Object lacks property u'collection-title' object_expr='object[0]', schema_expr=u'schema.items.properties.collection-title.optional')
>>> SCHEMA['items']['properties']['collection-title']
{u'type': u'string'}
>>> doc.value[0]['collection-title'] = 'foo'
>>> doc.validate()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/json_document/document.py", line 191, in validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 100, in validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 114, in validate_toplevel
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 126, in _validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 430, in _validate_items
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 123, in _validate
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 316, in _validate_properties
File "build/bdist.linux-x86_64/egg/json_schema_validator/validator.py", line 159, in _report_error
json_schema_validator.errors.ValidationError: ValidationError: Object lacks property u'container-author' object_expr='object[0]', schema_expr=u'schema.items.properties.container-author.optional')
>>> SCHEMA['items']['properties']['container-author']
{u'items': {u'$ref': u'name-variable'}, u'type': u'array'}