知识卡片

普通读书笔记卡 · 3499

契约驱动模拟外部服务

理解等级:中级

外部服务尚未运行时,可由其 API 规范驱动模拟服务器,先验证客户端请求形状并取得符合契约的示例响应。这适合检验接口集成的路径、载荷与状态码;模拟器只复现契约层行为,不能证明真实服务的业务规则、时序或故障处理都正确。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 7 章《Service implementation patterns for microservices》(源文件:_epub-src/OEBPS/Text/07.htm) - 结论依据:原文用厨房和支付 OpenAPI 文件代替实际服务,说明模拟服务器校验请求并返回有效响应,随后以 Prism 演示接口调用。 - 原始内容:API mock servers replicate the server behind the APIs, validating our requests and returning valid responses. We’ll use Prism CLI ( https://github.com/stoplightio/prism ), a library built and maintained by Stoplight, to mock the API server for the kitchen and payments services.