Skip to content

Why do we need a special "Internal References" section? #545

Closed
@handrews

Description

@handrews

I've lost track of the reason for Section 9.2.1 Internal References. Is this intended to produce any difference in actual behavior from just relying on the natural behavior of defining a plain name fragment with $id?

The only thing that I can see that might have any effect is (emphasis added):

which is understood as the schema defined elsewhere in the same document without needing to resolve the fragment against the base URI.

So given this schema, which modifies the 9.2.1 example to have two nested "items", the outer of which sets its own absolute URI $id:

{
    "$id": "http://example.net/root.json",
    "items": {
        "$id": "http://example.net/other.json",
        "items": {
            "type": "array",
            "items": { "$ref": "#item" }
        }
    },
    "definitions": {
        "single": {
            "$id": "#item",
            "type": "integer"
        }
    }
}

If we go by pure RFC 3986 rules, then the $ref resolves to http://example.net/other.json#item which does not appear to exist, as the fully resolve URI of the schema at #/definitions/single is http://example.net/root.json#item.

But the "in the same file" wording could be read to mean "forget base URIs, if there's a plain name fragment in the same physical file, you MUST ignore RFC 3986 and resolve to that fragment even if the fully resolved URIs of the $ref and $id in question are different.

So my questions are:

  1. Is this difference in behavior what is intended?
  2. If so, WHY???????
  3. If we don't have a really, really, really compelling reason for the behavior, can we get rid of it and just rely on the usual interpretation of fragments and URI reference resolution per RFC 3986? $id is hard enough for people to get right without special-casing it.

Paging @awwright @Relequestual @johandorland

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions