分层 REST API 与规范化 REST API

Hierarchical REST API vs Normalized REST API

首先,我想解释一下我编的Hierarchical REST APINormalized REST API的含义。

{
  "name": "John Doe",
  "orders": [{
      "id": 1,
      "price": 10,
      "delivered": true
    }, {
      "id": 2,
      "price": 11,
      "delivered": false
    }
  ]
}
{
  "name": "John Doe",
  "orderIds": [1, 2]
}

我觉得这两种方式各有优缺点

我的问题是:

Is there terminology for the Hierarchical REST API and Normalized REST API?

没有

Which one is more fit to the REST API guideline?

他们都“很好”。

想想万维网,以及我们如何向浏览器传送 CSS 指令。我们可以将 CSS 直接嵌入到 HTML 页面中吗?是的。我们可以通过不同的资源获取 link 到 CSS 吗?是的

这两种方法都“符合 REST API 准则”。是的 - 更准确地说,它们起作用是因为 HTML 是一种通用的标准化媒体类型,具有关于如何引用 CSS 的规则;每个人都以同样的方式理解这些规则。