0
votes

An excerpt from http://json-schema.org/draft-07/json-schema-core.html#rfc.section.8.2.4

{
    "$id": "http://example.com/root.json",
    "definitions": {
        "A": { "$id": "#foo" },
        "B": {
            "$id": "other.json",
            "definitions": {
                "X": { "$id": "#bar" },
                "Y": { "$id": "t/inner.json" }
            }
        },
        "C": {
            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
        }
    }
}

The schemas at the following URI-encoded JSON Pointers [RFC6901] (relative to the root schema) have the following base URIs, and are identifiable by any listed URI in accordance with Section 5 above:

...
#/definitions/B/definitions/X
        http://example.com/other.json#bar
        http://example.com/other.json#/definitions/X
        http://example.com/root.json#/definitions/B/definitions/X
...

Why isn't http://example.com/root.json#bar a valid base URI for #/definitions/B/definitions/X?

1
I notice you also posted the same question on the JSON Schema Google Group (which I approved). You are more likely to get answers by posting here, as the community activly monitors and is alerted to the jsonschema tag.Relequestual

1 Answers

2
votes

http://example.com/root.json#bar would not be resolveable with the given schema.

Think of it like anchors in HTML. $id is like defining a new page, so the location of #/definitions/B falls under "the page" $other.json, hence http://example.com/other.json#bar in the list you included that are equivilents for #/definitions/B/definitions/X.

If you create an HTML page which is at http://example.com/root.json, and try to click a link which is #bar, it would not find the # location because it's on the other.json page.

Please let me know if any of this doesn't make sense or is confusing.