I have downloaded the Swagger Editor
and run it locally from localhost:3001
. I imported my .yaml
file from local system. Then I clicked on Generate Server
and I choose a jaxrs
. When I opened a random java file I can see:
package io.swagger.model;
I have more then 30 java classes and I don't want to change it manually, because my .yaml
maybe change in future. Is there any possibility to change it, to be for example:
package my.funny.package.model;
//Edit:
I downloaded Swagger Editor
from this swagger-editor and run it using code snipped from Contribute
section. In my folder files I can't find a .jar
file from suggested post.
Swagger Editor uses Swagger Codegen (specifically, its online version at http://generator.swagger.io) to generate the client and server code. It runs the Codegen with the default settings. If you want to customize code generation, you'll need to run the Codegen directly.
Swagger Codegen has a command-line version, swagger-codegen-cli.jar
. There are several ways to install it depending on your operating system. One way is to download the JAR file from Maven Central: http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/
You can run the codegen as follows:
java -jar swagger-codegen-cli.jar generate
-i http://petstore.swagger.io/v2/swagger.json
-l jaxrs
-o Petstore-Jaxrs
-DapiPackage=my.funny.package.model
Custom options, such as the package name, can be specified directly in the command line using -D{optionName}={optionValue}
(as shown above), or using a config file as explained here.
To list all options a specific generator supports, use:
java -jar swagger-codegen-cli.jar config-help -l jaxrs
Disclosure: I work for the company that develops SwaggerHub.
If you use SwaggerHub instead of Swagger Editor to write and store your API definitions, it lets you customize Codegen options before you download the code.