RESTful 相关资源使用 JSONAPI 模式

RESTful related resource using JSONAPI schema

我正在关注 jsonapi schema to return a standardised response from a web API. I want to reduce the number of HTTP requests to get related information so it looks like I want to use compound documents 到 return(例如)一篇文章和两条相关评论。

我有点理解这一点,但我想知道 RESTful GET 请求是什么?我在想

http://api.mysite.com/v1/articles/1?comments=2

我想说清楚,但是为了从资源中 return 获取相关信息,请求参数是必需的吗?

听起来像你想要的 /v1/articles/1?include=comments&limitComments=2

其中 limitComments 是一个 API 特定参数(注意成员名称要求)

http://jsonapi.org/format/#query-parameters http://jsonapi.org/format/#fetching-includes

或者,您可以 /v1/comments?include=articles&filter[articles]=1&page[size]=2

http://jsonapi.org/recommendations/#filteringhttp://jsonapi.org/format/#fetching-pagination