Skip to content

Commit b7c984b

Browse files
committed
Remove profile query parameters and make Accept the sole negotiation mechanism.
1 parent 9d36434 commit b7c984b

File tree

1 file changed

+28
-71
lines changed

1 file changed

+28
-71
lines changed

_format/1.1/index.md

Lines changed: 28 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ with any media type parameters other than `profile`.
6060

6161
Servers **MUST** respond with a `406 Not Acceptable` status code if a
6262
request's `Accept` header contains the JSON:API media type and the server is
63-
unable to respond with an acceptable representation.
63+
unable to respond with an acceptable representation. The response **MUST** contain
64+
an [error object] which lists the unsupported profile or profiles as
65+
its `source` and which has the following URI as (one of) its `type`s:
66+
67+
```
68+
https://jsonapi.org/errors/profile-not-supported
69+
```
6470

6571
> Note: These content negotiation requirements exist to allow future versions
6672
of this specification to add other media type parameters for extension
@@ -1906,32 +1912,38 @@ parameter **MUST** equal a space-separated (U+0020 SPACE, " ") list of profile U
19061912
> (U+0022 QUOTATION MARK, "\"") if it contains more than one URI.
19071913
19081914
A client **MAY** use the `profile` media type parameter in conjunction with the
1909-
JSON:API media type in an `Accept` header to _request_, but not _require_, that
1910-
the server apply one or more profiles to the response document. When such a
1911-
request is received, a server **SHOULD** attempt to apply the requested profiles
1912-
to its response.
1915+
JSON:API media type in an `Accept` header to request that the server apply one
1916+
or more profiles to the response document. When such a request is received, a
1917+
server **SHOULD** attempt to apply the requested profiles to its response.
19131918

19141919
For example, in the following request, the client asks that the server apply the
1915-
`http://example.com/last-modified` profile if it is able to.
1920+
`http://example.com/last-modified` profile if it is able to. If the server is
1921+
unable to apply the profile, it may send a response without the profile applied
1922+
because the client also specified the JSON:API media type without the `profile`
1923+
media type parameter.
19161924

19171925
```http
19181926
Accept: application/vnd.api+json;profile="http://example.com/last-modified", application/vnd.api+json
19191927
```
19201928

1921-
> Note: The second instance of the JSON:API media type in the example above is
1922-
required under the [client's content negotiation responsibilities](#content-negotiation-clients).
1923-
It is used to support old servers that don't understand the profile parameter.
1929+
In the following request, the client asks the server to process its request
1930+
using the `http://example.com/boolean-filters` profile. In this case, the client
1931+
does not specify the bare JSON:API media type because it would not like a
1932+
response unless the request was processed using the specified profile.
19241933

1925-
Servers **MAY** add profiles to a JSON:API document even if the client has not
1926-
requested them. The recipient of a document **MUST** ignore any profiles in that
1927-
document that it does not understand. The only exception to this is profiles
1928-
whose support is required using the `profile` query parameter, as described later.
1934+
```http
1935+
Accept: application/vnd.api+json;profile="http://example.com/boolean-filters"
1936+
```
1937+
1938+
Servers **MAY** process messages using one or more profiles even if the client has
1939+
not requested them. The recipient of a document to which an unknown profile
1940+
has been applied **MUST** ignore any document members that it does not understand.
19291941

19301942
#### <a href="#profiles-sending" id="profiles-sending" class="headerlink"></a> Sending Profiled Documents
19311943

19321944
Clients and servers **MUST** include the `profile` media type parameter in
19331945
conjunction with the JSON:API media type in a `Content-Type` header to indicate
1934-
that they have applied one or more profiles to a JSON:API document.
1946+
that they have applied one or more profiles to a JSON:API message.
19351947

19361948
Likewise, clients and servers applying profiles to a JSON:API document **MUST**
19371949
include a [top-level][top level] [`links` object][links] with a `profile` key,
@@ -1952,22 +1964,6 @@ apply profiles in subsequent interactions with the same API.
19521964
support JSON:API at all or that the client has failed to provide a required
19531965
profile.
19541966

1955-
### <a href="#profile-query-parameter" id="profile-query-parameter" class="headerlink"></a> `profile` Query Parameter
1956-
1957-
A client **MAY** use the `profile` query parameter to _require_ the server to
1958-
apply one or more profiles when processing the request. The value of the `profile`
1959-
query parameter **MUST** equal a URI-encoded whitespace-separated list of profile URIs.
1960-
1961-
If a server receives a request requiring the application of a profile or
1962-
combination of profiles that it can not apply, it **MUST** respond with a `400
1963-
Bad Request` status code. The response **MUST** contain an [error object] that
1964-
identifies the `profile` query parameter as the `source` and has the following
1965-
URI as (one of) its `type`s:
1966-
1967-
```
1968-
https://jsonapi.org/errors/profile-not-supported
1969-
```
1970-
19711967
> Note: When a client lists a profile in the `Accept` header, it's asking the
19721968
> server to compute its response as normal, but then send the response document
19731969
> with some extra information, as described in the requested profile. By
@@ -1976,47 +1972,6 @@ https://jsonapi.org/errors/profile-not-supported
19761972
> rules of the profile. This can fundamentally change the meaning of the
19771973
> server's response.
19781974
1979-
#### <a href="#profile-query-parameter-omitting" id="profile-query-parameter" class="headerlink"></a> Omitting the `profile` Query Parameter
1980-
1981-
Requiring the client to specify the `profile` query parameter would be
1982-
cumbersome. Accordingly, JSON:API defines a way that server's may infer its
1983-
value in many cases.
1984-
1985-
To do so, a server **MAY** define an internal mapping from query parameter names
1986-
to profile URIs. The profile URI for a query parameter name in this mapping
1987-
**MUST NOT** change over time.
1988-
1989-
> Note: the server may choose to map all query parameter names from the same
1990-
> [family][query parameter family] to one profile URI. Or, it may choose to map
1991-
> only specific query parameter names.
1992-
1993-
If a requested URL does not contain the `profile` query parameter and does
1994-
contain one or more query parameters in the server's internal mapping, the
1995-
server may act as though the request URL contained a `profile` query parameter
1996-
whose value was the URI-encoded space-separated list of each unique profile URI
1997-
found in the server's internal mapping for the query parameters in use on the
1998-
request.
1999-
2000-
For example, the server might support a profile that defines a meaning for the
2001-
values of the `page[cursor]` query parameter. Then, it could define its internal
2002-
param name to profile URI mapping like so:
2003-
2004-
```json
2005-
{ "page[cursor]": "https://example.com/pagination-profile" }
2006-
```
2007-
2008-
Accordingly, a request for:
2009-
2010-
```
2011-
https://example.com/?page[cursor]=xyz
2012-
```
2013-
2014-
would be interpreted by the server as:
2015-
2016-
```
2017-
https://example.com/?page[cursor]=xyz&profile=https://example.com/pagination-profile
2018-
```
2019-
20201975

20211976
### <a href="#profile-keywords" id="profile-keywords" class="headerlink"></a> Profile Keywords
20221977

@@ -2323,6 +2278,8 @@ An error object **MAY** have the following members:
23232278
exists; if it doesn't, the client **SHOULD** simply ignore the pointer.
23242279
* `parameter`: a string indicating which URI query parameter caused
23252280
the error.
2281+
* `profiles`: an array of the requested profile URIs that the server was not
2282+
able to support.
23262283
* `meta`: a [meta object][meta] containing non-standard meta-information about the
23272284
error.
23282285

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