diff --git a/jsonschema-hyperschema.xml b/jsonschema-hyperschema.xml index d48264a2..658e0371 100644 --- a/jsonschema-hyperschema.xml +++ b/jsonschema-hyperschema.xml @@ -8,7 +8,9 @@ + + ]> @@ -654,7 +656,8 @@ resource is the instance to which the schema (or sub-schema) applies, rather than any larger document in which the instance may have been found. The context may be changed - with the "anchor" property. + with the "anchor" or + "anchorPointer" properties. @@ -793,6 +796,93 @@ GET /foo/ +
+ + This property changes the point within the instance that is considered + to be the context resource of the link. The value of the property MUST be a + valid JSON Pointer, or a valid + Relative JSON Pointer + which is evaluated relative to the position in the instance from which + "href" template variable resolution would + normally begin. + + + While an alternate context with a known URI is best set with the + "anchor" keyword, the lack of a fragment identifier + syntax for application/json means that it is usually not possible to + change the context within a JSON instance using a URI. + + + Even in "+json" media types that define JSON Pointer as a fragment identifier + syntax, if the default context is nested within an array, it is not possible to + obtain the index of the default context's position in that array in order + to construct a pointer to another property in that same nested JSON object. + + +
+ + For example, given this hyper-schema: + + + + + + The "item" relation indicates that each array entry can be used to construct + a link from the collection embedded in this instance to a resource for that + specific item. The default context of this link is the individual array + element. But the context of an "item" relation should be the collection, + which is the entire "examples" array. The Relative JSON Pointer of "1" + accomplishes this as follows: + +
+
+ + Given this instance of media type application/json: + + + + + + The default context for the link to "/examples/1234" is the first + array entry, and for the link to "/examples/5678" it is the second array + entry. But "anchorPointer" moves this up one instance level (the "1" + Relative JSON Pointer) to be the array containing each entry. + +
+ + If both "anchor" and "anchorPointer" are defined, and do not resolve to + the same link context, the resulting behavior is undefined. + +
+
This property defines a title for the link. @@ -1190,6 +1280,8 @@ GET /foo/ &rfc3986; &rfc6570; + &rfc6906; + &I-D.luff-relative-json-pointer; &I-D.reschke-http-jfv; diff --git a/links.json b/links.json index 76be45b1..00f22a1f 100644 --- a/links.json +++ b/links.json @@ -21,6 +21,13 @@ "type": "string", "format": "uri-reference" }, + "anchorPointer": { + "type": "string", + "anyOf": [ + { "format": "json-pointer" }, + { "pattern": "^[0-9]" } + ] + }, "title": { "type": "string" },