Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty list for required fields ? #339

Closed
leplatrem opened this issue Jun 12, 2017 · 1 comment
Closed

Empty list for required fields ? #339

leplatrem opened this issue Jun 12, 2017 · 1 comment

Comments

@leplatrem
Copy link

In the specs, it says that Omitting this keyword has the same behavior as an empty array. .

However, using jsonschema, there seems to be a rule validating the number of elements:

>>> import jsonschema
>>> schema = {"required": []}
>>> jsonschema.validate({}, schema)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mathieu/Code/Mozilla/kinto/.venv/lib/python3.5/site-packages/jsonschema/validators.py", line 540, in validate
    cls.check_schema(schema)
  File "/home/mathieu/Code/Mozilla/kinto/.venv/lib/python3.5/site-packages/jsonschema/validators.py", line 83, in check_schema
    raise SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: [] is too short

Failed validating 'minItems' in schema['properties']['required']:
    {'items': {'type': 'string'},
     'minItems': 1,
     'type': 'array',
     'uniqueItems': True}

On instance['required']:
    []
>>> 

Let me know if I can help and submit a fix :)

Thanks!

@Julian
Copy link
Member

Julian commented Jun 12, 2017

That's the spec for draft 6, not draft 4, and that's a thing that changed in draft 6.

Support for draft 6 is happening in #337 on the draft-06 branch, so definitely welcome patches on that branch!

@Julian Julian closed this as completed Jun 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants