Open
Description
Considering using the demo app: https://github.com/api-platform/demo
Modifying the Book
Entity so Reviews
are embedded.
A review looks like:
{
"_links": {
"book": {
"href": "/books/3"
},
"self": {
"href": "/reviews/275"
}
},
"author": "Herbert Reinger I",
"body": "Voluptas hic ipsum cumque aliquid. Vero iusto sit atque hic non voluptate dignissimos velit. In reprehenderit accusamus cum porro. Doloremque eligendi architecto quia omnis eaque vel officiis.",
"id": 275,
"publicationDate": "1970-07-11T14:10:52+00:00",
"rating": 5
}
A book (with embedded review) looks like this:
{
"_embedded": {
"reviews": [
{
"_links": {
"self": {
"href": "/reviews/275"
}
},
"author": "Herbert Reinger I",
"body": "Voluptas hic ipsum cumque aliquid. Vero iusto sit atque hic non voluptate dignissimos velit. In reprehenderit accusamus cum porro. Doloremque eligendi architecto quia omnis eaque vel officiis.",
"id": 275,
"publicationDate": "1970-07-11T14:10:52+00:00",
"rating": 5
}
]
},
"_links": {
"reviews": [
{
"href": "/reviews/275"
}
],
"self": {
"href": "/books/3"
}
},
"author": "Prof. Joelle Doyle",
"description": "Cupiditate quae ut sit illo. Accusamus ex voluptatem et eveniet nemo voluptatibus necessitatibus. Veniam odit ducimus consequuntur voluptatem id quod pariatur distinctio.",
"id": 3,
"isbn": "9783899289190",
"publicationDate": "1996-01-02T00:00:00+00:00",
"title": "Excepturi quo dolor et officiis minima et consequatur earum."
}
Note that the embedded Review
does not have a book
in its _links
.
How can the embedded representation be made to match the non embedded?
I.e they both should have book
link. the representation must be consistent.
Thanks