github.com/hyperledger/aries-framework-go@v0.3.2/scripts/generate-openapi-demo-specs.sh (about) 1 #!/bin/bash 2 # 3 # Copyright SecureKey Technologies Inc. All Rights Reserved. 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 set -e 8 9 BASE_SPEC_LOC="${SPEC_PATH}/openAPI.yml" 10 DEMO_PATH="${OPENAPI_DEMO_PATH}" 11 IMAGE="${DOCKER_IMAGE:-quay.io/goswagger/swagger}" 12 IMAGE_VERSION="${DOCKER_IMAGE_VERSION:-latest}" 13 OUTPUT_PATH="$DEMO_PATH/specs" 14 15 if [ ! -f "$BASE_SPEC_LOC" ]; then 16 echo "'$BASE_SPEC_LOC' doesn't exists" 17 exit 1 18 fi 19 20 set -o allexport 21 [[ -f $DEMO_PATH/.env ]] && source $DEMO_PATH/.env 22 set +o allexport 23 24 mkdir -p $OUTPUT_PATH 25 26 # generate sub specs using .env entries and mix them using 'swagger mixin' 27 while IFS='=' read -r name value ; do 28 if [[ $name == *'_API_HOST' ]]; then 29 result="${!name}" 30 echo "host: $result" > $OUTPUT_PATH/$result.yml 31 command="mixin $BASE_SPEC_LOC $OUTPUT_PATH/${result}.yml -o $OUTPUT_PATH/openapi-${result}.yml --format yaml" 32 docker run --rm -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) ${IMAGE}:${IMAGE_VERSION} $command 33 rm -rf $OUTPUT_PATH/$result.yml 34 fi 35 done < <(env) 36 37