Hi,
I'm quite new to designing resources and representations for Web APIs.
One if things I'm struggling a bit is modelling variety of attributes
of items in a collection.
For instance, `/products`, then `/products/1` and `/products/2` share
common set of attributes (e.g. name, description), but they also have
set of attributes specific (e.g. depending on category of product).
IOW, it models a typical OO hierarchy.
Can anyone recommend a good resource devoted to modelling/encoding
attributes set for resource representations?
One of the recommendations I've found is Darrel Miller talk at NDC
https://vimeo.com/131643022 where from around 27min and 29min
suggests to "avoid structure, that's good". That means a flat list of
attributes has advantages, but it is not entirely clear to me what
exactly. Darrel mentions that adding things is easy, removing things
is hard, but I see little difference between adding/removing one
attribute vs whole group./
Then later, from around 22:18, Darrel discusses attribute groups and
among number of reasons why to group attributes,
one is particularly interesting: optional attributes - if group is
present, then attributes of that group are mandatory.
That actually is a compelling reason to use groups - I see it can be
useful to model hierarchies of categories and subtypes for
items in resources.
I'm interested to hear any ideas related to modelling attributes for resources.
Best regards,
--
Mateusz Loskot,
http://mateusz.loskot.net