Skip to content

Commit fcf410d

Browse files
committed
Rework '"targetSchema" and HTTP'
This is an attempt to introduce concepts in a better order and generally improve the flow. Examples relevant to this section will be submitted separately once decisions are made as to where they should go.
1 parent 9e554cc commit fcf410d

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

jsonschema-hyperschema.xml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,29 +1330,38 @@ for varname in templateData:
13301330
</section>
13311331
<section title='"targetSchema" and HTTP' anchor="targetHTTP">
13321332
<t>
1333-
The relationship between a resource's representation and HTTP requests and
1334-
responses is determined by <xref target="RFC7231">RFC 7231, section 4.3.1 -
1335-
"GET", section 4.3.4 "PUT", and section 3.1.4.2, "Content-Location"</xref>.
1333+
"targetSchema" describes the resource on the other end of the link, while
1334+
"targetMediaType" defines that resource's media type. With HTTP links,
1335+
"headerSchema" can also be used to describe valid values for use in an
1336+
"Accept" request header, which can support multiple media types or
1337+
media ranges. When both ways of indicating the target media type are
1338+
present, "targetMediaType" SHOULD indicate the default representation
1339+
media type, while the schema for "accept" in "headerSchema" SHOULD include
1340+
the default as well as any alternate media types or media ranges that can
1341+
be requested.
1342+
</t>
1343+
<t>
1344+
Since the semantics of many HTTP methods are defined in terms of the target
1345+
resource, "targetSchema" is used for requests and/or responses for several
1346+
HTTP methods.
13361347
In particular, "targetSchema" suggests what a client can expect for the
13371348
response to an HTTP GET or any response for which the "Content-Location"
13381349
header is equal to the request URI, and what a client should send if it
13391350
replaces the resource in an HTTP PUT request.
1340-
</t>
1341-
<t>
1342-
The media type of the representation is given by the "targetMediaType"
1343-
field. Alternatively, possible available media types MAY be advertised
1344-
for HTTP-accessible resources using the "accept" field in "headerSchema",
1345-
corresponding to the HTTP "Accept" header.
1351+
These correlations are defined by <xref target="RFC7231">RFC 7231,
1352+
section 4.3.1 - "GET", section 4.3.4 "PUT", and section 3.1.4.2,
1353+
"Content-Location"</xref>.
13461354
</t>
13471355
<t>
13481356
Per <xref target="RFC5789">RFC 5789</xref>, the request structure for an HTTP
13491357
PATCH is determined by the combination of "targetSchema" and the request
1350-
media type, which is conveyed by the "Accept-Patch" header. Media types
1351-
that are suitable for PATCH-ing define a syntax for expressing changes
1352-
to a document, which can be applied to the representation described by
1353-
"targetSchema" to determine the set of syntactically valid request payloads.
1354-
Often, the simplest way to validate a PATCH is to apply it and validate
1355-
the result as a normal representation.
1358+
media type, which is conveyed by the "Accept-Patch" header, which may be
1359+
included in "targetHints". Media types that are suitable for PATCH-ing
1360+
define a syntax for expressing changes to a document, which can be applied
1361+
to the representation described by "targetSchema" to determine the set of
1362+
syntactically valid request payloads. Often, the simplest way to validate
1363+
a PATCH request is to apply it and validate the result as a normal
1364+
representation.
13561365
</t>
13571366
<t>
13581367
HTTP POST request payloads are described by the "submissionSchema" and

0 commit comments

Comments
 (0)