Skip to content

Made required_draft4 more robust when used with Draft3 #297

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

Merged
merged 3 commits into from
Oct 9, 2016

Conversation

wspeirs
Copy link

@wspeirs wspeirs commented Sep 28, 2016

When I try to validate a Draft3 schema using the Draft4 validator, you get the following error:

  File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 299, in required_draft4
    for property in required:
TypeError: 'bool' object is not iterable

My change fixes this issue by alerting the use to the mis-match in draft versions.

@Julian
Copy link
Member

Julian commented Sep 28, 2016

Hi! Thanks.

So, this would only happen if you didn't first verify you had a valid schema by using Draft4Validator.check_schema before you called Draft4Validator(schema).validate -- if you did, you'd see that the meta schema complains about having the wrong type there (which is why `jsonschema.validate calls that first before calling the method on the validator).

Generally, all the validators ask for and document that they need to be given valid schemas for their errors to be decipherable.

@wspeirs
Copy link
Author

wspeirs commented Sep 28, 2016 via email

@Julian
Copy link
Member

Julian commented Sep 28, 2016

Yes! Definitely, that is issue #208 -- would definitely appreciate a patch for that.

@wspeirs
Copy link
Author

wspeirs commented Sep 28, 2016

@Julian updated my PR to include a fix for #208 as well. If you want, you can cherry pick b44c1a2 but I think it's safe to pull in both changes.

@Julian
Copy link
Member

Julian commented Sep 28, 2016

Seems like it's in the right place, can you add a test?

@wspeirs
Copy link
Author

wspeirs commented Oct 3, 2016

@Julian added a unit test in 788ea8e

@Julian Julian merged commit 788ea8e into python-jsonschema:master Oct 9, 2016
@Julian
Copy link
Member

Julian commented Oct 9, 2016

Merged (at least the part that's correct here). Thanks -- really appreciate it.

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

Successfully merging this pull request may close these issues.

2 participants