如何获取相关实体 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"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想得到这样的相关实体ID:
"relationships": {
"author": {
"data": {
"type": "User",
"id": "b26e0381-6800-4f47-b269-9a92b27ad331"
}
}
Run Code Online (Sandbox Code Playgroud)
API Platform 3 已弃用该allow_plain_identifiers选项,但现在有一个专门讨论此主题的文档页面。
对于 API Platform 2,您可以使用以下配置:
api_platform:
allow_plain_identifiers: true
Run Code Online (Sandbox Code Playgroud)
但请注意:
| 归档时间: |
|
| 查看次数: |
1928 次 |
| 最近记录: |