What is the correct media type for HAL + JSON?

I use Spring to create a RESTful service, and I'm curious about the syntax for media types.

In my opinion, the common media type for HAL + JSON is application/hal+json . In addition, from my point of view, a special type of media type that supports HAL + JSON will be similar to application/vnd.api.entity.hal+json . However, I also saw application/vnd.api.entity+hal+json . Which one is correct?

Also, what would be the correct wild-card type for HAL + JSON? This will be application/*.hal+json or application/*+hal+json . Links to any suitable RFC will be appreciated. Thanks!

+7
java spring rest
source share
1 answer
 application/vnd.api.entity+json 

application/vnd.api.entity.hal+json only makes sense if you plan to provide your data also without HAL support. In any case, the client must know the structure of the content, and the HAL is part of it.

application/vnd.api.entity+hal+json simply wrong. The standard states that only registered suffixes should be used. He also refers to them as "structured syntactic suffixes." So it’s very clear that this is about how to read data not about its meaning. Only one suffix is ​​allowed, and no longer makes sense.

Think of it as application/semantic+syntax or application/what in it + how to read it .

+6
source share

All Articles