Skip to content
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

json-api conformity #983

Closed
heartsentwined opened this issue May 16, 2013 · 4 comments
Closed

json-api conformity #983

heartsentwined opened this issue May 16, 2013 · 4 comments

Comments

@heartsentwined
Copy link
Contributor

I would like to start a discussion on the level of conformity that we can expect from ember-data, to the json-api specs.

I was first directed from #962 and #379 to json-api/json-api#18, where @tomdale seems to indicate that ember / ember-data would follow json-api.

The latest revision (rev. 12 at the time of writing) here in BREAKING_CHANGES.MD, however, indicates that ember-data had made an effort to standardize its api calls (on singular and plural ids), but instead of conforming with the json-api-suggested style of links and urls, it introduced *_id and _ids suffixes for models.

ember-data itself does not have any docs on its expected api, but over at the official ember docs, it was documented as the above-mentioned *_id(s)-suffix style also. In addition, the GET /resources?ids[]=1&ids[]=2 was also documented; while json-api documents a GET /resources?ids=1,2 request.

The entire links implementation from json-api was also absent.

Finally, from the json-api FAQ, it was also mentioned that ember is an exemplar conformer to the specs - while this is not so.

So I would like to start a discussion here, in hope of reaching a common agreement of what API spec ember-data would adopt, and hopefully explicitly documenting it - unless we decide to fully adopt json-api, that is.

@heartsentwined
Copy link
Contributor Author

cc @tchak

@tchak
Copy link
Member

tchak commented May 16, 2013

@heartsentwined ember-data will at some point support the spec. But the spec for now is not stable. I expect it to change quite a bit for a while. The first step would be probably to implement json-api on the active_model_serializer side of things and when it would be just a metter of adding JSONAPISerializer to ember-data.

@stephenrs
Copy link

I'm also very interested in this topic. My team and I have begun the process of migrating/modernizing a fairly large existing web app to Ember/EmberData, and have found the early JSONAPI spec to be a great starting point and guide for standardizing our growing collection of services. I was pretty surprised to find that EmberData didn't yet support the full JSONAPI spec - particularly because the part of the app that we're building now needs at least read access to the 'links' component..but I'm no stranger to the bleeding edge beast...

To bridge the gap, so that we could implement the JSONAPI spec in our services now, and still use the RESTAdaptor, we've implemented a simple custom transform, something like this:

App.Widget = DS.Model.extend({ id: DS.attr('number'), name: DS.attr('string'), links: DS.attr('links') }); App.Adapter.registerTransform('links', { serialize: function(value) { return [ value.get('foo'), value.get('bar'), value.get('baz') ]; }, deserialize: function(value) { return Ember.create({ foo: value['foo'], bar: value['bar'], baz: value['baz'] }); } });

This lets us spit out JSON from the backend according to the current spec, and access 'links' naturally in our Ember app, and works fine for our current limited needs...but that won't last for long...so any information/inspiration that can get stirred up here would be great.

Not sure if I'm ready to bite off building a something usable by the community, but I'd like to participate in any way that I can to help advance the effort.

@wagenet
Copy link
Member

wagenet commented Aug 13, 2013

I talked to @wycats about this recently and the plan is to fully support the JSONAPI spec. If you want to discuss further, the forums are a good place for this.

@wagenet wagenet closed this as completed Aug 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants