plexus / yaks

Ruby library for building hypermedia APIs
http://rubygems.org/gems/yaks
MIT License
236 stars 26 forks source link

Update JSON API #98

Closed groyoh closed 5 years ago

groyoh commented 9 years ago

Some changes has been made to the JSON API format lately. They added a relationship key to resource objects with is a pretty big change. It seems that they also plan to change linkage to data. I'll try to make a list of changes that needs to be done and maybe we could keep this issue opened and add new features to the list until they release it.

Reference: http://jsonapi.org/format/

janko commented 9 years ago

Yeah, I was thinking to just wait for JSON-API to get to 1.0, and then bring Yaks up-to-date. Because I found myself rereading the entire spec to see what changed, but it's easier to just read it just once again when a stable version is released. The official date was supposed to be tomorrow, but they don't look ready yet.

Another thing that we're still missing are errors (https://github.com/plexus/yaks/issues/62). I have a pretty straightforward monkey patch in my app, just telling the JsonApi formatter to render {:errors => errors} if the resource type is "error" (I made my own ErrorMapper for displaying application-specific errors, with attributes conforming to the JSON-API standard, just title, id and status). But from the description of the issue it seems that @plexus wants to make general changes in Yaks to support errors, I will see if I can help somehow, even though I'm not familiar with other JSON specifications.

groyoh commented 9 years ago

I was looking forward to wait for 1.0 too but as things go I don't know if it will be released tomorrow. In the meantime, it might be easier to add small changes once at a time rather than doing it all at once. This way it may be easier to see what needs to be changed too.

groyoh commented 9 years ago

Looks like JSON API will be released on 28th of May and that no changes would be made until then. So we should definitely implement it! :smile: (source: http://jsonapi.org/status/)

janko commented 9 years ago

Awesome, let's go for it!

tobidelius commented 9 years ago

How is this going?

janko commented 9 years ago

@sandelius You can track the progress on https://github.com/plexus/yaks/pull/101 :)

groyoh commented 9 years ago

101 has been merged. So what is missing right now:

@plexus proposed this for links:

class PostMapper < Yaks::Mapper
  has_one :user, mapper: Class.new(UserMapper) { link :self, ... }
end

but the template uri would be evaluated in the user mapper, right? So what if we want to build http://example.com/posts/1/relationships/user where 1 is the post id?

tobidelius commented 8 years ago

Is this list still accurate?