James:
good to see you using hypermedia in your message designs; it's
something i do in almost all my implementations.
what follows are some of my observations and opinions on your design.
1) check out RFC6570 - URI Template [1]. This is a newly-release
standard on creating the kind of templates you are showing here. the
RFC includes processing rules and will (likely) lead to folks writing
standard parser libraries. then we can all use a common set of
templates w/ assurances they will be understood and processed by a
wide range of clients.
2) i see your designs use things like "code" and "name" to help
identify the link.. I'd encourage you use the "rel" attribute for this
and follow the RFC5988 - Web Linking [2] spec. it's essentially doing
what i think i see you already doing, but again it will be
standardized in a way that third-party devs will pick up easily.
3) operationally, i'm not sure (from looking at the example) which
"id" should be plugged into which template. this proly is covered in
the docs, but you might want to use naming to help make that easier to
pick up quickly wen devs are looking at your messages (i.e.
shipmentId, warehouseId, etc.).
4) it's not clear to me (from this example) why you are using the
template for shipment and warehouse links. are there other possible
values for {id} that i could use? if yes, where are those values? if
not, it's better to juse pass me (the client dev) a complete URI that
i know will work w/o me needing to "construct" the URI before it's
valid.
5) you write in your narrative that devs can "drop" the {id} from the
template in order to get a list of valid ids. personally, i prefer
_NOT_ coding that rule in my clients (or asking other devs to do
that). instead, i provide a "list" URI that can be used directly.
again, this makes sure devs don't need to hard code URI construction
into their apps and let's me (the server coder now<g>) change this URI
sometime in the future w/o breaking existing code. one possible way to
do this is:
"ShipmentType": {
"Id": "2"
"Code": "Road",
"ItemUri": "
http://api.company.com/logistics/shipmenttypes/{Id}",
"ListUrl" : "
http://api.company.com/logistics/shipmenttypes/"
},
Finally, i've been working on a similar design for JSON-Hypermedia.
I've registered the Collection+JSON media type[3] and continue to
tweak it based on feedback. feel free to use this as a guide for ideas
on your own design and/or provide me feedback on changes you think
could make CJ useful for your needs.
Hope this helps.
Mike
[1]
http://tools.ietf.org/html/rfc6570
[2]
http://tools.ietf.org/html/rfc5988
[3]
http://amundsen.com/media-types/collection/
mca
http://amundsen.com/blog/
http://twitter.com@mamund
http://mamund.com/foaf.rdf#me