Json-api links

18 views
Skip to first unread message

Oliver Barnes

unread,
Jun 17, 2014, 5:45:21 AM6/17/14
to roar...@googlegroups.com
Hey guys,

Is it possible to represent links in the format json-api prescribes? As per http://jsonapi.org (example right at the top of homepage)

I'm aware there isn't built-in support like there is for HAL, justI'm wondering if I can get it going with the roar/representable's dsl. Opening the hood it looked like the Hypermedia module wouldn't do it as is.

Oliver



 

Nick Sutterer

unread,
Jun 17, 2014, 5:47:41 AM6/17/14
to roar...@googlegroups.com
I thought about providing JSON-API support in Roar in general if anyone helps me out with tests.


--
You received this message because you are subscribed to the Google Groups "Roar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roar-talk+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Sutterer

unread,
Jun 17, 2014, 5:53:51 AM6/17/14
to roar...@googlegroups.com
So, a DSL like that

link "posts.comments", type: :comments do
  "http://example.com/comments/{posts.comments}"
end

would produce that

"posts.comments": {
  "href": "http://example.com/comments/{posts.comments}",
  "type": "comments"
}

Right?

Oliver Azevedo Barnes

unread,
Jun 17, 2014, 10:57:39 AM6/17/14
to roar...@googlegroups.com, Nick Sutterer
Happy to help with tests, I looked into actually implementing it myself, but it was a little over my head

Oliver

On June 17, 2014 at 11:47:41 AM, Nick Sutterer (apot...@gmail.com) wrote:
> I thought about providing JSON-API support in Roar in general if anyone
> helps me out with tests.
>
>
> On Tue, Jun 17, 2014 at 7:45 PM, Oliver Barnes

Oliver Azevedo Barnes

unread,
Jun 17, 2014, 11:00:29 AM6/17/14
to roar...@googlegroups.com
Ok, but then how do I wrap that in a 'links' hash?

"links": {
    "posts.comments": {
      "href": "http://example.com/comments/{posts.comments}",
      "type": "comments"
    }
  },

and then, in the resource itself, create this

"posts": [{
    "id": "1",
    "links": {
      "comments": [ "5", "12", "17", "20" ]
    }
  }]

Oliver

On June 17, 2014 at 11:53:51 AM, Nick Sutterer (apot...@gmail.com) wrote:
> So, a DSL like that
>
> link "posts.comments", type: :comments do
>
> "http://example.com/comments/{posts.comments}"
>
> end
>
> would produce that
>
> "posts.comments": {
> "href": "http://example.com/comments/{posts.comments}",
> "type": "comments"
> }
>
>
> Right?
>
>
> On Tue, Jun 17, 2014 at 7:47 PM, Nick Sutterer wrote:
>
> > I thought about providing JSON-API support in Roar in general if anyone
> > helps me out with tests.
> >
> >
> > On Tue, Jun 17, 2014 at 7:45 PM, Oliver Barnes

Oliver Azevedo Barnes

unread,
Jun 17, 2014, 12:36:38 PM6/17/14
to roar...@googlegroups.com
WIP tests:

https://github.com/apotonick/roar/pull/98

It’s making more sense as I get into it, I can take a stab at the implementation too, with some guidance

Oliver

On June 17, 2014 at 11:47:41 AM, Nick Sutterer (apot...@gmail.com) wrote:
> I thought about providing JSON-API support in Roar in general if anyone
> helps me out with tests.
>
>
> On Tue, Jun 17, 2014 at 7:45 PM, Oliver Barnes

Nick Sutterer

unread,
Jun 17, 2014, 6:13:39 PM6/17/14
to roar...@googlegroups.com
So cool, thanks for that, breaking tests are the best motivation to implement stuff.
Reply all
Reply to author
Forward
0 new messages