Generating code - adewg/ICAR GitHub Wiki

The ICAR Animal Data Exchange JSON Standards are meant to be used for automatic code generation. That means that you can download the specification, run a tool, and get a working implementation as a starting point.

In the ADE workgroup, we primarily use the openapi-generator by OpenAPITools but other tools compliant with the OpenAPI specification should work as well.

Here are some quick steps to get you up and running using the command line:

  1. Install the openapi-generator, following the instructions on https://github.com/OpenAPITools/openapi-generator

In this case, we simply download the jar file: wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar -O openapi-generator-cli.jar

  1. Now, run java -jar openapi-generator-cli.jar list to see a list of all the generators that are available. Choose one from either the client or server perspective.

We assume here that you want to generate a client (consuming ICAR ADE api's) in Java.

  1. Choose which version of ADE you want. Currently we have the ADE-1 branch which contains the latest version 1.x.y. Or, you can choose the Develop branch, where the latest features are and what will become the next release.

We assume here that you want the ADE-1 branch.

  1. Run the generator: java -jar openapi-generator-cli.jar generate -g java --library native -i https://raw.githubusercontent.com/adewg/ICAR/ADE-1/url-schemes/exampleUrlScheme.json

This should give you a full Java project, including Maven and Gradle build scripts. Enjoy!

  1. Tweak to your liking: the -g java option defines what you want to generate. See the listing in step 2 for the options. The -i url contains the branch name (in this case ADE-1), you can replace that with Develop for the latest features.

Tip: see Versioning, -releases and branches for finding out which version we test against.