cd `mktemp -d /tmp/codegen.XXXXXXXX`;
git clone https://github.com/swagger-api/swagger-codegen.git;
cd swagger-codegen;
mvn package;
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar meta -o output/myLibrary -n FooBarGen -p com.foo.example.generated;
mvn clean package -f output/myLibrary/pom.xml;
java -cp output/myLibrary/target/FooBarGen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen;
java -cp output/myLibrary/target/FooBarGen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
io.swagger.codegen.SwaggerCodegen generate -l FooBarGen\
-i http://petstore.swagger.io/v2/swagger.json \
-o myClient;
# To view the debug operations:
java -cp output/myLibrary/target/FooBarGen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -l FooBarGen -i http://petstore.swagger.io/v2/swagger.json -o myOutput -DdebugOperations=true
java -cp output/myLibrary/target/FooBarGen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen config-help -l FooBarGen
output:
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)
First, create a config json file.
echo '{"sortParamsByRequiredFlag":false}' > /tmp/FooBarGen-config.json;
Second, pass this file to the codegen generage command using the -c
flag
java -cp output/myLibrary/target/FooBarGen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
io.swagger.codegen.SwaggerCodegen generate -l FooBarGen\
-i http://petstore.swagger.io/v2/swagger.json \
-o myClient \
-c /tmp/FooBarGen-config.json;