Skip to content

Handle $id property for draft6 in validates() #417

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 1 commit into from
Jul 8, 2018

Conversation

robherring
Copy link
Contributor

Fix another spot where 'id' vs. '$id' needs to be handled for draft 6+.

Signed-off-by: Grant Likely [email protected]
[robh: re-word commit message]
Signed-off-by: Rob Herring [email protected]

@Julian
Copy link
Member

Julian commented May 29, 2018

Here though I think this (unfortunately) is the right solution, this too needs tests!

(And thanks again!)

@Julian
Copy link
Member

Julian commented May 29, 2018

And likely a quick note in the docstring.

@robherring
Copy link
Contributor Author

Something like this?

def test_custom_validator_draft6(self):
    Validator = validators.create(
        meta_schema={"$id": "meta schema id"},
        version="12",
    )
    schema = {"$schema": "meta schema id"}
    self.assertIs(
        validators.validator_for(schema),
        Validator,
    )

@Julian
Copy link
Member

Julian commented May 29, 2018

Yep, exactly!

I'd add one more that uses validates directly since that too is public API and is being changed here (with a similar assertion to what you have there, or just one that asserts on meta_schemas since unfortunately that's public API)

And ideally a third that tests the behavior for when id and $id are both present -- the code you have here (intentionally or otherwise) prioritizes one over the other, but I'm inclined to think that we should raise an exception and refuse to guess there.

Fix another spot where 'id' vs. '$id' needs to be handled for draft 6+.

Signed-off-by: Grant Likely <[email protected]>
[robh: add testcases, re-word commit message]
Signed-off-by: Rob Herring <[email protected]>
@robherring
Copy link
Contributor Author

@Julian Any issues with this change?

@Julian
Copy link
Member

Julian commented Jun 7, 2018 via email

@Julian Julian merged commit fa39b24 into python-jsonschema:master Jul 8, 2018
Julian added a commit that referenced this pull request Jul 25, 2020
ea41553 Remove test that doesn't match RFC 3339 duration grammar
dee8ef7 Merge pull request #411 from ChALkeR/chalker/more-unevaluted
cd88fb5 Add more nested and cousin unevaluatedProperties tests
5f3dc7e Merge pull request #415 from json-schema-org/ether/more-ipv6-tests
04ddab1 some more ipv6 tests
acb45cd Merge pull request #417 from ChALkeR/chalker/patternProperties
0f4b73a One more patternProperties test with boolean schemas
8ccbfdc Merge pull request #412 from json-schema-org/ether/more-format-duration-2
1329dab some more tests for the "duration" format
1d5c3c0 Merge pull request #405 from ChALkeR/chalker/email-format
7ad7443 Extend email format tests

git-subtree-dir: json
git-subtree-split: ea415537dda2613f3cd5df1f219f84086f75a7dc
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.

3 participants