-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-api.sh
68 lines (58 loc) · 1.23 KB
/
gen-api.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
STEP="all"
case "$1" in
"gen-openapi")
STEP="$1"
;;
"gen-client")
STEP="$1"
;;
"replace")
STEP="$1"
;;
esac
RMS_HOME="/c/reps/msa-rms"
RMS_SERVER_HOME="${RMS_HOME}/msa-rms-apigateway"
GEN_API_HOME="/c/VSCode_workspaces/rms-generated-client-js"
cd $RMS_SERVER_HOME
./maven-all.sh gen-openapi
if [ $? -ne 0 ]; then
echo "gen-openapi fail!!!"
exit $?
fi
if [ "$STEP" = "gen-openapi" ]; then
echo "### end ${STEP} ###"
exit 0
fi
#cd $RMS_HOME
if [ -f ./target/generated-oas/openapi.yml ]; then
if [ ! -d ./temp ]; then
mkdir ./temp
fi
cp -f ./target/generated-oas/openapi.yml ./temp
OAS_FILE_PATH="temp/openapi.yml"
fi
mvn -Pgen-js-client clean openapi-generator:generate -Dopenapi.file.path=$OAS_FILE_PATH
if [ $? -ne 0 ]; then
echo "gen-client fail!!!"
exit $?
fi
if [ "$STEP" = "gen-client" ]; then
echo "### end ${STEP} ###"
exit 0
fi
if [ ! -e $GEN_API_HOME ]; then
echo "${GEN_API_HOME} not exist!!"
exit 1;
fi
rm -rf ${GEN_API_HOME}/*
cp -rf ./target/generated-sources/openapi/. $GEN_API_HOME
cp -f $OAS_FILE_PATH $GEN_API_HOME
rm -rf ./temp
if [ "$STEP" = "replace" ]; then
echo "### end ${STEP} ###"
exit 0
fi
cd $GEN_API_HOME
npm install
echo "### end ${STEP} ###"