Made it possible to have a property named "$ref" #360
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For a few weeks we've had a test from the json-schema common test suite
failing on master. The test was checking that it was possible to
validate a property named "$ref" (and that it wasn't reserved or
interpreted as a json-reference).
The problem was that whenever we had a property name that has special
meaning in json-schema (ie. one that matches the keys of the
Schema::Validator#attributes hash), we'd skip a level in the schema
object while validating, which would cause errors. To fix the problem
I've made sure we always descend one level at a time (see
attributes/additionalproperties.rb line 17).
Fixing this caused new tests to fail, in test/extends_nested_test.rb. It
turns out that these tests were depending on the old incorrect
behaviour.
What's more, the same tests were using an incorrect form of the extends
property. According to the json-schema spec, extends should take a
json-schema, or an array of json-schemas. However, these tests were
passing a string to extends. It seems that although this is incorrect,
we had code in attributes/extends.rb which would automatically correct
this incorrect syntax (ie. from {"extends": "foo.json"} to {"extends:
{"$ref": "foo.json"}}). I've removed that workaround, as well as
correcting the tests.
Fixes #357