Reputation: 137
While generating the server stub, in my case spring type, I can specify the packages for api
, model
and invoker
. And it works without problems.
I need also change the package for generated supporting files. I'm not able to find the way how to do that. The default package is io.swagger.configuration
which needs to be changed in my case.
Upvotes: 2
Views: 3639
Reputation: 2110
The Swagger-Codegen support the option when generate code. The detail you can check the official wiki section customizing-the-generator
Let me make an example by using generation to jersey2
java -jar ${your_swagger_codegen_jar} generate \
-i ${your_api_url} \
-l java --library=jersey2 \
-o ${your_output_folder} \
-c ./config.json
The config.json
{
"hideGenerationTimestamp":true,
"groupId":"science.mengxin",
"artifactId":"test-api-client",
"artifactDescription":"test-api-client",
"developerName":"xin.meng",
"developerEmail":"[email protected]",
"developerOrganization":"mengxin",
"developerOrganizationUrl":"mengxin.science",
"licenseName":"mengxin.science",
"invokerPackage":"science.mengxin.test.cloud.client",
"apiPackage":"science.mengxin.test.cloud.client.api",
"modelPackage":"science.mengxin.test.cloud.client.model"
}
Then check pom.xml
and source code of generated code, you will find all these parameters has been customised.
The more options to customise the generated code can be found in the swagger-codegen book: English, Chinese
Upvotes: 3