Skip to content

Missing Spec Tests #21

Closed
Closed
@jaredcnance

Description

@jaredcnance

Fetching Data

  • Request for an empty collection should return an empty collection

A server MUST respond to a successful request to fetch a resource collection with an array of resource objects or an empty array ([]) as the response document’s primary data.

HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "links": {
    "self": "http://example.com/articles"
  },
  "data": []
}
  • Relationship requests should return null if the relationship has not been set
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "links": {
    "self": "http://example.com/articles/1/author"
  },
  "data": null
}
  • Server MUST return 404 Not Found when processing a request to fetch a relationship link URL that does not exist.

Note: This can happen when the parent resource of the relationship does not exist. For example, when /articles/1 does not exist, request to /articles/1/relationships/tags returns 404 Not Found.

  • Inclusion of multiple relationships:

The value of the include parameter MUST be a comma-separated (U+002C COMMA, “,”) list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, “.”) list of relationship names.

  • 400 response if relationship does not exist

If a server is unable to identify a relationship path or does not support inclusion of resources from a path, it MUST respond with 400 Bad Request.

  • Pagination links MUST appear in the links object that corresponds to a collection

The following keys MUST be used for pagination links:

  • first: the first page of data
  • last: the last page of data
  • prev: the previous page of data
  • next: the next page of data

Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable.

Creating, Updating and Deleting Resources

  • 403 Forbidden for client generated Ids

A server MUST return 403 Forbidden in response to an unsupported request to create a resource with a client-generated ID.

  • Creation: The response SHOULD include a Location header identifying the location of the newly created resource.

  • Creation: The response MUST also include a document that contains the primary resource created.

  • 409:

A server MUST return 409 Conflict when processing a POST request in which the resource object’s type is not among the type(s) that constitute the collection represented by the endpoint.

  • 404:

A server MUST return 404 Not Found when processing a request that references a related resource that does not exist.

Updating Relationships

  • Can update to-many relationships through relationship link
  • Can update to-one relationships through relationship link

A server MUST respond to PATCH, POST, and DELETE requests to a URL from a to-many relationship link as described below.

PATCH /articles/1/relationships/tags HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": [
    { "type": "tags", "id": "2" },
    { "type": "tags", "id": "3" }
  ]
}

Deleting

  • 404

A server SHOULD return a 404 Not Found status code if a deletion request fails due to the resource not existing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions