Here you will find a guide for how to generate your own SDK with openAPI Generator from openAPI Tools.
The openAPI Generator is a tool that helps you generate clients, servers and documentation, in wide variety of programming languages and frameworks.
The complete list of supported generators can be found here.
The way it works:
- First you need to have a specification file (in yaml or json format) that describes your API.
- Then you specify in what programming language you want the generated code to be.
- Specify the output directory. This is where the generated code will be placed.
- Lastly, run the command to generate the code.
Install it on your project with the following commands:
npm install @openapitools/openapi-generator-cli
yarn add @openapitools/openapi-generator-cli
This example is for a nodejs project, for other package managers that the openApi Generator is available, please refer to their documantation.
Make sure that the installation proccess has completed successfully and then you are ready to generate some code.
Run the code generator
To start the code generator you need run the following command:
npx openapi-generator-cli generate -i <path/to/file/api.yaml> -g <generator name> -o <path/to/output_folder/>
yarn openapi-generator-cli generate -i <path/to/file/api.yaml> -g <generator name> -o <path/to/output_folder/>
There are various other flags available, with options that can found in the openAPI Generator documentation.
Run command breakdown
Here is a breakdown of what we are passing through to the above command:
-i <path/to/file/api.yaml>: the input directory and yaml file.
-g <generator name>: the language or framework you want the output to be in.
-o <path/to/output_folder/>: the output folder where you can find the resulting code after a successful run.
The Envizage APIs
Here you can find a list of all the available Envizage API specification files:
In the next sections we provide a simple example of what the generated outcome would be and how we can use it.