Skip to content

Proposal for v1.0 rc2 #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Feb 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8db6729
V1.0 RC2 WIP
dgeb Dec 24, 2014
e19b2a3
V1.0 RC2 WIP, continued
dgeb Jan 7, 2015
2837f8a
minor edits
Jan 9, 2015
613996e
Introduce `Extending` section.
dgeb Feb 2, 2015
1cd710f
Clarify requirements for meta-information.
dgeb Feb 2, 2015
a42b61d
Introduce pagination.
dgeb Feb 2, 2015
936e1f8
Require dasherized naming of attributes and associations.
dgeb Feb 2, 2015
4d98838
Introduce note about (lack of) inflection rules.
dgeb Feb 2, 2015
6973ee9
Remove HTTP Caching section.
dgeb Feb 2, 2015
dca96b9
Refine Errors section.
dgeb Feb 2, 2015
ea1431e
Fix line breaks and minor typos.
dgeb Feb 2, 2015
25606b9
Clarify requirements around client-generated IDs
dgeb Feb 2, 2015
6133ac1
Correct column wrapping
dgeb Feb 2, 2015
ee12f88
Add note clarifying that foreign keys aren’t attributes.
dgeb Feb 3, 2015
7912e42
Reword note about foreign key relationships
dgeb Feb 3, 2015
e8f0401
Remove "example" divs.
dgeb Feb 3, 2015
ea35fff
Clarify definition of compound documents.
dgeb Feb 3, 2015
1ff22df
Add Recommendations and remove Overview from navigation
dgeb Feb 4, 2015
59b2ee3
Clarify that related resource URLs should remain constant
dgeb Feb 4, 2015
1e23b89
Translate URL rules into "recommendations"
dgeb Feb 4, 2015
e60ccec
Clarify meta information with example.
dgeb Feb 4, 2015
1307997
Clarify top-level self link definition
dgeb Feb 4, 2015
91876ae
Re-introduce filtering strategy as a recommendation.
dgeb Feb 4, 2015
061a8f4
Clarify sorting section
dgeb Feb 4, 2015
825d466
Fix column wrapping
dgeb Feb 4, 2015
8dac29a
Clarify media type header
dgeb Feb 4, 2015
b4d6873
Clarify note about `type` requirement.
dgeb Feb 4, 2015
90d898a
Revisit relationship updating sections.
dgeb Feb 4, 2015
c2a325a
Rename extending -> extensions
dgeb Feb 4, 2015
2ceafea
Move Deleting Resources below Updating Relationships
dgeb Feb 5, 2015
35ee064
Fix typo - remove extra word
dgeb Feb 5, 2015
622a755
Further clarification of updating resources and relationships.
dgeb Feb 5, 2015
43eec5c
Rework extensions page.
dgeb Feb 5, 2015
edd2c10
Move bulk extension page
dgeb Feb 5, 2015
21e9bad
Move patch extension page
dgeb Feb 5, 2015
8af5e05
Clarify resource creation language.
dgeb Feb 5, 2015
2293aa1
Clarify names and media types of official extensions.
dgeb Feb 5, 2015
043adb0
Clarify primary data reqs for to-many relationship updates.
dgeb Feb 5, 2015
c7fa63a
Completely rework the Bulk extension.
dgeb Feb 5, 2015
4a2c55a
Completely rework the Patch extension.
dgeb Feb 6, 2015
b2649b1
Clarify several responses.
dgeb Feb 6, 2015
25b5823
Refactor Patch extension for consistency with base spec.
dgeb Feb 6, 2015
eae7512
Rework Overview page and compound document example.
dgeb Feb 6, 2015
0dbb804
Correct missing comma.
dgeb Feb 7, 2015
d9729e4
Move field name requirements to recommendations.
dgeb Feb 8, 2015
5865f15
Rename 'post' as 'article'
miguelsan Feb 9, 2015
ddb2fdb
Relationships SHALL NOT be named "self"
miguelsan Feb 9, 2015
4ee9bad
Clarify that the *value* of `type` can be singular or plural.
dgeb Feb 10, 2015
0138885
should -> **SHOULD**
dgeb Feb 10, 2015
b35d887
Correct link wrapping
dgeb Feb 17, 2015
2924a6e
Fix EOL spacing.
dgeb Feb 17, 2015
87d2828
Clarify `data` / `errors` top-level members.
dgeb Feb 17, 2015
eece87f
Further define "sort fields" and their usage.
dgeb Feb 17, 2015
2fa6265
Clarify that `type` is not required for empty relationships.
dgeb Feb 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pygments: false
port: 9876

navigation:
- title: Overview
url: /
- title: Format
url: /format/
- title: Extending
url: /extending/
- title: Extensions
url: /extensions/
- title: Recommendations
url: /recommendations/
- title: Examples
url: /examples/
- title: FAQ
Expand Down
74 changes: 0 additions & 74 deletions extending/index.md

This file was deleted.

105 changes: 105 additions & 0 deletions extensions/bulk/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
layout: page
title: "Bulk Extension"
---

## Introduction <a href="#introduction" id="introduction" class="headerlink"></a>

The "Bulk extension" is an [official
extension](/extensions/#official-extensions) of the JSON API specification.
It provides support for performing multiple operations in a request,
including adding and removing multiple resources.

Servers **SHOULD** indicate support for the JSON API media type's Bulk
extension by including the header `Content-Type: application/vnd.api+json;
ext=bulk` in every response.

Clients **MAY** request the JSON API media type's Bulk extension by
specifying the header `Accept: application/vnd.api+json; ext=bulk`. Servers
that do not support the Bulk extension **MUST** return a `415 Unsupported
Media Type` status code.

## Bulk Operations <a href="#bulk-operations" id="bulk-operations" class="headerlink"></a>

[As mentioned in the base specification](/format/#crud), a request **MUST**
completely succeed or fail (in a single "transaction").

Therefore, any request that involves multiple operations **MUST** only
succeed if all operations are performed successfully. The state of the
server **MUST NOT** be changed by a request if any individual operation fails.

## Creating Multiple Resources <a href="#creating-multiple-resources" id="creating-multiple-resources" class="headerlink"></a>

Multiple resources can be created by sending a `POST` request to a URL that
represents a collection of resources. The request **MUST** include an array
of resource objects as primary data. Each resource object **MUST** contain
at least a `type` member.

For instance, multiple photos might be created with the following request:

```text
POST /photos
Content-Type: application/vnd.api+json; ext=bulk
Accept: application/vnd.api+json; ext=bulk

{
"data": [{
"type": "photos",
"title": "Ember Hamster",
"src": "http://example.com/images/productivity.png"
}, {
"type": "photos",
"title": "Mustaches on a Stick",
"src": "http://example.com/images/mustaches.png"
}]
}
```


## Updating Multiple Resources <a href="#updating-multiple-resources" id="updating-multiple-resources" class="headerlink"></a>

Multiple resources can be updated by sending a `PUT` request to a URL that
represents a collection of resources to which they all belong. The request
**MUST** include an array of resource objects as primary data. Each resource
object **MUST** contain at least `type` and `id` members.

For example:

```text
PUT /articles
Content-Type: application/vnd.api+json; ext=bulk
Accept: application/vnd.api+json; ext=bulk

{
"data": [{
"type": "articles",
"id": "1",
"title": "To TDD or Not"
}, {
"type": "articles",
"id": "2",
"title": "LOL Engineering"
}]
}
```

## Deleting Multiple Resources <a href="#deleting-multiple-resources" id="deleting-multiple-resources" class="headerlink"></a>

Multiple resources can be deleted by sending a `DELETE` request to a URL that
represents a collection of resources to which they all belong.

The body of the request **MUST** contain a `data` member whose value is an
object that contains `type` and `ids`, or an array of objects that each
contain a `type` and `id`.

For example:

```text
DELETE /articles
Content-Type: application/vnd.api+json; ext=bulk
Accept: application/vnd.api+json; ext=bulk

{
"data": { "type": "articles", "ids": ["1", "2"] }
}
```
111 changes: 111 additions & 0 deletions extensions/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
layout: page
title: Extensions
---

JSON API can be extended in several ways:

* The `ext` media type parameter can be used to declare and request support for
extensions, [as discussed in the base specification](/format#extending).
Official and custom extensions to the specification are discussed below.

* Meta information can be included in several places in a document,
[as discussed in the base specification](/format/#document-structure-meta).

* A profile can be specified in the top-level `meta` object, as discussed below.

## Official Extensions <a href="#official-extensions" id="official-extensions" class="headerlink"></a>

JSON API currently supports the following official extensions:

* [Bulk extension](/extensions/bulk/) - provides support for performing multiple
operations in a request, including adding and removing multiple resources.
The Bulk extension is referenced with the media type parameter `ext=bulk`.

* [Patch extension](/extensions/patch/) - provides support for modification of resources
with the HTTP PATCH method [[RFC5789](http://tools.ietf.org/html/rfc5789)]
and the JSON Patch format [[RFC6902](http://tools.ietf.org/html/rfc6902)].
The Patch extension is referenced with the media type parameter `ext=patch`.

## Custom Extensions <a href="#custom-extensions" id="custom-extensions" class="headerlink"></a>

The JSON API media type can be extended for your organization by writing your
own custom extension. This extension should also be specified using the `ext`
media type parameter.

It is strongly recommended that custom extensions be prefixed with a unique
identifier for your organization to avoid namespace collision. For example,
`my-org/embedded-resources`.

## Profiles <a href="#profiles" id="profiles" class="headerlink"></a>

JSON API can be extended with the profile link relation, defined in [RFC
6906](http://tools.ietf.org/html/rfc6906). See also [this blog post by Mark
Nottingham](http://www.mnot.net/blog/2012/04/17/profiles).

According to the RFC, profiles are:

```text
defined not to alter the semantics of the resource representation itself, but
to allow clients to learn about additional semantics (constraints, conventions,
extensions) that are associated with the resource representation, in addition
to those defined by the media type and possibly other mechanisms.
```

A profile link **SHOULD** be specified in the top-level `meta` object, keyed
by `profile`.

For example, let's say that you want your API to support a offset / limit
based pagination scheme that you'd like to describe to your users. You would
make some sort of profile page on your site, such as
`http://api.example.com/profile`, and then include it in the `meta` key of
your responses:

```text
GET http://api.example.com/posts

{
"meta": {
"profile": "http://api.example.com/profile",
"page": {
"offset": 1,
"limit": 10,
"total": 35
}
},
"links": {
"self": "http://api.example.com/posts",
"next": "http://api.example.com/posts?page[offset]=11",
"last": "http://api.example.com/posts?page[offset]=31"
},
"data": [
// First 10 posts
]
}
```

That document will de-reference to explain your link relations:

```text
GET http://api.example.com/profile HTTP/1.1
```

```text
HTTP/1.1 200 OK
Content-Type: text/plain

The Example.com API Profile
===========================

The Example.com API uses simple offset and limit-based pagination. Paginated
resources will include the standard JSON API `next`, `prev`, `first`, and
`last` pagination links in the top-level `links` object when they are not
`null`.

In addition, a `page` member will be added to the top-level `meta` object
that includes the following members: `offset`, `limit`, and `total`. The
`total` member represents the total count of resources in the paginated
collection. You can use the `offset` and `limit` members to construct your
own custom pagination links with the query parameters `page[offset]` and
`page[limit]`.
```
Loading
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