-
Notifications
You must be signed in to change notification settings - Fork 276
/
Copy pathgenerate.sh
executable file
·57 lines (47 loc) · 1.93 KB
/
generate.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
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SED_NAME="sed"
PACKAGE_NAME="linux-x64"
if [[ $OSTYPE == 'darwin'* ]]; then
SED_NAME="gsed"
PACKAGE_NAME="osx-x64"
fi
# TODO move the kiota-version.csproj to it's own folder?
VERSION=$(cat $SCRIPT_DIR/kiota-version.csproj | grep Version | sed -n 's/.*Version="\([^"]*\)".*/\1/p')
URL="https://github.com/microsoft/kiota/releases/download/v${VERSION}/${PACKAGE_NAME}.zip"
# COMMAND="kiota"
# if ! command -v $COMMAND &> /dev/null
# then
# echo "System wide kiota could not be found, using local version"
if [[ ! -f $SCRIPT_DIR/kiota_tmp/kiota ]]
then
echo "Local kiota could not be found, downloading"
rm -rf $SCRIPT_DIR/kiota_tmp
mkdir -p $SCRIPT_DIR/kiota_tmp
curl -sL $URL > $SCRIPT_DIR/kiota_tmp/kiota.zip
unzip $SCRIPT_DIR/kiota_tmp/kiota.zip -d $SCRIPT_DIR/kiota_tmp
chmod a+x $SCRIPT_DIR/kiota_tmp/kiota
fi
COMMAND="$SCRIPT_DIR/kiota_tmp/kiota"
# fi
rm -rf $SCRIPT_DIR/pkg/registryclient-v2
mkdir -p $SCRIPT_DIR/pkg/registryclient-v2
rm -rf $SCRIPT_DIR/pkg/registryclient-v3
mkdir -p $SCRIPT_DIR/pkg/registryclient-v3
cp $SCRIPT_DIR/../common/src/main/resources/META-INF/openapi-v2.json $SCRIPT_DIR/v2.json
cp $SCRIPT_DIR/../common/src/main/resources/META-INF/openapi.json $SCRIPT_DIR/v3.json
# Hask to overcome https://github.com/microsoft/kiota/issues/3920
$SED_NAME -i 's/NewComment/DTONewComment/' $SCRIPT_DIR/v2.json
$SED_NAME -i 's/NewComment/DTONewComment/' $SCRIPT_DIR/v3.json
$COMMAND generate \
--language go \
--openapi $SCRIPT_DIR/v2.json \
--clean-output \
-o $SCRIPT_DIR/pkg/registryclient-v2 \
--namespace-name github.com/apicurio/apicurio-registry/go-sdk/pkg/registryclient-v2
$COMMAND generate \
--language go \
--openapi $SCRIPT_DIR/v3.json \
--clean-output \
-o $SCRIPT_DIR/pkg/registryclient-v3 \
--namespace-name github.com/apicurio/apicurio-registry/go-sdk/pkg/registryclient-v3