This is question more about service architecture strategy, we are building big web system based on rest services on back end. And we are currently trying to build some standard internal to follow while developing rest services.
Some queries returns list of entities, for example lets consider we have image galleries retrieving service: /gell_all_galeries, returning next response:
<galleries>
<gallery>
<id>some_gallery_id</id>
<name>my photos</name>
<photos>
<photo>
<id>123</id>
<name>my photo</name>
<location>http://mysite/photo/show/123</location>
......
<author>
<id>some_id</id>
<name>some name</name>
.......
<author>
</photo>
<photo> ..... </photo>
<photo> ..... </photo>
<photo> ..... </photo>
<photo> ..... </photo>
</photos>
</gallery>
<gallery> .... </gallery>
<gallery> .... </gallery>
<gallery> .... </gallery>
<gallery> .... </gallery>
</galleries>
As you see here, response quite big and heavy, and not always we need such deep info level. Usual solution is to use or http://ru.wikipedia.org/wiki/Atom elements for each gallery instead of full gallery data:
<galleries>
<gallery>
<id>some_gallery_id</id>
<link href="http://mysite/gallery/some_gallery_id"/>
</gallery>
<gallery>
<id>second_gallery_id</id>
<link href="http://mysite/gallery/second_gallery_id"/>
</gallery>
<gallery> .... </gallery>
<gallery> .... </gallery>
<gallery> .... </gallery>
<gallery> .... </gallery>
</galleries>
The first question, is next: maybe instead we shouldn't even use and types, and just use generic and for all resources that return list objects:
<list>
<item><link href="http://mysite/gallery/some_gallery_id"/></item>
<item><link href="http://mysite/gallery/other_gallery_id"/></item>
<item>....</item>
</list>
And the second question, after user try to retrieve info about some concrete gallery, he'll use for example http://mysite/gallery/some_gallery_id link, what should he see as results?
Should it be:
<gallery>
<id>some_gallery_id</id>
<name>my photos</name>
<photos>
<photo>
<id>123</id>
<name>my photo</name>
<location>http://mysite/photo/show/123</location>
......
<author>
<id>some_id</id>
<name>some name</name>
.......
<author>
</photo>
<photo> ..... </photo>
<photo> ..... </photo>
<photo> ..... </photo>
<photo> ..... </photo>
</photos>
</gallery>
or :
<gallery>
<id>some_gallery_id</id>
<name>my photos</name>
<photos>
<photo><link href="http://mysite/photo/11111"/></photo>
<photo><link href="http://mysite/photo/22222"/></photo>
<photo><link href="http://mysite/photo/33333"/> </photo>
<photo> ..... </photo>
</photos>
</gallery>
or
<gallery>
<id>some_gallery_id</id>
<name>my photos</name>
<photos>
<photo>
<link href="http://mysite/photo/11111"/>
<author>
<link href="http://mysite/author/11111"/>
</author>
</photo>
<photo>
<link href="http://mysite/photo/22222"/>
<author>
<link href="http://mysite/author/11111"/>
</author>
</photo>
<photo>
<link href="http://mysite/photo/33333"/>
<author>
<link href="http://mysite/author/11111"/>
</author>
</photo>
<photo> ..... </photo>
</photos>
</gallery>
I mean if we use link instead of full object info, how deep we should go there? Should I show an author inside photo and so on.
Probably my question ambiguous, but what I'm trying to do is create general strategy in such cases for all team members to follow in future.