openapi-generator-cli
openapi-generator-cli copied to clipboard
[BUG] cli doesn't support JAVA_HOME, requires the java executable to be on the PATH
🐛 Bug Report:
Describe the bug
When running openapi-generator-cli
via NPM script:
Error: 'java' is not recognized as an internal or external command, operable program or batch file.
Steps to Reproduce
Have a clean operating system, with no Java installation.
"Install" the JDK by downloading and then unzipping the portable zip archive, then set JAVA_HOME
to that location.
Expected behavior
Like all other tooling in the Java ecosystem, openapi-generator-cli should try to execute the JDK via $JAVA_HOME/bin/java
before falling back to looking for the java executable on the path.
Operation System (please complete the following information):
- OS: Windows (problem exists on any other OS too)
- Version 2.5.1
Package System (please complete the following information):
- whatever NPM comes by default with Node.js 16.17.0
Additional context
This is a problem for developers working in more complex environments where they might need to work on multiple separate projects that require different JDK versions. It's not viable to always be swapping the global path between different JDK installations.
This is actually a thing in the Node ecosystem too, you can (and people do) install and run Node via a portable archive, without adding the node / npm executables to the global path.
If JAVA_HOME
support is added, the readme should be updated to reflect that users don't necessarily need to have java
on their PATH
any more.
Workaround
Use a different tool to invoke openapi-generator
, that does support JAVA_HOME
.
I use Gradle, with wrapper for the gradlew
script and the org.openapi.generator
Gradle plugin to call the OpenAPI Generator. Then hook it up to your NPM project via pre
scripts:
"generate-api": "../gradlew openApiGenerate",
"prestart": "npm run generate-api",
"start": "react-scripts start",
"prebuild": "npm run generate-api",
"build": "react-scripts build",
:tada: This issue has been resolved in version 2.10.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: