This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SUBMARINE-687. Create bash script to auto-generate typescript-sdk and…
… fix minor bugs ### What is this PR for? It is a sub-task under [SUBMARINE-686. [Umbrella] Intergrate swagger to frontend](https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-686?filter=allopenissues) 1. To integrate swagger to the frontend, I wrote a script to auto-generate typescript-angular sdk. 2. Fix bug in `gen-sdk.sh` 3. Improve doc ### How should this be tested? https://github.com/ByronHsu/submarine/actions/runs/386715559 ### What type of PR is it? [Improvement] ### What is the Jira issue? https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-687 Author: ByronHsu <[email protected]> Closes #464 from ByronHsu/SUBMARINE-687 and squashes the following commits: dc8adbd [ByronHsu] Remove comments f7a8468 [ByronHsu] create gen-ts-sdk and fix minor bugs
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters