Question about name resolution when $id is used

103 views
Skip to first unread message

Simon Sprott

unread,
Feb 2, 2020, 7:21:26 AM2/2/20
to JSON Schema
Im trying to figure out how to resolve references within a JSON Schema, when $id properties are involved.

I'm looking at the example in https://tools.ietf.org/html/draft-handrews-json-schema-01#section-8.2.4 whats described in there makes sense, but does not provide a complete explaination, so I've added definitions "Z", to the example to help explain.

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

According to the spec the following are valid references to "X"

   #/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

What I'm stuggling to figure out is what valid references to "Z" would look like

   #/definitions/B/definitions/X/definitions/Z

         http://example.com/other.json#bar/definitions/Z                          - not at all sure about this

         http://example.com/other.json#/definitions/X/definitions/Z               - this seesms like a logical progression

         http://example.com/root.json#/definitions/B/definitions/X/definitions/Z  - Happy with this one

Thanks for your help
Reply all
Reply to author
Forward
Message has been deleted
0 new messages