Skip to content

Add test for properties named $ref #125

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
Aug 28, 2016
Merged

Add test for properties named $ref #125

merged 1 commit into from
Aug 28, 2016

Conversation

matt-allan
Copy link

The JSON Reference spec states:

A JSON Reference is a JSON object, which contains a member named
"$ref", which has a JSON string value. Example:

{ "$ref": "http://example.com/example.json#/foo/bar" }

If a JSON value does not have these characteristics, then it SHOULD
NOT be interpreted as a JSON Reference.

The swagger schema declares a property named $ref that is not actually a reference, like this:

"properties": {
        "$ref": {
          "type": "string"
        }
      }

Since the value is not a string, it's not considered a reference and should not be dereferenced.

This test ensures that a validator will not attempt to dereference a property named $ref when the value is not a string.

@Julian
Copy link
Member

Julian commented Aug 28, 2016

Might belong a bit more in the properties tests than the ref tests, can't really decide, but thanks!

@Julian Julian merged commit 5fb3d9f into json-schema-org:develop Aug 28, 2016
@epoberezkin
Copy link
Member

epoberezkin commented Aug 28, 2016

This test ensures that a validator will not attempt to dereference a property named $ref when the value is not a string.

"when the value is not a string" is an unnecessary qualifier here, the validators simply should not assign any special meaning to properties of properties keyword, everything is just a property name, and unless its value is an object (and a valid schema) the schema is invalid (e.g. if $ref is a string here).

@matt-allan
Copy link
Author

To be clear, the intention of the test is to to ensure that the validator will not attempt to dereference any property named $ref when the value is not a string. I was just explaining what this specific test is doing. This test places the $ref under properties but it could be anywhere in the schema.

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