知识卡片

结构图卡 · 10296.b.2 · 生成模型:未记录

同一契约生成多端产物

理解等级:中级

契约漂移常来自两次手工转译,或需求改变后只更新运行代码。用 OpenAPI 作权威定义时,先在定义里确认所需请求、响应与字段,然后从同一版规格生成控制器接口与模型、客户端 SDK、参考文档,也可派生符合性测试。各团队可以依据已评审的契约并行推进。

业务规则、运行时字段填充和网关行为仍需实施与验证。对外文档应在对应服务已部署时发布该服务版本的定义,避免把未来设计写成线上当前能力。

结构图:

flowchart LR
  R[业务需求] --> S[已确认的 OpenAPI 定义]
  S --> A[服务端接口与模型]
  S --> B[消费方 SDK]
  S --> C[参考文档]
  S --> D[符合性测试]
  A --> E[部署后的公开 API]
  D -->|验证接入结果| E
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 通过代码与定义生成促进遵约 6.1 The API conformance problem · 查看原书依据

      Another option is to make the update in just one place—the OpenAPI definition—and generate the API service controller code, the API client SDK, and the API reference documentation from that. That is, treat the OpenAPI definition from the design phase not just as the SOT, but minimize the chance of human translation errors by generating the API service stub code, API client SDK, and reference documents from it.

    参考来源

    - 位置:《Automating API Delivery APIOps with OpenAPI》《第 06 章 通过代码与定义生成促进遵约》(6.1 The API conformance problem;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-6.xhtml#p20) - 结论依据:解释先改 OpenAPI 再重新生成控制器、SDK 与文档的做法。 - 原始内容:Another option is to make the update in just one place—the OpenAPI definition—and generate the API service controller code, the API client SDK, and the API reference documentation from that. That is, treat the OpenAPI definition from the design phase not just as the SOT, but minimize the chance of human translation errors by generating the API service stub code, API client SDK, and reference documents from it.