知识卡片

普通读书笔记卡 · 10296.b.3 · 生成模型:未记录

从实现反推OpenAPI

理解等级:中级

从代码生成 OpenAPI 可以利用框架的路由、模型、类型和注解,减少已实现结构与文档的偏差。生成物仍要评审,因为描述和示例、字符串范围、错误状态以及入口上游的响应变换可能无法推断。可从应用生成 as-is 契约,再与评审过的设计定义比较,并由生成后且核实的定义派生文档和 SDK。

遇到业务或技术约束不明时,先做代码原型收集信息,再导出定义进入设计迭代。探索所用规格只有经过确认并匹配发布内容,才适合成为消费者可依赖的契约。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Automating API Delivery APIOps with OpenAPI》《第 06 章 通过代码与定义生成促进遵约》(6.3 Generating OpenAPI from code;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-6.xhtml#p154) - 结论依据:说明代码生成定义可用于对照设计,也可用于原型探索。 - 原始内容:Rather than generate code from the API definition, some teams take the approach of writing the code for the API service, generating an OpenAPI definition from it, comparing the generated definition to the SOT definition from the design phase, and fixing any differences.