-
Notifications
You must be signed in to change notification settings - Fork 71
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
Added value objects for possible values #69
base: master
Are you sure you want to change the base?
Conversation
@@ -49,7 +49,19 @@ The media type for JSON Siren is `application/vnd.siren+json`. | |||
"fields": [ | |||
{ "name": "orderNumber", "type": "hidden", "value": "42" }, | |||
{ "name": "productCode", "type": "text" }, | |||
{ "name": "quantity", "type": "number" } | |||
{ "name": "quantity", "type": "number" }, | |||
{ "name": "color", "type": "radio", "title": "Choose a Color", |
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.
A name describing the control. Field names MUST be unique within the set of fields for an action. The behaviour of clients when parsing a Siren document that violates this constraint is undefined. Required.
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.
Thanks for spotting this. The 'color' attribute was not meant to appear twice. Changed to 'accessories'.
FYI I have no capability to change the spec, but IMO, I doubt the spec will be changed without 'real' implementations and feedback. Therefore I think you should move on extending it yourself and report back to the group about how it went, what was good, what was bad, etc.... In general I don't think it's a good practice to change a spec before real world implementations are tried. |
@apsoto Yes, that's the general direction I'd like to take. I've implemented this, but I'd like some more feedback from other folks. |
I wanted to drop in and give some feedback on this topic. I ended up going with this as a solution for providing multiple values for a given field, and it worked well. My only issue was that the current proposal feels a tad out of place. All other code around modeling representations is laughably simple with almost no conditions (this is the part of Siren's design that resonates with me). In other words, it mapped almost directly to my classes. But this proposal introduces a special rule, such as when converting to JSON, if it's a string or number do this, and if it's a list of Value objects, do that. This also shows up in the JSON Schema as the only place a "oneOf" is used. I don't say this to say it's bad at because it worked for me, however it just seems almost too special for Siren. :) I have wondered in this if there is a different way to think about this. Instead of a For me, it would remove a little bit of the magic that I'm feeling. It would also mimic the way |
Just to add one note of clarity for my suggestion, like how "Sub Entity" has "Embedded Representation" and "Embedded Link," you would have "Field" that would have "Single Value Field" and "Multi-Value Field" (or of course better names). The JSON Schema would then be an |
While implementing Siren support for the Insomnia ReST client, I found @smizell 's observation helpful. The suggested PR (which was built on a comment by @kevinswiber in the google group) breaks an implementation which relies on the |
following https://groups.google.com/forum/#!topic/siren-hypermedia/8mbOX44gguU