Description
JSON Hyper-Schema should not include keywords that come from specific protocols, and certainly not ones that do not generalize well enough to apply to any protocol.
This would suggest that "allow"
as proposed by #73 would not be ideal as it is HTTP-specific, although the concept generalizes well, so it's not an unreasonable proposal either.
However, there are several things such as HTTP's "Allow", which would optimize and document how to use the protocol to interact with a link target, as opposed to the current LDO hints such as "mediaType"
which describe the target resource itself, independent of how it is accessed.
A more clear example is the "Accept-Patch" header, which is critical for correctly constructing an HTTP PATCH request (in conjunction with either "targetSchema"
or the schema linked in the response to a HEAD or GET to the target). "Accept-Patch" is very specific to HTTP (or, really, an extension to HTTP). No current Hyper-Schema keyword could accommodate it, and adding an "acceptPatch"
field to the LDO would be inappropriately specific.
One approach would be a "usageHints"
field for hinting at protocol usage meta-data that could otherwise be discovered by interacting with the target resource. This field would not encompass meta-data that describes the target resource independent of protocol.
The value of this keyword would be an object. The exact possible values for the contents of the object are deferred to the protocol and the target resource, but Hyper-Schema would define general rules to provide for interoperability.
Here's a strawman proposal:
- keys would be the meta-data field names in whatever form is deemed canonical by the relevant standards, e.g.
"Accept-Patch"
and not a JSON-ized"acceptPatch"
- values would be as they would exist in the protocol, except that lists and named fields SHOULD be structured using JSON arrays and objects
So if we wanted to hint at the following authentication header (example taken directly from RFC 7235)
WWW-Authenticate: Newauth realm="apps", type=1,
title="Login to \\"apps\\"", Basic realm="simple"
along with hinting at available HTTP methods (example taken directly from RFC 7231)
Allow: GET, HEAD, PUT
the result would look like:
becomes:
{
"rel": "self",
"href": "/foos/{id}",
"usageHints": {
"Allow": ["GET", "HEAD", "PUT"],
"WWW-Authenticate": {
"Newauth": {
"realm": "apps",
"type": 1,
"title": "Login to \"apps\""
},
"Basic": {
"realm": "simple"
}
}
}
}