github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/enhancements/2444/gen-fixtures.sh (about) 1 #! /bin/bash 2 if [[ ${1} == "--clean" ]] ; then 3 clean=1 4 fi 5 continueOnError= 6 # A small utility to build fixture servers 7 testcases="${testcases} fixture-2244.yaml" 8 export SWAGGER_DEBUG=1 9 for opts in "" "--with-flatten=full" "--with-expand" ; do 10 for testcase in ${testcases} ; do 11 grep -q discriminator ${testcase} 12 discriminated=$? 13 if [[ ${discriminated} -eq 0 && ${opts} == "--with-expand" ]] ; then 14 echo "Skipped ${testcase} with ${opts}: discriminator not supported with ${opts}" 15 continue 16 fi 17 spec=${testcase} 18 testcase=`basename ${testcase}` 19 if [[ -z ${opts} ]]; then 20 target=./gen-${testcase%.*}-minimal 21 elif [[ ${opts} == "--with-flatten=full" ]] ; then 22 target=./gen-${testcase%.*}-flatten 23 else 24 target=./gen-${testcase%.*}-expand 25 fi 26 serverName="codegensrv" 27 rm -rf ${target} 28 mkdir ${target} 29 echo "Server generation for ${spec} with opts=${opts}" 30 serverName="nrcodegen" 31 swagger generate server --skip-validation ${opts} --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1 32 # 33 if [[ $? != 0 ]] ; then 34 echo "Generation failed for ${spec}" 35 if [[ ! -z ${continueOnError} ]] ; then 36 failures="${failures} codegen:${spec}" 37 continue 38 else 39 exit 1 40 fi 41 fi 42 echo "${spec}: Generation OK" 43 if [[ ! -d ${target}/models ]] ; then 44 echo "No model in this spec! Continue building server" 45 fi 46 if [[ -d ${target}/cmd/${serverName}"-server" ]] ; then 47 (cd ${target}/cmd/${serverName}"-server"; go build) 48 #(cd ${target}/models; go build) 49 if [[ $? != 0 ]] ; then 50 echo "Build failed for ${spec}" 51 if [[ ! -z ${continueOnError} ]] ; then 52 failures="${failures} build:${spec}" 53 continue 54 else 55 exit 1 56 fi 57 fi 58 echo "${spec}: Build OK" 59 if [[ -n ${clean} ]] ; then 60 rm -rf ${target} 61 fi 62 fi 63 done 64 done 65 if [[ ! -z ${failures} ]] ; then 66 echo ${failures}|tr ' ' '\n' 67 else 68 echo "No failures" 69 fi 70 exit