This repository has been archived by the owner on Dec 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
create.sh
executable file
·95 lines (83 loc) · 2.64 KB
/
create.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# currently must be available locally as we need to do "sed" stuff
SPEC=https://docs.graphhopper.com/openapi.yaml
DIR=.
VERSION=0.13.0
SW_VERSION=3.0.11
FILE=swagger-codegen-cli-$SW_VERSION.jar
NAME=directions-api-client
GROUP=com.graphhopper
if [[ ! -s $FILE ]]; then
wget https://graphhopper.com/public/misc/$FILE -O $FILE
if [[ ! -s $FILE ]]; then
wget http://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/$SW_VERSION/$FILE -O $FILE
if [[ ! -s $FILE ]]; then
curl http://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/$SW_VERSION/$FILE -O $FILE
fi
fi
fi
file_size_kb=$(du -k "$FILE" | cut -f1)
if [[ $file_size_kb -lt 1000 ]]; then
echo corrupt file $FILE, remove it, ensure host exists and try again
exit
fi
function create {
LANG=$1
CONFIG=""
ADD_PARAMS=""
case "$LANG" in
java)
PKG="com.graphhopper.directions.api.client"
CONFIG="--artifact-version $VERSION --api-package $PKG.api --invoker-package $PKG --model-package $PKG.model --artifact-id $NAME --group-id $GROUP --library okhttp-gson -DhideGenerationTimestamp=true"
;;
ruby)
CONFIG="-DgemName=$NAME -DmoduleName=GraphHopperClient -DgemVersion=$VERSION"
;;
go)
# CONFIG="-t modules/swagger-codegen/src/main/resources/go"
ADD_PARAMS="-DpackageName=graphhopper"
;;
swift)
CONFIG="-DprojectName=GraphHopper"
;;
javascript)
CONFIG="-t modules/swagger-codegen/src/main/resources/Javascript"
;;
haskell)
;;
r)
ADD_PARAMS="-DpackageName=GraphHopper"
;;
php)
CONFIG="--artifact-version $VERSION --git-repo-id $NAME --git-user-id graphhopper --api-package $NAME"
;;
csharp)
VER=$(echo $VERSION | cut -d'-' -f 1)
ADD_PARAMS="-DpackageName=GraphHopper,packageVersion=$VER"
;;
*)
;;
esac
# This is ugly. The name of our endpoint is "Matrix API" and swagger codegen creates classes like MatrixApiApi and we just want MatrixApi for backward compatibility
curl $SPEC | sed -e 's/Matrix API/Matrix/g' | sed -e 's/Routing API/Routing/g' | sed -e 's/Geocoding API/Geocoding/g' | sed -e 's/Route Optimization API/Route Optimization/g' | sed -e 's/Map Matching API/Map Matching/g' | sed -e 's/Isochrone API/Isochrone/g' > openapi.yaml
SH="java -jar $FILE generate -i openapi.yaml -l $LANG $CONFIG -o $DIR/$LANG $ADD_PARAMS"
echo $SH
$SH
}
LANG=$1
if [[ "$LANG" != "" ]]; then
create $LANG
exit 0
else
echo "creating all clients"
# the JS client is just too large and not recommended so use nodejs-server
# create javascript -> nodejs-server
create csharp
create java
create kotlin-client
create nodejs-server
create php
create python
create scala
create swift4
fi