Skip to content

Draft 7 $ref at root with sibling definitions #622

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

Closed
gregsdennis opened this issue Nov 30, 2022 · 1 comment
Closed

Draft 7 $ref at root with sibling definitions #622

gregsdennis opened this issue Nov 30, 2022 · 1 comment

Comments

@gregsdennis
Copy link
Member

gregsdennis commented Nov 30, 2022

We don't have a test that ensures implementations don't scan for nested schema objects or schema resources (if that's indeed the requirement).

{
  "$ref": "#/definitions/reference",
  "definitions": {
    "reference": { "type": "integer" }
  }
}

I suppose this would be okay since the reference is just a pointer into data that happens to be itself, but if it were a reference to a nested $id (with either a URI base change or an anchor), it would definitely fail.

We do have a test to make sure that a sibling $id doesn't change the base URI, but the $ref in question isn't at the root, so would

{
  "$id": "http://example.com/base",
  "$ref": "myInteger#/definitions/integer",
}

ignore the $id? What would the base URI be, then?

(I suspect things like this were a factor in the reason we decided to allow sibling keywords, but we still need to know how this works.)

The spec merely says:

All other properties in a "$ref" object MUST be ignored.

I expect the anticipation was (as was common practice at the time) to wrap a root reference in an allOf.

This comes out of an old user test of mine that has a case similar to the top example. I encountered it after refactoring my reference management a bit. I didn't notice the root-level $ref at the time.

@jdesrosiers
Copy link
Member

It was determined that the behavior in this case is implementation defined. See, #458

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