知识卡片
规范校验可设在流量边界
在入口或测试链路用 OpenAPI 校验请求、响应与规范的结构一致性,可在消息进入后端前拒绝不合形状的输入,并发现实现偏离契约。校验位置要考虑网关改写路径等情况;它只检查规范能表达的约束,不能替代业务授权与行为测试。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
OpenAPI Specifications are useful for validating the content of an exchange to ensure the request and response match the expectations of the specification. At first it might not seem apparent where this would be useful—if code is generated, surely the exchange will always be right? One practical application of OpenAPI validation is in securing APIs and API infrastructure.
参考来源
- 位置:《Mastering API Architecture》第1章《Design, Build, and Specify APIs》之《OpenAPI Validation》(源文件:_epub-src/OEBPS/ch01.xhtml)
- 结论依据:原文说明规范可核验交换内容,举例在 DMZ 检查并终止不匹配的流量,又提到基础路径被基础设施改变时要配置覆盖值。
- 原始内容:OpenAPI Specifications are useful for validating the content of an exchange to ensure the request and response match the expectations of the specification. At first it might not seem apparent where this would be useful—if code is generated, surely the exchange will always be right? One practical application of OpenAPI validation is in securing APIs and API infrastructure.