github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/bugs/1020/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 # Fixtures with models only 8 testcases="${testcases} fixture-1020.yaml" 9 for opts in "" "--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 if [[ ${testcase} == "../1479/fixture-1479-part.yaml" && ${opts} == "--with-expand" ]] ; then 18 echo "Skipped ${testcase} with ${opts}: known issue with enum in anonymous allOf not validated. See you next PR" 19 continue 20 fi 21 22 spec=${testcase} 23 testcase=`basename ${testcase}` 24 if [[ -z ${opts} ]]; then 25 target=./gen-${testcase%.*}-flatten 26 else 27 target=./gen-${testcase%.*}-expand 28 fi 29 serverName="codegensrv" 30 rm -rf ${target} 31 mkdir ${target} 32 echo "Server generation for ${spec} with opts=${opts}" 33 serverName="nrcodegen" 34 swagger generate server --skip-validation ${opts} --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1 35 if [[ $? != 0 ]] ; then 36 echo "Server generation failed for ${spec}" 37 if [[ ! -z ${continueOnError} ]] ; then 38 failures="${failures} codegen:${spec}" 39 continue 40 else 41 exit 1 42 fi 43 fi 44 clientName="nrclient" 45 swagger generate client --skip-validation ${opts} --spec ${spec} --target ${target} --name=${clientName} 1>${testcase%.*}.log 2>&1 46 if [[ $? != 0 ]] ; then 47 echo "Client generation failed for ${spec}" 48 if [[ ! -z ${continueOnError} ]] ; then 49 failures="${failures} codegen:${spec}" 50 continue 51 else 52 exit 1 53 fi 54 fi 55 echo "${spec}: Generation OK" 56 if [[ ! -d ${target}/models ]] ; then 57 echo "No model in this spec! Continue building server" 58 fi 59 if [[ -d ${target}/cmd/${serverName}"-server" ]] ; then 60 (cd ${target}/cmd/${serverName}"-server"; go build) 61 #(cd ${target}/models; go build) 62 if [[ $? != 0 ]] ; then 63 echo "Build failed for ${spec}" 64 if [[ ! -z ${continueOnError} ]] ; then 65 failures="${failures} build:${spec}" 66 continue 67 else 68 exit 1 69 fi 70 fi 71 echo "${spec}: Build OK" 72 if [[ -n ${clean} ]] ; then 73 rm -rf ${target} 74 fi 75 fi 76 done 77 done 78 if [[ ! -z ${failures} ]] ; then 79 echo ${failures}|tr ' ' '\n' 80 else 81 echo "No failures" 82 fi 83 exit