【问题标题】:RESTful related resource using JSONAPI schema使用 JSONAPI 模式的 RESTful 相关资源
【发布时间】:2016-10-11 17:12:17
【问题描述】:

我正在遵循 jsonapi 架构从 Web API 返回标准化响应。我想减少获取相关信息的 HTTP 请求的数量,所以看起来我想使用compound documents 来返回(例如)一篇文章和两个相关的 cmets。

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

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

我喜欢明确,但为了从资源返回相关信息,请求参数是必需的吗?

【问题讨论】:

    标签: rest json-api


    【解决方案1】:

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

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-07
      • 1970-01-01
      • 2015-12-10
      • 1970-01-01
      • 2016-01-26
      • 1970-01-01
      相关资源
      最近更新 更多