OpenAPI generator is a tool we can use to generate working code artifacts based on API specs based on OpenAPI format. One benefit of using this is to ensure that all systems (e.g., service, backend, frontend, etc.) rely on a single source of truth (the API specs).
To get started, install the CLI tool: npm install @openapitools/openapi-generator-cli -g
The generator requires JRE installed; otherwise, if you run openapi-generator-cli version, it will show Error: /bin/sh: 1: java: not found.
However, I opt to install JDK instead. To install JDK on your Debian/Ubuntu environment: sudo apt-get update && sudo apt-get install -y openjdk-17-jdk
Now, we can use the generator.
java -version
openjdk version "17.0.18" 2026-01-20
openapi-generator-cli version
7.19.0