summaryrefslogtreecommitdiff
path: root/scripts/buildSwaggerClient.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/buildSwaggerClient.sh')
-rwxr-xr-xscripts/buildSwaggerClient.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/buildSwaggerClient.sh b/scripts/buildSwaggerClient.sh
new file mode 100755
index 00000000..2e721206
--- /dev/null
+++ b/scripts/buildSwaggerClient.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+SWAGGER_MENSHEN_COMMIT=d50eef262620f58c9e3b39a4e5f0cdb7797357a1
+SCRIPT_DIR=$(dirname "$0")
+BASE_DIR="$SCRIPT_DIR/.."
+
+GREEN='\033[0;32m'
+NC='\033[0m'
+
+echo -e "${GREEN}Creating swagger build directory${NC}"
+mkdir -p ${BASE_DIR}/app/build/swagger
+
+echo -e "${GREEN}Fetching swagger specification for menshen commit ${SWAGGER_MENSHEN_COMMIT}${NC}"
+curl https://0xacab.org/leap/menshen/-/raw/${SWAGGER_MENSHEN_COMMIT}/api/swagger.yaml > ${BASE_DIR}/app/build/swagger/swagger.yaml
+
+echo -e "${GREEN}Pulling swagger-codegen docker image${NC}"
+docker pull swaggerapi/swagger-codegen-cli
+cd $BASE_DIR
+
+echo -e "${GREEN}Running swagger-codegen-cli in docker${NC}"
+docker run --rm --user $(id -u):$(id -g) -v ${PWD}:/bitmask_android swaggerapi/swagger-codegen-cli generate \
+ -i /bitmask_android/app/build/swagger/swagger.yaml \
+ -l java \
+ -o /bitmask_android/app/build/swagger \
+ -DuseAndroidMavenGradlePlugin=true \
+ -DhideGenerationTimestamp=true
+
+echo -e "${GREEN}Copying generated model classes${NC}"
+cp -r app/build/swagger/src/main/java/io/swagger/client/model/* app/src/main/java/io/swagger/client/model/.
+cp app/build/swagger/src/main/java/io/swagger/client/JSON.java app/src/main/java/io/swagger/client/.
+
+echo -e "${GREEN}Cleanup${NC}"
+#rm -r app/build/swagger/ \ No newline at end of file