github.com/ryanbennettvoid/go-swagger@v0.18.1-0.20190104015444-3854bbbe2392/hack/run-canary.sh (about) 1 #!/bin/bash 2 # 3 # A small utility to generate clients and servers on 4 # well known specifications. 5 6 # Bails on any command failure 7 set -e -o pipefail 8 9 cd $(git rev-parse --show-toplevel) 10 11 if [[ "${SWAGGER_BIN}" ]]; then 12 cp "${SWAGGER_BIN}" /go/bin/ 13 fi 14 15 if ! command -v swagger >/dev/null 2>&1; then 16 echo "can't find swagger in the PATH" 17 exit 1 18 fi 19 20 for dir in fixtures/canary/* 21 do 22 [ ! -d "$dir" ] && continue 23 echo "validating '$dir'" 24 pushd "$dir" > /dev/null 25 26 case $dir in 27 "fixtures/canary/bitbucket.org") 28 # bitbucket.org generates wrong model 29 client=false 30 server=false 31 echo "$dir is disabled for now" 32 ;; 33 "fixtures/canary/kubernetes"|"fixtures/canary/docker") 34 # docker has an invalid spec with duplicate operationIds. Generates on docker-fixed 35 # kubernetes uses unsupported media type options (issue#1377) 36 client=true 37 server=false 38 echo "$dir is disabled for server generation now (only client is generated)" 39 ;; 40 *) 41 client=true 42 server=true 43 ;; 44 esac 45 if [[ "${client}" == "true" ]] ; then 46 rm -rf client models restapi cmd 47 echo "generating client for $dir..." 48 swagger generate client --skip-validation --quiet 49 go test -vet off ./... 50 fi 51 52 if [[ "${server}" == "true" ]] ; then 53 echo "generating server for $dir..." 54 swagger generate server --skip-validation --quiet 55 go test -vet off ./... 56 fi 57 set +e 58 popd > /dev/null || true 59 set -e 60 done