← 返回刚才阅读的位置

知识卡片

操作参考卡 · 10421.c · 生成模型:GPT-6

错误声明给出可预期分支

理解等级:高级

在 responses 中明确列出该操作可能出现且客户端需要处理的状态,并用公共组件约束格式。把尚无特定处理的其余响应交给 default。同状态的不同业务原因可用类型或扩展字段区分。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Designing APIs with Swagger and OpenAPI》第18章《Supporting the unhappy path: Error handling with problem+json》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch18.htm,阅读块 145) - 结论依据:书中比较仅写 default 与逐操作列可发生状态的接入价值。 - 原始内容:Of course, we could blindly add a default response for errors to every method and call it a day. Technically, that would cover everything and the contract would be valid. Would the contract be useful, though? If we get into the shoes