Skip to content

Commit a20e262

Browse files
dgebgabesullice
andauthored
Introduce extensions for v1.1 (json-api#1457)
* Amend the client and server content negotiation responsibilities to include the `ext` parameter * Clarify server responsibilities * Introduce extension namespacing * Add namespace example Co-authored-by: Gabe Sullice <gabriel@sullice.com>
1 parent cc6087c commit a20e262

File tree

1 file changed

+57
-10
lines changed

1 file changed

+57
-10
lines changed

_format/1.1/index.md

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ Clients and servers **MUST** send all JSON:API data using this media type in the
3636
`Content-Type` header.
3737

3838
Further, the JSON:API media type **MUST** always be specified with either no
39-
media type parameters or with only the `profile` parameter. This applies to both
40-
the `Content-Type` and `Accept` headers whenever they are present.
39+
media type parameters, the `ext` parameter, the `profile` parameter or both the
40+
`ext` and `profile` parameters. This applies to both the `Content-Type` and
41+
`Accept` headers.
4142

42-
The `profile` parameter is used to support [profiles].
43+
The `ext` parameter is used to support [extensions] and the `profile` parameter
44+
is used to support [profiles].
4345

4446
> Note: A media type parameter is an extra piece of information that can
4547
accompany a media type. For example, in the header
@@ -53,17 +55,24 @@ negotiation and versioning.
5355
### <a href="#content-negotiation-clients" id="content-negotiation-clients" class="headerlink"></a> Client Responsibilities
5456

5557
When processing a JSON:API response document, clients **MUST** ignore any
56-
parameters other than `profile` in the server's `Content-Type` header.
58+
parameters other than `ext` and `profile` parameters in the server's
59+
`Content-Type` header.
5760

5861
### <a href="#content-negotiation-servers" id="content-negotiation-servers" class="headerlink"></a> Server Responsibilities
5962

60-
Servers **MUST** respond with a `415 Unsupported Media Type` status code if
61-
a request specifies the header `Content-Type: application/vnd.api+json` with
62-
any media type parameters other than `profile`.
63+
If a request specifies the `Content-Type` header with the JSON:API media type,
64+
servers **MUST** respond with a `415 Unsupported Media Type` status code if that
65+
media type contains any media type parameters other than `ext` or `profile`.
66+
67+
If a request's `Accept` header contains an instance of the JSON:API media type,
68+
servers **MUST** respond with a `406 Not Acceptable` status code if all
69+
instances of that media type are modified with a media type parameter other
70+
than `ext` or `profile`.
6371

64-
Servers **MUST** respond with a `406 Not Acceptable` status code if a request's
65-
`Accept` header contains the JSON:API media type and all instances of that
66-
media type are modified with a media type parameter other than `profile`.
72+
If a request's `Accept` header contains an instance of the JSON:API media type,
73+
servers **MUST** respond with a `406 Not Acceptable` status code if every
74+
instance of that media type is modified by the `ext` parameter and each
75+
contains at least one unsupported extension URI.
6776

6877
## <a href="#document-structure" id="document-structure" class="headerlink"></a> Document Structure
6978

@@ -1900,6 +1909,43 @@ parameter from this specification, it **MUST** return `400 Bad Request`.
19001909
> \[a-z\], JSON:API is reserving the ability to standardize additional query
19011910
> parameters later without conflicting with existing implementations.
19021911
1912+
## <a href="#extensions" id="extensions" class="headerlink"></a> Extensions
1913+
1914+
JSON:API supports the use of "extensions" as a way to indicate additional
1915+
semantics that extend the basic semantics described in this specification.
1916+
1917+
An extension is a separate specification defining these extended semantics.
1918+
1919+
An exenstion **MAY** impose additional processing rules or further restrictions
1920+
and it **MAY** define new object members as described below.
1921+
1922+
An extension **MUST NOT** lessen or remove any processing rules, restrictions or
1923+
object member requirements defined in this specification or other extensions.
1924+
1925+
### <a href="#extension-members" id="extension-members" class="headerlink"></a> Extending Document Structure
1926+
1927+
An extension **MAY** define new members within the document structure defined by
1928+
this specification. The name of every new member introduced by an extension
1929+
**MUST** be prefixed with an extension namespace followed by a colon (`:`). The
1930+
namespace **MUST** be identical for every member introduced by a particular
1931+
extension.
1932+
1933+
Namespaces guarantee that extensions will never conflict with the current or
1934+
future versions of this specification.
1935+
1936+
In the following example, an extension requiring that each request document
1937+
contains a unique request ID has been applied. It uses the namespace `request`
1938+
and adds a top-level object member named `request:id`:
1939+
1940+
```
1941+
{
1942+
"request:id": "some-long-uuid",
1943+
"data": {
1944+
"type": "comments",
1945+
}
1946+
}
1947+
```
1948+
19031949
## <a href="#profiles" id="profiles" class="headerlink"></a> Profiles
19041950

19051951
JSON:API supports the use of "profiles" as a way to indicate additional
@@ -2386,6 +2432,7 @@ request as equivalent to one in which the square brackets were percent-encoded.
23862432
[link object]: #document-links-link-object
23872433
[link relation type]: #document-links-link-relation-type
23882434
[link parameters]: #document-links-link-parameters
2435+
[extensions]: #extensions
23892436
[profiles]: #profiles
23902437
[timestamps profile]: #profiles-timestamp-profile
23912438
[profile keywords]: #profile-keywords

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy