Skip to content

Commit 483414b

Browse files
Use openapi-generator-cli jar directly instead of npm
1 parent 9bab5ce commit 483414b

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

generate-client.sh

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#
5959
# Output log: generate-client.log (overwritten on each run)
6060
#
61-
# Prerequisites: Node.js/npm, Java 25, Maven, Perl
61+
# Prerequisites: Java 25, Maven, Perl (Node.js/npm optional — JAR fallback used if absent)
6262
#
6363

6464
set -euo pipefail
@@ -92,24 +92,16 @@ LOG_FILE="$SCRIPT_DIR/generate-client.log"
9292
# Log everything to file and stdout
9393
exec > >(tee "$LOG_FILE") 2>&1
9494

95-
# Initialize nvm if available
96-
NVM_DIR="$HOME/.nvm"
97-
if [ -s "$NVM_DIR/nvm.sh" ]; then
98-
. "$NVM_DIR/nvm.sh"
99-
fi
100-
101-
# Ensure openapi-generator-cli is available
102-
if ! command -v openapi-generator-cli &> /dev/null; then
103-
echo "openapi-generator-cli not found. Installing via npm..."
104-
105-
if ! command -v npm &> /dev/null; then
106-
echo "Error: npm is not installed. Please install Node.js/npm first."
107-
exit 1
108-
fi
95+
OPENAPI_GENERATOR_VERSION="7.20.0"
96+
GENERATOR_JAR="$SCRIPT_DIR/.cache/openapi-generator-cli-${OPENAPI_GENERATOR_VERSION}.jar"
10997

110-
npm install -g @openapitools/openapi-generator-cli
111-
echo "openapi-generator-cli installed successfully."
98+
if [ ! -f "$GENERATOR_JAR" ]; then
99+
echo "Downloading openapi-generator-cli ${OPENAPI_GENERATOR_VERSION}..."
100+
mkdir -p "$SCRIPT_DIR/.cache"
101+
curl -fSL -o "$GENERATOR_JAR" \
102+
"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${OPENAPI_GENERATOR_VERSION}/openapi-generator-cli-${OPENAPI_GENERATOR_VERSION}.jar"
112103
fi
104+
openapi-generator-cli() { java -jar "$GENERATOR_JAR" "$@"; }
113105

114106
generate() {
115107
local edition="$1"

0 commit comments

Comments
 (0)