知识卡片
框架错误格式也要对账
收集框架真实错误样本再写契约。不要用一次校验失败推定所有场景都有相同细节。若无法统一框架错误,用媒体类型和已知字段组织解析,并留出缺字段的处理。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Supporting the unhappy path: Error handling with problem+json 18.4 The OAS tools format · 查看原书依据
Also, there is a message field with a human-readable error description, and there’s an errors array. The item inside errors provides an errorCode field with a specific type identifier called type.openapi.validation so that clients can immediately understand that this is a validation
参考来源
- 位置:《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,阅读块 119)
- 结论依据:原文从 400、404、405 样本发现 path 意义与 errorCode 存在性不同。
- 原始内容:Also, there is a message field with a human-readable error description, and there’s an errors array. The item inside errors provides an errorCode field with a specific type identifier called type.openapi.validation so that clients can immediately understand that this is a validation