forked from square/connect-api-specification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-sdks
executable file
·53 lines (44 loc) · 1.17 KB
/
generate-sdks
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
#!/usr/bin/env sh
set -eu
if [ -n "${SWAGGER_CMD+1}" ]
then
echo "Using Swagger command \`${SWAGGER_CMD}\`."
else
if ! which swagger-codegen
then
echo "swagger-codegen is either not installed on this system or is"\
"unavailable through the \$PATH."
while true; do
printf "Install it from Homebrew now? [y/N] "
read -r yn
case "$yn" in
[Yy]* ) break;;
[Nn]* ) exit;;
'' ) exit;;
esac
done
echo "Updating Homebrew and then installing swagger-codegen"
brew update
brew install swagger-codegen
fi
SWAGGER_CMD="swagger-codegen"
fi
target_language="${1:-}"
generate_for_language() {
$SWAGGER_CMD generate \
--input-spec "./api.json" \
--lang "$1" \
--config "./swagger-config/config-$1.json" \
--template-dir "./swagger-templates/$1" \
--output "./swagger-out/$1"
}
if [ -n "$target_language" ]
then
generate_for_language "$target_language"
else
languages=$(ls swagger-templates)
for lang in $languages
do
generate_for_language "$lang"
done
fi