
[英]cleanest way to glue generated Flask app code (Swagger-Codegen) to backend implementation
[英]How to generate complex ORM code and REST API with swagger-codegen?
swagger-editor 内置了 codegen 工具,所以我可以用它生成服务器端代码。 我尝试了宠物店的例子,它有效。 然后我的下一个尝试是考虑数据持久性。 我用谷歌搜索,我经常使用 Python/Java,所以我专注于这两种语言。
首先我想试试 python。
在swagger-codegen工具中,依赖flask/connexion/flask-swagg等,所以我觉得connexion对我来说是一个好的开始。 However when I read the generated code, I found that swagger-codegen inherits swagger data Model itself, and I can use connexion with SQLAlchemy to implement db ORM. 例如Connexion-Example 。 Also I found SAFRS a good place to go, with this I can easily expose all the DB models as REST API, so that I don't need to create duplicate ORM code myself. 所以我试图找到一些可以帮助我的建议,因为现在我被困住了。
我想创建一个 API 规范文件(yaml 或 json 在 swagger-editor 中),以及 DB model。 然后生成服务器端代码,包括 DB model 和 SQLAlchemy,所有 DB CRUD 操作都为 RESTA8D6347CEDCA084。 我的第一个想法是在 swagger-codegen 中修改 swagger 模板,以使用 SAFRS 或 connexion。 但我想在这里讨论一下,以获得一些关于你如何管理这种工作的建议?
谢谢。
安第斯山脉
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.