Hi - I'm struggling a little with the design of our domain-specific
hypermedia format, and wondered if the group could help provide some
clarity?
I shall attempt to use the RiP venacular to explain the problem...
Let's say I'm documenting the media-type 'application/vnd.restbucks
+xml' (as per Chapter 5 of RiP). I have the notion of "order" and
"payment" resources, and I can convey the domain-specifc and protocol
information. I interpret this as the respresentation design for the
'order' and 'payment' resources (appropriate XML schema) and the set
of Link Relations (standard or domain specific) appropriate to domain
(i) structural and (ii) state transition semantics.
In the 'Media type design and formats' paragraph there is some
discourse about the balance of media types and representation
formats. Specifically, whether to use 'application/vnd.restbucks+xml'
as an umbrella type, or to use representation specific formats
'application/vnd.restbucks.order+xml' etc. In the book, the choice is
made to use the umbrella type, leaving indentification of individual
representations to "their XML namespaces". This approach is also
chosen over the Media Type Parameter approach adopted by ATOM with the
'type' parameter.
Now for the slight diversion...
My encoding format is JSON. I acknowledge that I will have to define
the hypermedia control elements etc, but I'm somewhat stuck with the
encoding format.
I have a couple of choices, I can either:
i) Add the resource name into the representation, in a manner similar
to the XML namespace, or
ii) I can stamp out specific media types for each resource, or
iii) I can add a Media Type Parameter, such as ATOM's 'type' and
include the representation format in there e.g. 'application/
vnd.restbucks+xml;type=order'
My (current) views are as follows:
Option (i): I don't like the fact that the identification of the
resource is (only) encoded within the body of the HTTP Message, and
would prefer that it was drawn out into a header of some type (i.e.
Content-Type). Also, I'm not using XML, so trying to 'replicate' this
approach for JSON smells bad.
Option (ii): Seems overly verbose, and frankly wrong. I have a Media
Type with multiple resources, not multiple media types.
Option (iii): Seems reasonable and extensible, and aligned with ATOM,
but I've trawled the IANA Media Type Registry and can't find a single
example of anybody doing it this way (except ATOM). That fills me with
fear. There are some notable uses of Media Type Paramaters in the
field of audio & video codecs (
http://www.iana.org/assignments/media-
type-sub-parameters) which seem analogous, but nothing substantial
from the application/* tree.
Questions:
1. Does the Media Type Parameter approach of Option (iii) seem a)
reasonable and b) standards compliant?
2. Am I (unknowingly) inferring anything else about the Media Type by
defining and using a Parameter?
Thanks for your time and thoughts
Paul
PS: As an adendum Option (iii) also provides a deterministic way of
specifying the resource type when following a 'plain' link (i.e. not a
hypermedia control - no 'rel') from an email, or similar. That
*might* be useful.