This repository was archived by the owner on Apr 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgenapi.sh
executable file
·53 lines (44 loc) · 1.8 KB
/
genapi.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
#
# Copyright contributors to the Galasa project
#
# SPDX-License-Identifier: EPL-2.0
#
# Where is this script executing from ? Lets find out...
BASEDIR=$(dirname "$0");pushd $BASEDIR 2>&1 >> /dev/null ;BASEDIR=$(pwd);popd 2>&1 >> /dev/null
export ORIGINAL_DIR=$(pwd)
cd "${BASEDIR}"
# Allow an environment variable to over-ride the location of the openapi generator cli tool
# otherwise set a default.
if [[ -z $OPENAPI_GENERATOR_CLI_JAR ]]; then
export OPENAPI_GENERATOR_CLI_JAR=~/openapi/openapi-generator-cli.jar
echo "The location of the open generator jar is not specified. Defaulting it to ${OPENAPI_GENERATOR_CLI_JAR}"
echo "Set the OPENAPI_GENERATOR_CLI_JAR environment variable to over-ride this setting."
exit 1
fi
# Make sure that the openapi generator cli tool is present where we expect.
if [[ ! -e ${OPENAPI_GENERATOR_CLI_JAR} ]]; then
echo "The openapi generator is not found at ${OPENAPI_GENERATOR_CLI_JAR}."
echo "Download it and set the OPENAPI_GENERATOR_CLI_JAR environment variable to point to it."
exit 1
fi
export OPENAPI_YAML_FILE="${BASEDIR}/build/dependencies/openapi.yaml"
if [[ ! -e ${OPENAPI_YAML_FILE} ]]; then
echo "This build requires that the galasa.dev/framework repository is checked-out to ${BASEDIR}"
exit 1
fi
# Use the tool to generate our api client code.
java -jar ${OPENAPI_GENERATOR_CLI_JAR} generate \
-i ${OPENAPI_YAML_FILE} \
-g go \
-o pkg/galasaapi \
--additional-properties=packageName=galasaapi \
--additional-properties=isGoSubmodule=true \
--global-property=apiTests=false
rc=$?
if [[ "${rc}" != "0" ]]; then
echo "The openapi client code generator failed. rc=${rc}"
exit 1
fi
echo "Folder ${BASEDIR}/cli/pkg/galasaapi has been generated with content inside"
echo "Note: This source code is never checked-in to github."