Re: REST: Typed resources

Hi Tom,

> It seems to me that media types are a dead end

I agree that the direction of very specific media types is a dead end.
Media types should cover syntax and interpretation, like text/html and application/ld+json,
but I don't see how more specific media types would be scalable.
Otherwise we're just building very specific clients for very specific APIs,
but this gives a 1-on-1 coupling between such clients and APIs.

As a consequence, everything more specific should go inside of the representation.
But this seemingly conflicts with:

> The only types that are significant to a client are the current representation’s media type and standardized relation names.

However, we should be careful with the interpretation of "type".
Fielding is not talking about RDF types here.
The way I interpret "type" in this context is
that a client expects to receive something
that behaves in a certain way, even though
the media type does not allow it to make that assumption.
In contrast, RDF is media types explicitly allow us
to describe which things are there and not.
There is no assumption; the message is self-descriptive.
That's a wholly different story altogether.

It also depends on what you expect a client to do.
The ability to do something with more specific types
might be desired or not. But that doesn't really matter:
the ability to _recognize_ that something is a certain type
is the important thing, so messages must be explicit.

Then a client can say: I found this,
and I (don't) know how to handle such things.

> Well, precisely, but Hydra does exactly the opposite when discovering supported operations for a given supported class. Th client looks up the type x:Page in ApiDocumentation and finds what operations are available for the resource itself and the x:next, x:prev links.

Not necessarily. I implement my clients to look for relations, not types.
In a certain way, it's like object-oriented programming:
if you do Java, you need to compile against the whole interface;
if you do JavaScript, duck typing and using what you need is fine.
You don't need to understand the whole "type" to use it.

Best,

Ruben

Received on Saturday, 19 December 2015 16:22:31 UTC