You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@submarine.apache.org by GitBox <gi...@apache.org> on 2020/11/27 14:43:19 UTC

[GitHub] [submarine] jiwq commented on a change in pull request #464: SUBMARINE-687. Create bash script to auto-generate typescript-sdk and fix minor bugs

jiwq commented on a change in pull request #464:
URL: https://github.com/apache/submarine/pull/464#discussion_r531639962



##########
File path: dev-support/pysubmarine/gen-ts-sdk.sh
##########
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FWDIR="$(cd "$(dirname "$0")"; pwd)"
+cd "$FWDIR"
+
+SUBMARINE_PROJECT_PATH="$FWDIR/../.."
+SWAGGER_JAR_URL="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar"
+SWAGGER_CODEGEN_JAR="openapi-generator-cli.jar"
+SWAGGER_CODEGEN_CONF="swagger_config.json"
+SWAGGER_CODEGEN_FILE="openapi.json"
+SDK_OUTPUT_PATH="sdk/typescript-angular"
+
+submarine_dist_exists=$(find -L "${SUBMARINE_PROJECT_PATH}/submarine-dist/target" -name "submarine-dist-*.tar.gz")
+# Build source code if the package doesn't exist.
+if [[ -z "${submarine_dist_exists}" ]]; then
+  cd "${SUBMARINE_PROJECT_PATH}"
+  mvn clean package -DskipTests
+  cd "$FWDIR" # go back to FWDIR after packaging
+fi
+
+echo "Generating openAPI 3.0 definition file ..."
+# TODO(pingsutw): generate openapi.json without starting submarine server
+bash ${SUBMARINE_PROJECT_PATH}/submarine-dist/target//submarine-dist-*/submarine-dist-*/bin/submarine-daemon.sh start getMysqlJar
+sleep 5
+rm openapi.json
+wget http://localhost:8080/v1/openapi.json
+bash ${SUBMARINE_PROJECT_PATH}/submarine-dist/target//submarine-dist-*/submarine-dist-*/bin/submarine-daemon.sh stop
+
+openapi_generator_cli_exists=$(find -L "${FWDIR}" -name "openapi-generator-cli*")
+if [[ -z "${openapi_generator_cli_exists}" ]]; then
+  echo "Downloading the swagger-codegen JAR package ..."
+  wget -O "${SWAGGER_CODEGEN_JAR}" "${SWAGGER_JAR_URL}"
+fi
+
+echo "Generating typescript-angular SDK for Submarine ..."
+rm -r sdk/
+java -jar ${SWAGGER_CODEGEN_JAR} generate \
+     -i "${SWAGGER_CODEGEN_FILE}" \
+     -g typescript-angular \
+     -o ${SDK_OUTPUT_PATH} \
+     -c ${SWAGGER_CODEGEN_CONF}
+
+# echo "Insert apache license at the top of file ..."
+# for filename in $(find ${SDK_OUTPUT_PATH}/submarine/experiment -type f); do
+#   echo "$filename"
+#   sed -i -e '1 e cat license-header.txt' "$filename"
+# done
+
+# echo "Move Experiment API to pysubmarine"
+# cp -r sdk/typescript-angular/submarine/experiment ${SUBMARINE_PROJECT_PATH}/submarine-sdk/pysubmarine/submarine/
+
+# echo "Fix typescript-angular SDK code style"
+# ${SUBMARINE_PROJECT_PATH}/submarine-sdk/pysubmarine/github-actions/auto-format.sh

Review comment:
       Thanks @ByronHsu for the contribution. If we don't need this comment we should better remove these. +1




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org