176
176
<postamble >
177
177
If the instance is {"id": 1234}, and its base URI according to
178
178
<xref target =" RFC3986" >RFC 3986 section 5.1</xref >, is
179
- "https://api. example.com/", then "https://api. example.com/thing/1234"
179
+ "https://example.com/api/ ", then "https://example.com/api /thing/1234"
180
180
is the resulting link's target URI.
181
181
</postamble >
182
182
</figure >
@@ -1551,14 +1551,14 @@ for varname in templateData:
1551
1551
<section title =" Entry Point Links, No Templates" anchor =" entryPoint" >
1552
1552
<t >
1553
1553
For this example, we will assume an example API with a documented
1554
- entry point URI of https://api. example.com, which is an empty JSON object
1554
+ entry point URI of https://example.com/api , which is an empty JSON object
1555
1555
with a link to a schema. Here, the entry point has no data of its
1556
1556
own and exists only to provide an initial set of links:
1557
1557
</t >
1558
1558
<figure >
1559
1559
<artwork >
1560
1560
<![CDATA[
1561
- GET https://api. example.com HTTP/1.1
1561
+ GET https://example.com/api HTTP/1.1
1562
1562
1563
1563
200 OK
1564
1564
Content-Type: application/json
@@ -1570,27 +1570,33 @@ Link: <https://schema.example.com/entry>; rel="describedBy"
1570
1570
<t >
1571
1571
The linked hyper-schema defines the API's base URI and provides
1572
1572
two links: an "about" link to API documentation, and a "self"
1573
- link indicating that this is a schema for the base URI. In this
1574
- case the base URI is also the entry point URI.
1573
+ link indicating that this is a schema for the base URI.
1575
1574
</t >
1576
1575
<figure >
1577
1576
<artwork >
1578
1577
<![CDATA[
1579
1578
{
1580
1579
"$id": "https://schema.example.com/entry",
1581
1580
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
1582
- "base": "https://api. example.com/",
1581
+ "base": "https://example.com/api /",
1583
1582
"links": [
1584
1583
{
1585
1584
"rel": "self",
1586
- "href": ""
1585
+ "href": "../api",
1587
1586
}, {
1588
1587
"rel": "about",
1589
- "href": "/ docs"
1588
+ "href": "docs"
1590
1589
}
1591
1590
]
1592
1591
}]]>
1593
1592
</artwork >
1593
+ <postamble >
1594
+ Due to quirks of the RFC 3986 URI-reference resolution algorithm,
1595
+ the "self" link needs to duplicate the "api" part of the path
1596
+ in order to produce a URI without a trailing slash.
1597
+ URIs, of course, may have trailing slashes, but this example
1598
+ is intended to highlight this frequently confusing special case.
1599
+ </postamble >
1594
1600
</figure >
1595
1601
<t >
1596
1602
These are the simplest possible links, with only a relation type and
@@ -1600,17 +1606,17 @@ Link: <https://schema.example.com/entry>; rel="describedBy"
1600
1606
<artwork >
1601
1607
<![CDATA[ [
1602
1608
{
1603
- "contextUri": "https://api. example.com",
1609
+ "contextUri": "https://example.com/api ",
1604
1610
"contextPointer": "",
1605
1611
"rel": "self",
1606
- "targetUri": "https://api. example.com",
1612
+ "targetUri": "https://example.com/api ",
1607
1613
"attachmentPointer": ""
1608
1614
},
1609
1615
{
1610
- "contextUri": "https://api. example.com",
1616
+ "contextUri": "https://example.com/api ",
1611
1617
"contextPointer": "",
1612
1618
"rel": "about",
1613
- "targetUri": "https://api. example.com/docs",
1619
+ "targetUri": "https://example.com/api /docs",
1614
1620
"attachmentPointer": ""
1615
1621
}
1616
1622
]]]>
@@ -1633,7 +1639,7 @@ Link: <https://schema.example.com/entry>; rel="describedBy"
1633
1639
<![CDATA[ {
1634
1640
"$id": "https://schema.example.com/thing",
1635
1641
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
1636
- "base": "https://api. example.com/",
1642
+ "base": "https://example.com/api /",
1637
1643
"type": "object",
1638
1644
"required": ["data"],
1639
1645
"properties": {
@@ -1830,7 +1836,7 @@ Link: <https://schema.example.com/entry>; rel="describedBy"
1830
1836
</list >
1831
1837
</t >
1832
1838
<t >
1833
- So, given the following instance retrieved from "https://api. example.com/stuff":
1839
+ So, given the following instance retrieved from "https://example.com/api /stuff":
1834
1840
</t >
1835
1841
<figure >
1836
1842
<artwork >
@@ -1848,7 +1854,7 @@ Link: <https://schema.example.com/entry>; rel="describedBy"
1848
1854
<figure >
1849
1855
<artwork >
1850
1856
<![CDATA[ {
1851
- "contextUri": "https://api. example.com/stuff",
1857
+ "contextUri": "https://example.com/api /stuff",
1852
1858
"contextPointer": "",
1853
1859
"rel": "author",
1854
1860
"hrefInputTemplates": [
@@ -1902,14 +1908,14 @@ Link: <https://schema.example.com/entry>; rel="describedBy"
1902
1908
</preamble >
1903
1909
<artwork >
1904
1910
<![CDATA[
1905
- GET https://api. example.com/trees/1/nodes/123 HTTP/1.1
1911
+ GET https://example.com/api /trees/1/nodes/123 HTTP/1.1
1906
1912
1907
1913
200 OK
1908
1914
Content-Type: application/json
1909
- Link: <https://api. example.com/trees/1/nodes/123>; rel="self"
1910
- Link: <https://api. example.com/trees/1/nodes/123>; rel="up";
1911
- anchor="https://api. example.com/trees/1/nodes/456"
1912
- Link: <https://api. example.com/trees/1/nodes/456>; rev="up"
1915
+ Link: <https://example.com/api /trees/1/nodes/123>; rel="self"
1916
+ Link: <https://example.com/api /trees/1/nodes/123>; rel="up";
1917
+ anchor="https://example.com/api /trees/1/nodes/456"
1918
+ Link: <https://example.com/api /trees/1/nodes/456>; rev="up"
1913
1919
{
1914
1920
"id": 123,
1915
1921
"treeId": 1,
@@ -1998,7 +2004,7 @@ Link: <https://api.example.com/trees/1/nodes/456>; rev="up"
1998
2004
<![CDATA[ {
1999
2005
"$id": "https://schema.example.com/thing",
2000
2006
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
2001
- "base": "https://api. example.com/",
2007
+ "base": "https://example.com/api /",
2002
2008
"type": "object",
2003
2009
"required": ["data"],
2004
2010
"properties": {
@@ -2051,7 +2057,7 @@ Link: <https://api.example.com/trees/1/nodes/456>; rev="up"
2051
2057
<![CDATA[ {
2052
2058
"$id": "https://schema.example.com/thing-collection",
2053
2059
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
2054
- "base": "https://api. example.com/",
2060
+ "base": "https://example.com/api /",
2055
2061
"type": "object",
2056
2062
"required": ["elements"],
2057
2063
"properties": {
@@ -2104,52 +2110,52 @@ Link: <https://api.example.com/trees/1/nodes/456>; rev="up"
2104
2110
<artwork >
2105
2111
<![CDATA[ [
2106
2112
{
2107
- "contextUri": "https://api. example.com/things",
2113
+ "contextUri": "https://example.com/api /things",
2108
2114
"contextPointer": "",
2109
2115
"rel": "self",
2110
- "targetUri": "https://api. example.com/things",
2116
+ "targetUri": "https://example.com/api /things",
2111
2117
"attachmentPointer": ""
2112
2118
},
2113
2119
{
2114
- "contextUri": "https://api. example.com/things",
2120
+ "contextUri": "https://example.com/api /things",
2115
2121
"contextPointer": "/elements/0",
2116
2122
"rel": "self",
2117
- "targetUri": "https://api. example.com/things/12345",
2123
+ "targetUri": "https://example.com/api /things/12345",
2118
2124
"attachmentPointer": "/elements/0"
2119
2125
},
2120
2126
{
2121
- "contextUri": "https://api. example.com/things",
2127
+ "contextUri": "https://example.com/api /things",
2122
2128
"contextPointer": "/elements/1",
2123
2129
"rel": "self",
2124
- "targetUri": "https://api. example.com/things/67890",
2130
+ "targetUri": "https://example.com/api /things/67890",
2125
2131
"attachmentPointer": "/elements/1"
2126
2132
},
2127
2133
{
2128
- "contextUri": "https://api. example.com/things",
2134
+ "contextUri": "https://example.com/api /things",
2129
2135
"contextPointer": "",
2130
2136
"rel": "item",
2131
- "targetUri": "https://api. example.com/things/12345",
2137
+ "targetUri": "https://example.com/api /things/12345",
2132
2138
"attachmentPointer": "/elements/0"
2133
2139
},
2134
2140
{
2135
- "contextUri": "https://api. example.com/things",
2141
+ "contextUri": "https://example.com/api /things",
2136
2142
"contextPointer": "",
2137
2143
"rel": "item",
2138
- "targetUri": "https://api. example.com/things/67890",
2144
+ "targetUri": "https://example.com/api /things/67890",
2139
2145
"attachmentPointer": "/elements/1"
2140
2146
},
2141
2147
{
2142
- "contextUri": "https://api. example.com/things",
2148
+ "contextUri": "https://example.com/api /things",
2143
2149
"contextPointer": "/elements/0",
2144
2150
"rel": "collection",
2145
- "targetUri": "https://api. example.com/things",
2151
+ "targetUri": "https://example.com/api /things",
2146
2152
"attachmentPointer": "/elements/0"
2147
2153
},
2148
2154
{
2149
- "contextUri": "https://api. example.com/things",
2155
+ "contextUri": "https://example.com/api /things",
2150
2156
"contextPointer": "/elements/1",
2151
2157
"rel": "collection",
2152
- "targetUri": "https://api. example.com/things",
2158
+ "targetUri": "https://example.com/api /things",
2153
2159
"attachmentPointer": "/elements/1"
2154
2160
}
2155
2161
]]]>
@@ -2310,19 +2316,19 @@ Link: <https://api.example.com/trees/1/nodes/456>; rev="up"
2310
2316
<artwork >
2311
2317
<![CDATA[ [
2312
2318
{
2313
- "contextUri": "https://api. example.com/things",
2319
+ "contextUri": "https://example.com/api /things",
2314
2320
"contextPointer": "",
2315
2321
"rel": "self",
2316
2322
"targetUri":
2317
- "https://api. example.com/things?offset=0&limit=2",
2323
+ "https://example.com/api /things?offset=0&limit=2",
2318
2324
"attachmentPointer": ""
2319
2325
},
2320
2326
{
2321
- "contextUri": "https://api. example.com/things",
2327
+ "contextUri": "https://example.com/api /things",
2322
2328
"contextPointer": "",
2323
2329
"rel": "next",
2324
2330
"targetUri":
2325
- "https://api. example.com/things?offset=3&limit=2",
2331
+ "https://example.com/api /things?offset=3&limit=2",
2326
2332
"attachmentPointer": ""
2327
2333
}
2328
2334
]]]>
0 commit comments