知识卡片
示例与模拟服务帮助试接口
规范中的响应示例可支撑开发者门户和模拟服务,让消费者在真实服务建成前试用接口并反馈设计。但示例本身可能与模式不一致,需校验其请求或响应结构;模拟成功也只能证明约定的示例可用,不能证明真实实现覆盖全部行为。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
The OAS can provide example responses for the paths in the specification. Examples, as we’ve discussed, are useful for documentation to help developers understand the expected API behavior. Some products have started to use examples to allow the user to query the API and return example responses from a mock service. This can be really useful in features such as a developer portal, which allows developers to explore documentation and invoke APIs.
参考来源
- 位置:《Mastering API Architecture》第1章《Design, Build, and Specify APIs》之《Examples and Mocking》(源文件:_epub-src/OEBPS/ch01.xhtml)
- 结论依据:原文说明 OAS 示例可驱动 mock 以便生产者和消费者提前试用接口,同时指出示例可能只是字符串、需验证与对应模式匹配。
- 原始内容:The OAS can provide example responses for the paths in the specification. Examples, as we’ve discussed, are useful for documentation to help developers understand the expected API behavior. Some products have started to use examples to allow the user to query the API and return example responses from a mock service. This can be really useful in features such as a developer portal, which allows developers to explore documentation and invoke APIs.