forked from BitMEX/api-connectors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
49 lines (41 loc) · 1.52 KB
/
build.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
#!/bin/bash -ex
# Builds new versions of client libraries using swagger-codegen
T="$(date +%s)"
DIR=$(pwd)
CLIENTS=$DIR/auto-generated
DOCS=$DIR/docs
CLI=$DIR/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar
RESOURCES="https://www.bitmex.com/api/explorer/swagger.json"
declare -a CLIENTLANGS=(android akka-scala clojure csharp java javascript go objc php python ruby scala swagger swagger-yaml swift4 typescript-node cpprest qt5cpp)
# FIXME: php and typescript-node appear to have case-sensitive FS problems
declare -a DOCLANGS=(html dynamic-html)
echo "Getting swagger json..."
rm $DIR/swagger.json || true
curl --compressed $RESOURCES | \
# Remove `--`, which is an invalid comment in XML and the generator happily puts into XML comments
sed s/--//g | \
# Pretty-print
jq '.' > \
$DIR/swagger.json
echo "Creating output folders..."
rm -rf $CLIENTS
rm -rf $DOCS
for clientLang in "${CLIENTLANGS[@]}"; do
mkdir -p $CLIENTS/$clientLang
done
echo "Checking out newest swagger-codegen..."
git submodule init
git submodule update --recursive --remote
echo "Building latest swagger-codegen..."
cd swagger-codegen
mvn package -DskipTests
echo "Generating client libraries..."
for clientLang in "${CLIENTLANGS[@]}"; do
java -jar $CLI generate -i $DIR/swagger.json -l $clientLang -o $CLIENTS/$clientLang
done
echo "Generating static docs..."
for docLang in "${DOCLANGS[@]}"; do
java -jar $CLI generate -i $DIR/swagger.json -l $docLang -o $DOCS/$docLang
done
T="$(($(date +%s)-T))"
echo "Done in ${T} seconds."