【发布时间】:2017-07-12 13:29:44
【问题描述】:
如果实体(例如人)具有必须以不同表示形式呈现的数据:
我有一个大的个人资料,有不同的表示,但举一个小例子:
陈述1:
GET /profiles/{id}/activity/projection1
返回:
{"actions":["add", "delete", "add"], "dates":[1499865456, 1499861544, 1499863655]}
陈述2:
GET /profiles/{id}/activity/projection2
返回:
{add_at:[1499865456, 1499863655], delete_at:[1499861544]}
那么问题来了:如何设计这样的案例? 我有一些想法,但不知道哪个更好
GET /profiles/{id}/activity/projection1
GET /profiles/{id}/activity/projections/1
GET /profiles/{id}/activities/projection1
GET /profiles/{id}/activities/projections/1
GET /profiles/{id}/activity-actions and GET /profiles/{id}/activity-timestamps
我只发现了一个相同的问题Different RESTful representations of the same resource,但它是关于过滤数据以响应而不是关于更改模型
【问题讨论】:
标签: rest api api-design