Make Spring HATEOS links serializion/deserialization JSON:API 1.1 compliant
Closed this issue · 1 comments
Spring HATEOAS provides a generic link concept. In JSON:API, for relationships between rest resources, the relationsships
attribute is in most cases the proper solution. Furthermore, JSON:API provides a links attribute, both for the top-level document, as well as for resource links. The only allowed member of resource-level links is self
. So, if a Spring HATEOAS representation model contains only a self-link, the current serialization would be JSON:API compliant. An example is:
{
"data": {
"id": "4",
"type": "movies",
"attributes": {
"title": "The Matrix"
},
"links": {
"self": "/api/movies/4"
}
}
}
But if you would add a link with the relation imdb, the current serialization would NOT be JSON:API compliant:
{
"data": {
"id": "4",
"type": "movies",
"attributes": {
"title": "The Matrix"
},
"links": {
"imdb": "https://www.imdb.com/title/tt0133093/"
}
}
}
Furthermore, Spring HATEOAS allows adding several links with the same relation name. Currently this library serializes this as an array, which is NOT JSON:API complient. The JSON:API spec demats that a link with a unique name is always a JSON object, never an array.
I am currently thinking about solutions, that the always library creates JSON:API compliant results. Furthermore, I am thinking of validation capabilities and more specific link building support.
serialization and configuration done.