From 9e338b33e4d55e7be9bc6c0d1dbf5f7d6ffea853 Mon Sep 17 00:00:00 2001 From: Ethan Resnick Date: Tue, 26 May 2015 18:45:23 -0700 Subject: [PATCH 1/3] Rename Media Type Negotiation to Content Negotiation --- format/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format/index.md b/format/index.md index e488976a1..ead7a0d84 100644 --- a/format/index.md +++ b/format/index.md @@ -26,7 +26,7 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", interpreted as described in RFC 2119 [[RFC2119](http://tools.ietf.org/html/rfc2119)]. -## Media Type Negotiation +## Content Negotiation Clients **MUST** send all JSON API data in request documents with the header `Content-Type: application/vnd.api+json`. From bc47c0429beb06049ded3ea38757692d0e703f98 Mon Sep 17 00:00:00 2001 From: Ethan Resnick Date: Tue, 26 May 2015 19:05:37 -0700 Subject: [PATCH 2/3] Content Negotiation: clarify client & server obligations and consequences of violating them See rationale in #673. Also consolidates all the rules into the content negotiation section. --- format/index.md | 51 ++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/format/index.md b/format/index.md index ead7a0d84..ce41efbcc 100644 --- a/format/index.md +++ b/format/index.md @@ -28,26 +28,31 @@ interpreted as described in RFC 2119 ## Content Negotiation -Clients **MUST** send all JSON API data in request documents with -the header `Content-Type: application/vnd.api+json`. +Clients **MUST** send all JSON API data in request documents with the header +`Content-Type: application/vnd.api+json`, without any media type parameters. -Clients **MUST** ignore all parameters for the `application/vnd.api+json` -media type received in the `Content-Type` header of response documents. +If a client violates this requirement, servers **MUST** respond with a +`415 Unsupported Media Type` status code. + +Clients that include the JSON API media type in their `Accept` header, **MUST** +specify the media type there at least once without any media type parameters. + +If a client violates this requirement, and its `Accept` header doesn't contain +any other media types that the server can produce, the server **MUST** respond +with a `406 Not Acceptable` status code. + +Servers **MUST** send all JSON API data in response documents with the header +`Content-Type: application/vnd.api+json`, without any media type parameters. -Servers **MUST** send all JSON API data in response documents with -the header `Content-Type: application/vnd.api+json`. +Servers **MUST NOT** send responses with the `application/vnd.api+json` media +type if the client has not indicated, using its `Accept` header, that it can +understand this format. -Servers **MUST** return a `406 Not Acceptable` status code if the -`application/vnd.api+json` media type is modified by the `ext` parameter in -the `Accept` header of a request. Otherwise, servers **MUST** return a `415 -Unsupported Media Type` status code if the `application/vnd.api+json` media -type is modified by the `ext` parameter in the `Content-Type` header of a -request. Servers **MUST** ignore all other parameters for the -`application/vnd.api+json` media type in `Accept` and `Content-Type` -headers. +Clients **MUST** ignore any parameters for the `application/vnd.api+json` +media type received in the `Content-Type` header of response documents. -> Note: These requirements may allow future versions of this specification -to support an extension mechanism based upon the `ext` media type parameter. +> Note: These requirements exist to allow future versions of this specification +to use media type parameters for extension negotiation and versioning. ## Document Structure @@ -592,16 +597,6 @@ The following characters **MUST NOT** be used in member names: Data, including resources and relationships, can be fetched by sending a `GET` request to an endpoint. -Clients **MUST** indicate that they can accept the JSON API media type, per -the semantics of the HTTP `Accept` header. If present, this header value **MUST** -also include any media type extensions relevant to the request. Servers **MUST** -return a `406 Not Acceptable` status code if this header specifies an -unsupported media type. - -> Note: Servers may support multiple media types at any endpoint. For example, -a server may choose to support `text/html` in order to simplify viewing content -via a web browser. - Responses can be further refined with the optional features described below. ### Fetching Resources @@ -1071,10 +1066,6 @@ strategies. A server **MAY** allow resources of a given type to be created. It **MAY** also allow existing resources to be modified or deleted. -Any requests that contain content **MUST** include a `Content-Type` header -whose value is `application/vnd.api+json`. This header value **MUST** also -include media type extensions relevant to the request. - A request **MUST** completely succeed or fail (in a single "transaction"). No partial updates are allowed. From a6a051cd61a5f080ce0629a830ce94f178e8974e Mon Sep 17 00:00:00 2001 From: Ethan Resnick Date: Tue, 26 May 2015 19:05:45 -0700 Subject: [PATCH 3/3] Content Negotiation: add non-normative note about serving JSON API as json --- format/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/format/index.md b/format/index.md index ce41efbcc..b03c0c8c1 100644 --- a/format/index.md +++ b/format/index.md @@ -48,6 +48,13 @@ Servers **MUST NOT** send responses with the `application/vnd.api+json` media type if the client has not indicated, using its `Accept` header, that it can understand this format. +> Note: If a client's `Accept` header indicates that it accepts standard JSON +but not the JSON API media type, the server may choose serve it a JSON API +document identified as `application/json`. If the server does so, is not +considered to be sending "JSON API data" for the purposes of the requirement +above, but rather simple JSON data, and the client cannot rely on any of the +rules laid out in this specification. + Clients **MUST** ignore any parameters for the `application/vnd.api+json` media type received in the `Content-Type` header of response documents.