@@ -60,7 +60,13 @@ with any media type parameters other than `profile`.
60
60
61
61
Servers ** MUST** respond with a ` 406 Not Acceptable ` status code if a
62
62
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
+ ```
64
70
65
71
> Note: These content negotiation requirements exist to allow future versions
66
72
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
1906
1912
> (U+0022 QUOTATION MARK, "\" ") if it contains more than one URI.
1907
1913
1908
1914
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.
1913
1918
1914
1919
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.
1916
1924
1917
1925
``` http
1918
1926
Accept: application/vnd.api+json;profile="http://example.com/last-modified", application/vnd.api+json
1919
1927
```
1920
1928
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.
1924
1933
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.
1929
1941
1930
1942
#### <a href =" #profiles-sending " id =" profiles-sending " class =" headerlink " ></a > Sending Profiled Documents
1931
1943
1932
1944
Clients and servers ** MUST** include the ` profile ` media type parameter in
1933
1945
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 .
1935
1947
1936
1948
Likewise, clients and servers applying profiles to a JSON: API document ** MUST**
1937
1949
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.
1952
1964
support JSON: API at all or that the client has failed to provide a required
1953
1965
profile.
1954
1966
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
-
1971
1967
> Note: When a client lists a profile in the ` Accept ` header, it's asking the
1972
1968
> server to compute its response as normal, but then send the response document
1973
1969
> with some extra information, as described in the requested profile. By
@@ -1976,47 +1972,6 @@ https://jsonapi.org/errors/profile-not-supported
1976
1972
> rules of the profile. This can fundamentally change the meaning of the
1977
1973
> server's response.
1978
1974
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
-
2020
1975
2021
1976
### <a href =" #profile-keywords " id =" profile-keywords " class =" headerlink " ></a > Profile Keywords
2022
1977
@@ -2323,6 +2278,8 @@ An error object **MAY** have the following members:
2323
2278
exists; if it doesn't, the client ** SHOULD** simply ignore the pointer.
2324
2279
* ` parameter ` : a string indicating which URI query parameter caused
2325
2280
the error.
2281
+ * ` profiles ` : an array of the requested profile URIs that the server was not
2282
+ able to support.
2326
2283
* ` meta ` : a [ meta object] [ meta ] containing non-standard meta-information about the
2327
2284
error.
2328
2285
0 commit comments