Use swagger codegen cli to generate Node.js server with models

感情迁移 提交于 2019-12-12 04:17:11

问题


I have a swagger.yaml and just installed the swagger-codegen on my Mac. I want to generate a Node.js server including the models described in the swagger.yaml from the command line. I tried:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i swagger.yaml -l nodejs -o export/nodejs -Dmodels

and

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i swagger.yaml -l nodejs -o export/nodejs -Dmodels -DsupportingFiles

But the output is always the same WITHOUT the models:

What is wrong?


回答1:


As opposed to previous versions of swagger-node (fka swagger-node-express), the swagger definition is used as the source of truth. There is no model file generated for each model in the application. So the -Dmodels will have no effect.

You can generate the response payload and send it back, and even configure the framework to validate that it follows the definition.



来源:https://stackoverflow.com/questions/34559725/use-swagger-codegen-cli-to-generate-node-js-server-with-models

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!