生成客户端代码时可以更改包名称 [英] Possible to change the package name when generating client code
问题描述
我正在使用 Swagger Edtior 为 API 生成客户端 Scala 代码.我粘贴了 json 然后做了一个 Generate Client/Scala.它给了我一个
I am generating the client scala code for an API using the Swagger Edtior. I pasted the json then did a Generate Client/Scala. It gives me a default root package of
io.swagger.client
io.swagger.client
我看不到任何明显的指定不同内容的方法.可以这样做吗?
I can't see any obvious way of specifying something different. Can this be done?
推荐答案
步骤 (1):创建文件 config.json 并添加以下行并定义包名称:
Step (1): Create a file config.json and add following lines and define package names:
{
"modelPackage" : "com.xyz.model",
"apiPackage" : "com.xyz.api"
}
步骤 (2):现在,将上述文件名与带有 -c 选项的 codegen 命令一起传递:
Step (2): Now, pass the above file name along with codegen command with -c option:
$ java -jar swagger-codegen-cli.jar generate -i path/swagger.json -l java -o Code -c path/config.json
现在,它会生成你的 java 包,比如 com.xyz…而不是默认的 io.swagger.client…
Now, it will generate your java packages like com.xyz… instead of default one io.swagger.client…
这篇关于生成客户端代码时可以更改包名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!