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
Resource Namespace #13
Conversation
- `href` (Href, required) - The URI template for this transition. | ||
- `parameters` (Href Variables) - A hash of input parameters for this transition. | ||
- `attributes` (Data Structure) - Input attributes for this transition. | ||
- `transactions` (array[Transaction]) - Array of transaction examples. |
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.
It may be helpful to address issue #12 first before committing to this, as you may be able to do what you originally had planned, which was to put href
, parameters
, and attributes
in the attributes
section, along with content
being defined as an array of Transaction elements. Would that simplify this any?
@kylef @danielgtaylor @smizell: I have updated PR. I believe it now captures all the information I wanted (to be able to convert API Blueprint (resource subtree) AST into it. I am up for any simplification or clarification! Please let me know. Also see my TODO items on PR description and let me know what you think. Thanks! _Lets' finish this one! _ 🍨 |
|
||
- Elements | ||
- (HTTP Request Message) | ||
- (HTTP Response Message) |
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.
Do these need required
on them in some way?
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.
As I was pressing comment, I noticed fixed
. I guess this covers it?
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.
As I was pressing comment, I noticed fixed. I guess this covers it?
Yup. That "fixes" the content of the property.
Thoughts on your questions
I personally think dashes or more readable, but I think camelCase is probably a safer bet with the JavaScript/JSON world, so I would vote camelCase.
Feels like you have it right with content of transitions being transactions with
I could have read this question incorrectly, but it seems like the content of an HTTP message could either be a string (where the content-type defines how it should be parsed) or an element (where the content of that element dictates how it is handled). This means the content of {
"element": "json",
"content": {
"foo": "bar"
}
} Then you could have multipart elements that combine these elements or whatever. Now, you don't need to define those elements here and now, but it could be an interesting pattern to think through.
I think you can use class however you see fit. Makes for creating multi-purpose elements IMO. What would the tradeoffs be for this versus defining a new element? Thoughts of my ownFirst impressions. Thought it might be helpful to you to get that perspective.
My first reaction to really digging in here is that this was hard to understand for me. I understood what a resource was (I think). Transitions with transactions, though, did not map well in my head. When working with a resource, I usually think of the actions you can take on it. I also think of how it relates to other resources. These seem to both be grouped under the same idea of "Transitions." I don't want to hold this up, because it sounds like this will work for you, though something feels off to me. I can't quite nail down what that is or what a solution would be, so I'll think on it some more. I think the thing that is throwing me off most is href templates and normal hrefs in several elements. |
More thinking out loud here if that's ok. It seems like you have these elements, which mostly mimic the current API Blueprint.
['resource', { 'title': 'My resource' }, { 'href': '/asdf' }, [
['action', { 'title': 'Retrieve' }, { 'method': 'GET'}, null],
['relation', { 'title': 'Retrieve related resource'}, { 'href': '/jkl', 'method': 'GET' }, null]
]] This would mean there are these constraints to define:
Not saying you have to do this, but just saying how I categorize these in my head. I suppose this is simply breaking apart the idea of a "transition," but in doing so you surface the constraints I listed above. Otherwise you have to introspect things and figure out what constraints to apply and when to apply them. |
|
||
- `element`: `http-response` (string, fixed) | ||
- `attributes` | ||
- `statusCode` (number) - HTTP response status code |
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.
Do you think it is worth trying to capture responses that have multiple status codes, i.e. HTTP 100 Continue? Urban Airship disabled the feature due to problems it was causing, but I know for a fact that Amazon S3 supports it and it's a commonly used pattern for APIs that handle large message bodies.
On the one hand I feel like it's an implementation detail not relevant to the higher level final request/response pair, on the other it seems important to include in the request/response examples so that implementers are aware of the feature.
Sample response: http://www.jmarshall.com/easy/http/#http1.1c4
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.
That is a very interesting point @danielgtaylor ! I think I would leave it as is for now. If needed later I think we can allow either two responses and or add an array like statusCodes
.
0c042cd
to
3f49015
Compare
@kylef @smizell @danielgtaylor This is ready to be reviewed and merged. Let me know your thoughts! Note I went through most of the comments @smizell had here #13 (comment) and here #13 (comment) with Stephen. I hope I've addressed most of them. Regarding
Which of those In any case I am open to comments and suggestions! Thanks! |
}, | ||
"content": [ | ||
{ | ||
"element": "data-structure" |
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.
Camel casing?
2dd0075
to
feca601
Compare
|
||
- `parameters` (Href Variables) - Input parameters. | ||
|
||
Definition of any input URI path segments or URI query parameters for this transition. |
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.
Just thought of this. Would it help to clarify that if the href
is not present, these parameters SHOULD be used for the parent resource href
?
cb05665
to
83243cd
Compare
a693c93
to
288a0d0
Compare
@smizell addressed & squashed |
- `attributes` (object) | ||
- `contentType` (string) - Optional media type of the asset | ||
- `href` (Href) - Link to the asset | ||
- `content` (string) - A textual representation of the asset |
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.
Missing trailing full stop on a few of the properties such as the above. Only pointing out because some have a full-stop and it's inconsistent. But not really a blocking problem.
statusCode
(number) - HTTP response status code.
👍 from me. |
@zdne I like what you did with the |
If not set, the parent `resource` element `href` attribute SHOULD be | ||
used to resolve the target URI of the transition. | ||
|
||
- `parameters` (Href Variables) - Input parameters. |
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.
Why is this called parameters
but the one under resource
is called hrefVariables
?
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.
Semantically, the two are different.
Let's start with transition: Any transition may have input properties (refer to representor charter) those properties are either parameters or attributes. In addition to that – since a templated href can be provided – you can have some other variables in there.
Consider resource "friends" which is an array of friend resources every user have. Its templated href may be something like /user/{username}/friends
. Now if you are "sitting" on the Friends
resource you can perhaps take a transition list
that lists all the friends. Let's say the transition parameter is limit
to limit maximum number of friend resources returned. The full templated href would look like /user/{username}/friends{?limit}
.
You can see that username
and limit
are input parameters of the transition. In a resource context, those are not necessarily parameters.
Now, strictly speaking, the parameter of the list
transition is really just a limit
(not username
) because in a hypermedia system the value of username
should be already resolved by now.
So in theory the transition should have both hrefVariables
and parameters
. I didn't want to overcomplicate things introducing both here but I've wanted to at least acknowledge this fact.
Does this make sense?
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.
Yes. I guess we should wait and see for adding the parameters
at resource level.
This namespaces extend MSON namespace with elements necessary to build REST Resource description / definition object model.
To be clarified:
Use dash versus camelCase in element types names (
data-structure
vsdataStructure
),A: Use camelCase
Transition: Is content of Transition element an array of Transaction examples elements or Transition's
parameters
andattributes
?A:
parmaters
andattributes
to stay under attributes property, Transactions examples are the contentHTTP Message: Are assets with a message content or attributes (think about JSON, JSON Schema, binary blobs being sent etc)?
Note: in a future I can see arbitrary assets to be associated with more elements (resource, data structure etc).
A: Asset as well as data structure are part of the element
content
Asset: Is using
class
inmeta
to distinguish classification of an asset like this correct?A: It is OK as it is.
NOTE: This namespace defines elements necessary for definition / description of a REST resource – not necessarily for capturing a resource representational message.
This PR supersedes #8 and #11 .