Comments (7)
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?
from jsonschema.
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
from jsonschema.
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
from jsonschema.
Hmm, draft 4 just says:
JSON Schema uses JSON Reference [json‑reference] as a mechanism for schema addressing.
from jsonschema.
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.
from jsonschema.
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.
from jsonschema.
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.
from jsonschema.
Related Issues (20)
- Bug: checking required fields doesn't produce error when not present. HOT 2
- Failed to validate the schema when shifted from RefResolver to Registry HOT 4
- ModuleNotFoundError: No module named 'rpds.rpds' HOT 6
- PyO3 error HOT 5
- Draft07Valiadator doesn't validate dates HOT 1
- Inconsistent behaviour of validator_for depending on http vs https HOT 2
- Validation starting from sub-definition
- Getting schema contents after refs are resolved HOT 1
- `format: uri` doesn't work properly HOT 4
- Issue with oneOf validation HOT 6
- Unable to resolve a realtive `$ref` from a schema with `$id` pointed to a subschema in `$defs` with `$id` HOT 2
- Self referenced schema encapsulation breaks reference resolution HOT 1
- jsonschema.TypeChecker with additional types fails to work after several reference resolutions by the referencing.Registry HOT 2
- validate fails to identify incorrect uuid strings HOT 3
- 'Tuple' arrays not handled correctly HOT 3
- validate() throwing exception for a valid schema HOT 1
- Draft7Validator(TyperError: create.<locals>.Validator.__init__() got an unexpected keyword argument 'registry' HOT 2
- Which is the last version not requiring Rust via its dependencies?
- Migrating From RefResolver, unable to resolve $ref
- Feature request: Add support for a second message attribute on errors which is guaranteed not to include the failing instance HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonschema.