Skip to content

Proposal: discoverable actions #590

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ interchange format itself.

### How to discover resource possible actions? <a href="#how-to-discover-resource-possible-actions" id="how-to-discover-resource-possible-actions" class="headerlink"></a>

You should use the OPTIONS HTTP method to discover what can be done with a
If resource-level member `"actions"` is not provided by the server,
you should use the OPTIONS HTTP method to discover what can be done with a
particular resource. The semantics of the methods returned by OPTIONS is defined
by the JSON API standard.

Expand Down
47 changes: 47 additions & 0 deletions format/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ In addition, a resource object **MAY** contain any of these top-level members:
relationships (described below).
* `"meta"`: non-standard meta-information about a resource that can not be
represented as an attribute or relationship.
* `"actions"`: a list of actions, which the client can perform on
the given resource.

Here's how an article (i.e. a resource of type "articles") might appear in a document:

Expand Down Expand Up @@ -378,6 +380,51 @@ The `comments` relationship is simpler: it just provides a related resource URL
to fetch the comments. The URL can therefore be specified directly as the
attribute value.

#### Actions <a href="#document-structure-resource-actions" id="document-structure-resource-actions" class="headerlink"></a>

Member `"actions"` contains list of actions which the client can perform
on the given resource. If provided, it **MUST** account for authentication
and authorization status of the current client and for other pertinent
circumstances in order to provide a list of actions which the given client
is actually allowed to perform on the given resource at the moment when
the response is being built by the server.

Its value **MUST** be an array of action objects, each including at least
the following members:

* `"label"`: a string, identifying the given action,
* `"href"`: an endpoint for performing the given action.

In addition, each action object **MAY** include the following members:

* `"method"`: contains name of HTTP method corresponding to the given action.
* `"meta"`: contains non-standard meta-information about the action.

For example,

```
// ...
{
"type": "articles",
"id": "1",
"title": "Rails is Omakase",
"actions": [{
"label": "FETCH",
"href": "http://example.com/articles/1",
"method": "GET"
},{
"label": "DISCARD",
"href": "http://example.com/articles/1",
"method": "DELETE"
},{
"label": "PUBLISH",
"href": "http://example.com/articles/1/publish",
"method": "POST"
}]
}
// ...
```

### Compound Documents <a href="#document-structure-compound-documents" id="document-structure-compound-documents" class="headerlink"></a>

To reduce the number of HTTP requests, servers **MAY** allow responses that
Expand Down
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