daybed
daybed copied to clipboard
Collection+JSON renderer
http://amundsen.com/media-types/collection/
Notes : https://gist.github.com/tmaiaroto/8533343 via @davidbgk
@leplatrem let me know if you need some help on that integration, I'd love to work with you :)
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)
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?"
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 :)
@davidbgk I guess you heard that 3 prestigious mozillians have joined the party :) Are you still willing to give a hand ?
@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?
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 !
I may starts using json-ld, siren looks a bit to heavy for me.
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.