Possible to change the package name when generating client code

家住魔仙堡 提交于 2019-12-05 02:06:13

Step (1): Create a file config.json and add following lines and define package names:

{
    "modelPackage" : "com.xyz.model",
    "apiPackage" : "com.xyz.api"
}

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

Now, it will generate your java packages like com.xyz… instead of default one io.swagger.client…

Pradeepkumar Reddy

Run the following command to get information about the supported configuration options

java -jar swagger-codegen-cli.jar  config-help -l scala

This will give you information about supported by this generator (Scala in this example):

CONFIG OPTIONS

    sortParamsByRequiredFlag
        Sort method arguments to place required parameters before optional parameters. (Default: true)

    ensureUniqueParams
        Whether to ensure parameter names are unique in an operation (rename parameters that are not). (Default: true)

    modelPackage
        package for generated models

    apiPackage
        package for generated api classes

Next, define a config.json file with the above parameters:

{
   "modelPackage": "your package name",
   "apiPackage": "your package name"
}

And supply config.json as input to swagger-codegen using the -c flag.

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