daybed icon indicating copy to clipboard operation
daybed copied to clipboard

Collection+JSON renderer

Open leplatrem opened this issue 11 years ago • 10 comments
trafficstars

http://amundsen.com/media-types/collection/

leplatrem avatar Jan 20 '14 20:01 leplatrem

Notes : https://gist.github.com/tmaiaroto/8533343 via @davidbgk

leplatrem avatar Jan 22 '14 09:01 leplatrem

@leplatrem let me know if you need some help on that integration, I'd love to work with you :)

davidbgk avatar Jan 22 '14 15:01 davidbgk

Oh great thanks, same for me! I feel honoured ;)

If you're willing to help on this, this is good news! :) We sometimes meet on freenode#daybed

First step would be to choose the most relevant default format among all of them!

So far the default data view does not follow any normalized layout :

{"data": [
   {
      "age": 120,
      "name": "jeanette"
   },
   ...
 ]}

This one looks pretty interesting too : http://json-schema.org/latest/json-schema-hypermedia.html

Notable parts of the code for this :

  • Records view : https://github.com/spiral-project/daybed/blob/dev/daybed/views/records.py#L36
  • Single record view : https://github.com/spiral-project/daybed/blob/dev/daybed/views/records.py#L79
  • GeoJSON renderer https://github.com/spiral-project/daybed/blob/dev/daybed/renderers.py

Related story #139 (browsable API, HATEOA)

leplatrem avatar Jan 23 '14 09:01 leplatrem

I don't have any particular preference regarding the format. Current trends are https://github.com/kevinswiber/siren and http://json-ld.org/ (that is now a W3C recommendation: http://www.w3.org/blog/news/archives/3589)

My initial question is: "Why would you like to add hypermedia to your API?"

davidbgk avatar Jan 26 '14 22:01 davidbgk

Well, let's say there are two ideas :

  • serve records collections using a normalized layout (this issue) ;
  • bring some browsability in general for easier exploration and auto-discovery (issue #139)

Regarding the former, I would say that normalized output is generally sane, because it would save us from implementing custom connectors for most clients or frameworks (see existing list for collection-json)... Well, even if I must admit that the current implementation is quite straightforward to plug (ex. with backbone)...

I find it hard to choose the default layout too, trends move! But as long as they have different mimetype or profile we can add several serializers without having to argue :)

leplatrem avatar Jan 27 '14 19:01 leplatrem

@davidbgk I guess you heard that 3 prestigious mozillians have joined the party :) Are you still willing to give a hand ?

leplatrem avatar Jun 02 '14 12:06 leplatrem

@leplatrem sure it's always a pleasure to work with mozillians ;) I don't want to slow things down though, do you plan to work on it soon?

davidbgk avatar Jun 02 '14 14:06 davidbgk

Oh, don't worry! Since it's remained a side-project for me, I don't care about productivity :)

n1k0, alexis and natim seem to be able to spend 1 day/week with a roadmap. Of course, it gave us a serious boost of motivation!

But just pick up what you like and enjoy most !

leplatrem avatar Jun 02 '14 19:06 leplatrem

I may starts using json-ld, siren looks a bit to heavy for me.

Natim avatar Jul 30 '14 10:07 Natim

So basically, all we need is to add:

@id with a link to the item @context with a link to the context description.

This means we will have to be able to return a model on a @context compliant form: See http://www.w3.org/TR/json-ld/#the-context

To do so, we will need to define a schema on each field type.

Natim avatar Jul 30 '14 10:07 Natim