This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Affordances #2
Open
kylef
wants to merge
1
commit into
master
Choose a base branch
from
kylef/root-transitions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Affordances #2
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
RFC: XXXX | ||
Author: Kyle Fuller | ||
Status: Draft | ||
Created: 2015-09-21 | ||
Last Modified: 2015-09-21 | ||
--- | ||
|
||
# API Blueprint RFC XXXX: Affordances | ||
|
||
## Table of Contents | ||
|
||
- [Abstract](#abstract) | ||
- [Rationale](#rationale) | ||
- [Example](#example) | ||
|
||
## Abstract | ||
|
||
This RFC proposes that you can define affordances (link relations) that an API | ||
resource or action provides. | ||
|
||
## Rationale | ||
|
||
This RFC proposes adding an `Affordances` section into API Blueprint that | ||
sits under a resource or action providing the affodances that it provides. | ||
|
||
### Example | ||
|
||
To describe affordances from a `Question` resource to two other resources, we | ||
can describe them within the affordances section as follows: | ||
|
||
```apib | ||
## Question [/question/{id}] | ||
|
||
+ Parameters | ||
+ id: 1 | ||
|
||
+ Affordances | ||
+ `create_comment` (Comments[create]) | ||
+ `author` (User) | ||
``` | ||
|
||
Where `Comment` is a resource named `Comment` that has a `create` relation | ||
identifier and User is another resource. | ||
|
||
```apib | ||
## Comments [/comments] | ||
### Create Comment [PUT] | ||
+ Relation: create | ||
|
||
## User [/user/{username}] | ||
|
||
+ Parameters | ||
+ username | ||
``` | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm missing something because it's not clear to me at all what this is solving, either by the example or the description above. I understand that the goal is to allow a client to understand link relationships between resources or arbitrary actions, but what does the above actually get me as a client? I'm wondering:
create_comment
andauthor
strings? Are they just an identifier or would an implementor be expected to use these to provide something like e.g.my_question.create_comment(params)
? I think any update to the spec should describe why these names exist.author_id
or something that would be taken as a parameter into theauthor
relationship when calling/user/{username}
. Where is the link betweenmy_question.author_id
and/user/{username}
defined here? What can I actually do without that link? I know an author may exist and that the author may have a URL, but really nothing else.create_comment
would require some kind ofquestion_id
attribute and you'd want to linkmy_question.id
to it, but how with the information provided?user
example, how do you link it to any specific action on the user? How do I know whether to use GET or PUT or something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielgtaylor AFAIK, for example, this is trying to define the
_links
keyword in HAL. But that raises a lot more questions for me.Let's take the following example on the HAL spec,
As daniel said above, we really don't know the relations between the
Question
resource andUser
resource. Similarly withComment
resource. We can usetemplated
as shown above, but I think some people might prefer the actual values instead of templates. Also, If you look at the above example, how do we define something like theea:admin
?There has been a bit of work done by @zdne on Resource Blueprint which tries to solve these issues and talks about state machines.
In my opinion, the introduction of
Affordances
to API Blueprint as it is in this document is an half-attempt at the resource blueprint which I don't think does anything good for us. It might actually hamper the development in the future.