Search the Aria Knowledgebase for
User Documentation, APIs, SDKs, and more!



 

Home > Aria SDKs > Generating Client SKDs from Swagger

Generating Client SKDs from Swagger

Generating Client SDKs from Swagger

The Swagger SDKs can be generated in two ways. One way is to generate them using a maven build script with the swagger-codegen maven plugin. The other way is to generate them directly via Java.

Generating Client SDKs with the Swagger-Codegen-Maven-Plugin

Another easy way to generate the SDks in a repeatable way is by using the swagger-codegen-maven-plugin. Using the maven plugin allows the ability to configure the client generation settings so it can be invoked in a repeatable way. In addition to running the generation from a command line, this plugin also allows the ability to generate the SDK from within a maven-supported IDE (like eclipse or IntelliJ)

Prerequisites for generating the SDK:

To generate the SDK, configure a maven build.xml to invoke the generation (see example maven client generation script below as a reference). Ensure that the build.xml file is configured to use the correct settings for the following values in the swagger-codegen maven-plugin configuration section. Some of the configuration parameters are as follows:

  • inputSpec - points to the correct location/name of the target swagger file.
  • language - designates the target code language for the generated SDK (java, php, ruby, etc.).
  • output - designates the target directory for the generated SDK files.

More configuration parameters can be found here.

Then the maven script can be executed as:

mvn clean install

example-client-generation-script.xml is our sample maven script for generating the Aria client with the swagger-codegen maven plugin.

Additional details on the swagger-codegen maven plugin can be found on its github site.

Generating the SDKs from the Java Command Line

Prerequisites for generating the SDK:

Obtaining / Building the generator jar:

git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
mvn clean package

The above script builds a swagger-codegen-cli.jar that is found in the modules/swagger-codegen-cli/target subdirectory. This jar will be used in the command to generate the swagger client.

Swagger Codegen can be directly invoked from a command line using a Java command with -D parameters.

java-jar ./swagger-codegen-2.2.1.jar generate \
-i .all_A7_13.0_swagger.json \
-I java \
-o ariaClient

The above example shows a couple of the generate command options:

  • -i is the reference to the swagger file that defines the client API.
  • -I is the type of programming language to generate the client in.
  • -o is the name of the subdirectory for the target client SDK files to be generated.

You can get the full list of available described command options using the help generate command:

java -jar swagger-codegen-cli.jar help generate

Additional details about the Java generate client functionality can be found on the swagger-api github page.

Last modified

Tags

This page has no custom tags.

Classifications

This page has no classifications.