Skip to content

Commit 924f7b3

Browse files
authored
Merge pull request #451 from handrews/content-negotiation
Guidance on content negotiation
2 parents 6773caf + e1d1290 commit 924f7b3

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

jsonschema-hyperschema.xml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,11 +1297,19 @@ for varname in templateData:
12971297
using protocols such as CoAP that are explicitly analogous to HTTP.
12981298
</t>
12991299
<t>
1300-
This section provides guidance on how to define links for use with each
1301-
common HTTP method, and how collection resources impose additional constraints
1302-
on the use of HTTP POST. Additionally, guidance is provided on hinting at
1303-
HTTP response header values and describing possible HTTP request headers
1304-
that are relevant to the given resource.
1300+
This section provides guidance on how to use each common HTTP method with a link,
1301+
and how colletion resources impose additional constraints on HTTP POST.
1302+
Additionally, guidance is provided on hinting at HTTP response header values and
1303+
describing possible HTTP request headers that are relevant to the given resource.
1304+
</t>
1305+
<t>
1306+
<xref target="json-schema">Section 11 of the JSON Schema core specification</xref>
1307+
provides guidance on linking instances in a hypermedia system to their schemas.
1308+
This may be done with network-accessible schemas, or may simply identify schemas
1309+
which were pre-packaged within the client application. JSON Hyper-Schema
1310+
intentionally does not constrain this mechanism, although it is RECOMMENDED that
1311+
the techniques outlined in the core specification be used to whatever extent
1312+
is possible.
13051313
</t>
13061314
<section title="One link per target and relation type">
13071315
<t>
@@ -1352,6 +1360,8 @@ for varname in templateData:
13521360
that are suitable for PATCH-ing define a syntax for expressing changes
13531361
to a document, which can be applied to the representation described by
13541362
"targetSchema" to determine the set of syntactically valid request payloads.
1363+
Often, the simplest way to validate a PATCH is to apply it and validate
1364+
the result as a normal representation.
13551365
</t>
13561366
<t>
13571367
HTTP POST request payloads are described by the "submissionSchema" and
@@ -1429,6 +1439,31 @@ for varname in templateData:
14291439
<xref target="collectionAndItem" />.
14301440
</t>
14311441
</section>
1442+
<section title="Content negotiation and schema evolution">
1443+
<t>
1444+
JSON Hyper-Schema facilitates HTTP content negotiation, and allows for
1445+
a hybrid of the proactive and reactive strategies. As mentioned
1446+
above, a hyper-schema can include a schema for HTTP headers such as
1447+
"Accept", "Accept-Charset", "Accept-Language", etc with the "headerSchema"
1448+
keyword. A user agent or client application can use information in
1449+
this schema, such as an enumerated list of supported languages, in lieu of
1450+
making an initial request to start the reactive negotiation process.
1451+
</t>
1452+
<t>
1453+
In this way, the proactive content negotiation technique of setting these
1454+
headers can be informed by server information about what values are
1455+
possible, similar to examining a list of alternatives in reactive negotiation.
1456+
</t>
1457+
<t>
1458+
For media types that allow specifying a schema as a media type parameter,
1459+
the "Accept" values sent in a request or advertised in "headerSchema" can
1460+
include the URI(s) of the schema(s) to which the negotiated representation
1461+
is expected to conform. One possible use for schema parameters in
1462+
content negotiation is if the resource has conformed to several different
1463+
schema versions over time. The client can indicate what version(s) it
1464+
understands in the "Accept" header in this way.
1465+
</t>
1466+
</section>
14321467
</section>
14331468

14341469
<section title="Examples" anchor="examples">

0 commit comments

Comments
 (0)