知识卡片
集合响应留出元数据
把列表放进对象的 items,可逐步增加总数、下一页或游标。成功查询没有命中时仍可返回 200 与空 items,语义是既有集合当前无匹配。把已公开的根数组直接改成包装对象会改变客户端的解析类型。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Creating an API design using OpenAPI 10.3 The CRUD approach to API operations · 查看原书依据
For “Read” operations on collection endpoints, the response is a collection object that contains an array of resource objects, optionally accompanied by additional fields with metadata. The field that contains the array of items is often called items or the name of
参考来源
- 位置:《Designing APIs with Swagger and OpenAPI》第10章《Creating an API design using OpenAPI》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch10.htm,阅读块 148)
- 结论依据:正文将 items 数组放在外层对象,并用分页数据说明为何值得保留扩展位置。
- 原始内容:For “Read” operations on collection endpoints, the response is a collection object that contains an array of resource objects, optionally accompanied by additional fields with metadata. The field that contains the array of items is often called items or the name of