-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_api.sh
executable file
·28 lines (20 loc) · 791 Bytes
/
generate_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
#/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
if [[ "$(git diff --stat)" != "" ]]; then
echo 'git repository is dirty, exiting.'
exit 1
fi
version=$(cat ./openapi.json | jq -r '.info.version')
version_numbers=$(echo $version | sed s/^v//)
# replace version in setup.py and setup-pandas2.py
sed "s/version=.*,$/version=\"$version_numbers\",/" -i setup.py
sed "s/version=.*,$/version=\"${version_numbers}-dev\",/" -i setup-pandas2.py
# regenerate the whole python project
rm -rf priceloop-api-python
openapi-python-client generate --path openapi.json --config config.yml
# copy over python code from generated project
rm -rf priceloop_api
cp -r priceloop-api-python/priceloop_api priceloop_api
# rescue custom files
git checkout priceloop_api/priceloop