api-platform / api-platform/core

HAL links of embedded resources not consistent with standard representation

Aperta
#1,291 18 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Good First Issue Hacktoberfest
Lingua principale
PHP
Stelle
2.6k
Fork
980
Merge medio
2g 5h
PR unite (30g)
48

Descrizione

Considering using the demo app: https://github.com/api-platform/demo

Modifying the `Book` Entity so `Reviews` are embedded.
A review looks like:
```json
{
"_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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.