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

Ignore other properties when $ref is present #81

Closed
gazpachoking opened this issue Mar 5, 2013 · 7 comments
Closed

Ignore other properties when $ref is present #81

gazpachoking opened this issue Mar 5, 2013 · 7 comments

Comments

@gazpachoking
Copy link
Contributor

According to the json reference spec, we should ignore all other properties when $ref is present. Currently we validate them all anyway.

@Julian
Copy link
Member

Julian commented Mar 5, 2013

Not saying we shouldn't do this as an optimization, but doesn't it say something like "when ref is encountered", which sounded like it meant whenever you happen to see the reference while you are validating that schema?

@gazpachoking
Copy link
Contributor Author

I was thinking of this line

Any members other than "$ref" in a JSON Reference object SHALL be ignored.

From here: http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03

@Julian
Copy link
Member

Julian commented Mar 5, 2013

That line governs JSON Reference. It means that if you're resolving JSON References you shouldn't fail to resolve because the reference has other members.

The relevant line covering what to do when validating JSON Schemas is:

When a validator encounters this attribute, it SHOULD replace the current schema with the schema referenced by the value's URI (if known and available) and re- validate the instance.

From http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.28

@gazpachoking
Copy link
Contributor Author

Hmm, draft 4 just says:

JSON Schema uses JSON Reference [json‑reference] as a mechanism for schema addressing.

@gazpachoking
Copy link
Contributor Author

Oh, and the 're- validate the instance' bit from draft 3 implies that any of the keywords you have already validated should be thrown out.

@Julian
Copy link
Member

Julian commented Mar 5, 2013

I don't think that means anything has changed, it just means either it was
left out accidentally or deemed unnecessary.

I'm also not sure that the intent of "re-validate" is to throw out what was
already seen, if it meant that out should have just mandated ignoring
everything but ref and said exactly those words.

Either way, if you want to add the pre-check I'm fine with that, since from
my standpoint even if allowing validating the other stuff is allowed, it's
not mandated and isn't something someone writing a schema should at all be
relying on, so it's a reasonable (although probably small) optimization.

Hmm, draft 4 just says:

JSON Schema uses JSON Reference [json‑reference] as a mechanism for schema
addressing.


Reply to this email directly or view it on GitHub.

@gazpachoking
Copy link
Contributor Author

Yeah, I think ultimately there aren't going to be any schemas that have stuff other than the $ref, unless they are written wrong, so it doesn't much matter. But I think @fge has also mentioned the intent of the spec was for other properties to be ignored when $ref is present.

@Julian Julian closed this as completed in 9da70c6 Mar 10, 2013
Julian added a commit that referenced this issue Mar 22, 2015
0b657e8 Merge pull request #86 from kylef/patch-1
1bd4151 [README] JSONSchema.swift uses these tests too
8f86716 Revert "Add jon, JSON parser for the fishshell."
db9c629 Merge pull request #82 from bucaran/patch-1
875fa42 Add jon, JSON parser for the fishshell.
64c556c Merge pull request #81 from s-panferov/patch-1
43105d4 Add new Rust library to the list
aa4d927 Merge pull request #80 from seagreen/implementations
20ef067 Add new haskell implementation.
1274070 Merge pull request #79 from Muscula/json-schema-benchmark
6d8cf45 Merge pull request #78 from JamesNK/patch-1
55c4992 Add json-schema-benchmark to list of users of this test suite
645623d Added Newtonsoft.Json.Schema implementation
a7944d1 Merge pull request #76 from Prestaul/patch-1
5729cdf Added skeemas to list of suite users
4600fe3 Make the implementation list a bit less unwieldy now that it's so long (hooray!)
11d6905 Merge remote-tracking branch 'mafintosh/patch-1' into develop
689b80f Merge pull request #74 from bugventure/develop
c36f888 Add request-validator as a user of the test suite
41876b1 Update README.md
aabcb34 Merge pull request #71 from seagreen/additionalproperties
b3d160b Add tests for additionalProperties by itself.

git-subtree-dir: json
git-subtree-split: 0b657e8b0d21a4099d3ce378ba7208073a9295e6
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