diff --git a/jsonschema-hyperschema.xml b/jsonschema-hyperschema.xml index b67921ad..d5971b9c 100644 --- a/jsonschema-hyperschema.xml +++ b/jsonschema-hyperschema.xml @@ -176,7 +176,7 @@ If the instance is {"id": 1234}, and its base URI according to RFC 3986 section 5.1, is - "https://api.example.com/", then "https://api.example.com/thing/1234" + "https://example.com/api/", then "https://example.com/api/thing/1234" is the resulting link's target URI. @@ -1551,14 +1551,14 @@ for varname in templateData:
For this example, we will assume an example API with a documented - entry point URI of https://api.example.com, which is an empty JSON object + entry point URI of https://example.com/api, which is an empty JSON object with a link to a schema. Here, the entry point has no data of its own and exists only to provide an initial set of links:
; rel="describedBy" The linked hyper-schema defines the API's base URI and provides two links: an "about" link to API documentation, and a "self" - link indicating that this is a schema for the base URI. In this - case the base URI is also the entry point URI. + link indicating that this is a schema for the base URI.
@@ -1579,14 +1578,14 @@ Link: ; rel="describedBy" { "$id": "https://schema.example.com/entry", "$schema": "http://json-schema.org/draft-08/hyper-schema#", - "base": "https://api.example.com/", + "base": "https://example.com/api/", "links": [ { "rel": "self", - "href": "" + "href": "../api", }, { "rel": "about", - "href": "/docs" + "href": "docs" } ] }]]> @@ -1596,21 +1595,41 @@ Link: ; rel="describedBy" These are the simplest possible links, with only a relation type and an "href" with no template variables. They resolve as follows: + + The duplication of "api" in both the base and the "../api" + href in the "self" link is due to quirks of the RFC 3986 + URI-reference resolution algorithm. In order for relative + URI-references to work well in general, the base URI needs + to include a trailing slash. The "about" link with its "docs" + href shows the common case of relative references, which is + used in the other examples in this document. + + + However, if an API uses URIs without trailing slashes for its resources, + there is no way to provide a relative reference that just removes a + trailing slash without duplicating the path component above it. + Which makes the case of the entry point resource, which differs + from the base URI only in terms of the trailing slash, somewhat awkward. + + + Resource URIs, of course, may have trailing slashes, but this example + is intended to highlight this frequently confusing special case. +
@@ -1633,7 +1652,7 @@ Link: ; rel="describedBy" ; rel="describedBy" - So, given the following instance retrieved from "https://api.example.com/stuff": + So, given the following instance retrieved from "https://example.com/api/stuff":
@@ -1848,7 +1867,7 @@ Link: ; rel="describedBy"
; rel="describedBy" ; rel="self" -Link: ; rel="up"; - anchor="https://api.example.com/trees/1/nodes/456" -Link: ; rev="up" +Link: ; rel="self" +Link: ; rel="up"; + anchor="https://example.com/api/trees/1/nodes/456" +Link: ; rev="up" { "id": 123, "treeId": 1, @@ -1998,7 +2017,7 @@ Link: ; rev="up" ; rev="up" ; rev="up" @@ -2310,19 +2329,19 @@ Link: ; rev="up"