知识卡片
响应按状态与媒体建模
在操作的 responses 中以状态码为键。每条响应先写 description,含正文时在 content 下列出媒体类型并给出相应 schema。客户端可按状态选择处理分支,再按媒体类型和模式解码数据。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Describing API responses 5.7 Describing the GET /reviews response · 查看原书依据
Inside each operation, we can describe several responses, one for each status code. The responses all go under the responses field. Each key in the responses field is a status code, and its value is a response definition object. The only required
参考来源
- 位置:《Designing APIs with Swagger and OpenAPI》第05章《Describing API responses》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch05.htm,阅读块 119)
- 结论依据:原文写明每个状态关联一份响应对象,描述字段为最小内容。
- 原始内容:Inside each operation, we can describe several responses, one for each status code. The responses all go under the responses field. Each key in the responses field is a status code, and its value is a response definition object. The only required