如何获取相关实体ID而不是资源路径?
例如,这就是我现在得到的:
{
"id": "/api/articles/0d8cb40c-221b-4c54-9e29-43877093b839",
"type": "Article",
"attributes": {
"_id": "0d8cb40c-221b-4c54-9e29-43877093b839",
"title": "Article",
"content": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>",
"dateCreated": "2018-07-17T18:20:29+03:00",
"dateUpdated": "2018-07-17T18:20:29+03:00"
},
"relationships": {
"author": {
"data": {
"type": "User",
"id": "/api/users/b26e0381-6800-4f47-b269-9a92b27ad331"
}
}
}
}
我想要这样的相关实体ID:
"relationships": {
"author": {
"data": {
"type": "User",
"id": "b26e0381-6800-4f47-b269-9a92b27ad331"
}
}
答案 0 :(得分:0)
您可以使用以下配置:
api_platform:
allow_plain_identifiers: true
但是请注意: