forked from ManageIQ/nutanix_clustermgmt-sdk-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi-generate
More file actions
executable file
·26 lines (21 loc) · 1.16 KB
/
openapi-generate
File metadata and controls
executable file
·26 lines (21 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
if [ -z "$INPUT_SPEC_VERSION" ]; then
echo "ERROR: INPUT_SPEC_VERSION must be set"
exit 1
fi
if [ -z "$OPENAPI_GENERATOR_JAR" ]; then
# Detect the latest version of the openapi-generator-cli package
version=`wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml -O - 2>/dev/null | xq -x "//metadata/versioning/latest"`
OPENAPI_GENERATOR_JAR=openapi-generator-cli-$version.jar
# Download the openapi-generator-cli jar if we don't already have it locally
if [ ! -f "$OPENAPI_GENERATOR_JAR" ]; then
echo "Downloading '$OPENAPI_GENERATOR_JAR'..."
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$version/$OPENAPI_GENERATOR_JAR
fi
fi
# Clear out any existing files in paths that are autogenerated to prevent deleted files
# from remaining after running the generate
rm -rf ./docs ./lib ./spec
# Generate the gem from the current openapi-spec
input_spec=https://developers.nutanix.com/api/v1/namespaces/clustermgmt/versions/$INPUT_SPEC_VERSION/yaml
java -jar $OPENAPI_GENERATOR_JAR generate --input-spec $input_spec --skip-validate-spec --generator-name ruby --config .openapi-config.json