Possible to change the package name when generating client code

user79074 picture user79074 · May 5, 2016 · Viewed 10k times · Source

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

I can't see any obvious way of specifying something different. Can this be done?

Answer

Joy picture Joy · Oct 12, 2017

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…