在API开发中如何执行合同?

1作者: arter452 个月前原帖
想象一下,你从一个API“合同”开始,比如Swagger规范。<p>你使用生成器自动将该规范转换为样板代码。<p>但是接下来你需要添加业务逻辑、身份验证等内容。<p>当API规范发生变化时,你该怎么办?你会重新运行生成器吗?如果不这样做,你如何确保你的代码符合规范?
查看原文
Imagine you start from an API &quot;contract&quot; like a Swagger specification.<p>You use a generator to automatically convert that spec to boilerplate code. But then you have to add business logic, authentication and so on.<p>When the API spec change, what do you do? Do you re run the generator? If not, how can you enforce your code is compliant with the spec?