-
Notifications
You must be signed in to change notification settings - Fork 890
reserve attributes in top level of resource object #588
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
Conversation
4b8ecce
to
05f7e49
Compare
Whoa, wait. Why are complex attributes being removed altogether? They're a widely-requested feature. IMO the "subattributes" within complex attributes should absolutely not be enclosed in a further As for what member names should be reserved inside complex attributes, I've always been of the opinion that it would be best to reserve just Other than that, I'm fully on board with the main idea here, i.e. introducing |
@bintoro Just trying to work through the implications of this adjustment, please consider this a working draft. Given that "complex attributes" reserve all the same top level keys as resource objects, I think they should be subject to the same constraints. The discontinuity created by not using the I would rather discard this idea and accept the risks outlined in #573 if we all can't agree on this point. |
Hmm. I don't think we have to regard Think of it this way: all attributes appear in a single |
@bintoro, interesting! And the rule to form paths to those links, would it be to drop |
@hhware Yes. To put it another way, an attribute can be any valid JSON value, as promised by the spec, as long as any nested objects reserve Introducing
|
@bintoro, pretty smart! I agree, it could be useful to have
I only suggested to reserve |
If complex attributes are explicitly for plain JSON and not for addressable resources it feels pretty strange to me that they would include references to addressable resources via links. That said, given that I don't personally have a use-case for complex attributes (and if I did, I doubt I'd use links within them), I suppose I can look the other way. @bintoro, would you mind taking a stab at what the revised definition of a complex attribute would be so I can re-introduce it in the document? I'd really like to hear from @dgeb and @steveklabnik on this. I think the main point of the PR is really important but I'm not going to merge without broad consensus. |
represent "[attributes]" and may contain any valid JSON value. | ||
A resource object **MAY** contain an "[attributes]" object. If included, this | ||
object **MUST** reserve the `id` member at it's top level, but can otherwise | ||
contain any valid JSON value. |
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 believe that type
MUST be reserved as well as id
. Otherwise, requests to sort or filter by type
would be ambiguous.
Also: s/it's/its/
Is there any reason that links for complex attributes can't be represented in the top level |
This would be possible using URI templates, which could account for arrays. However, URI templates are no longer explicitly supported in the spec. |
Even though I'm 👍 on merging this soon to allow implementations to adapt before May 21. I would like to open a separate milestoned issue to discuss defining complex attributes and reserving members within them. @tkellen could you please update the home page example as well? |
626b5f9
to
9588740
Compare
Updated. I'm prepared to merge and re-open the complex attributes issue assuming you're good with the current changes. |
There is clearly a use case for outbound links from complex attributes (e.g., #238). Whether complex attributes should be addressable has been discussed multiple times (e.g., #383), and the majority opinion seems to be against. Doing so would essentially make them embedded resource objects, which goes against the linkage paradigm.
This was discussed comprehensively in #383 and decided against. (It was actually about putting them at the resource-object level, but the idea is the same.)
But I'm not sure what needs to be done here. Does the definition of complex attributes have to change in any way apart from what members are reserved? I'm still puzzled as to why the section is being removed. PR #504 is aimed at improving the explanation on complex attributes, so any amendments to that section can be implemented there. |
Sorry for not being up to speed on that particular conversation @bintoro, I have obviously not considered complex attributes carefully enough (reasons stated above). I'll re-read those issues so I have the proper context. Assuming you're fine with rebasing #504 off of this, would you feel comfortable having me merge this as is? |
Yeah, it's fine to recreate the removed section in #504. In fact, the definition of complex attributes is not even strictly necessary; it only exists to elaborate on the topic because questions about it have been raised repeatedly. JSON objects as attributes have always been allowed regardless. However, there are a few other things I would like to discuss. Apologies for raising these issues at such a late stage, but I've been occupied with other stuff.
|
I suggest to add a clear statement that the following resource members are addressable via namespace
This will
|
No worries @bintoro. I was originally thinking I see your point about the difference between attributes and the attributes object. I'll push a fix for that shortly. |
f8836e5
to
e9140b5
Compare
That was my first reaction too when @dgeb mentioned that they'd share a namespace. Now I'm wondering though if having them be separate namespaces would also cause problems, like the ambiguity with I see a couple solutions:
|
Doesn't a collection of resources that can be sorted/filtered always contain resource objects of the same resource type? It's not defined in the spec, but this is how I understand it - so IMHO sorting/filtering by (resource) type doesn't make sense here and only |
This may be beating a dead horse, but what was it about reserved-key prefixes that caused them not to catch on? I don't remember seeing any concrete objections apart from underscore prefixes being considered ugly, which I agree with. But there are other characters. It seems to me we're going through a whole lot of trouble here to solve issues that wouldn't exist to begin with if we just used |
Perhaps we could provide a different syntax to refer to resource-level member names? E.g., immediate children of resource can be referenced by enclosing it in
@ziege, no, heterogeneous collections are also supported |
In the current spec, attributes and links already share a namespace (see http://jsonapi.org/format/#document-structure-links). Although it's not explicitly stated, this namespace is also shared by I don't think this should change if we accept this PR. I am unclear on the value proposition of allowing an attribute named Instead, I see the value proposition of the Let's say that an extension introduces the I hope this example illustrates the (somewhat subtle) advantages of the |
@dgeb, if you are referring to my comment, I only suggested to clearly state that they all share the same namespace |
0052dbf
to
c1b320f
Compare
This walls off implementation specific keys for resource objects under the namespace `attributes`. With this adjustment, all top level members of resource objects are reserved by JSON-API. This greatly improves our ability make additive changes that fit with the current style of the specification in a post 1.0 world. This proposal was met with wide acceptance by implementors in both #573 and #588.
c1b320f
to
60561b5
Compare
This walls off implementation specific keys for resource objects under the namespace `attributes`. With this adjustment, all top level members of resource objects are reserved by JSON-API. This greatly improves our ability make additive changes that fit with the current style of the specification in a post 1.0 world. This proposal was met with wide acceptance by implementors in both #573 and #588.
This walls off implementation specific keys for resource objects under the namespace `attributes`. With this adjustment, all top level members of resource objects are reserved by JSON-API. This greatly improves our ability make additive changes that fit with the current style of the specification in a post 1.0 world. This proposal was met with wide acceptance by implementors in both #573 and #588.
60561b5
to
9cdfd4c
Compare
reserve attributes in top level of resource object
@bintoro Amidst all this we lost the section on complex attributes, and the members reserved in them. Would you be up for making a PR (or rebasing from your old ones/old text) to bring this back? |
@ethanresnick Sure. But what to reserve? I'm inclined to reserve as few keys as possible. Do you foresee a need for anything besides "relationships"? |
@bintoro Definitely |
@ethanresnick Could you elaborate on this, please? I mean, how does reserving Reserving |
Sure. I said that because, when we were initially discussing the introduction of |
@ethanresnick Interestingly I have the exact opposite view 😄 The less similarities there are between complex attributes and resource objects, the less opportunity for confusion. In fact, I would like to get rid of the concept of "complex attribute" altogether and simply point out that an object or array is indeed a valid value for an attribute. Or perhaps retain the term but not have a separate section to discuss them. |
Ohhhh, I see what you mean. You're thinking that users will assess similarities by looking at the definitions (so reserving |
This addresses the discussion in #573.