github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/bugs/1532/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-1532.yaml" 9 #export SWAGGER_DEBUG=1 10 for opts in "" ; do 11 for testcase in ${testcases} ; do 12 grep -q discriminator ${testcase} 13 discriminated=$? 14 if [[ ${discriminated} -eq 0 && ${opts} == "--skip-flatten" ]] ; then 15 echo "Skipped ${testcase} with ${opts}: discriminator not supported with ${opts}" 16 continue 17 fi 18 if [[ ${testcase} == "../1479/fixture-1479-part.yaml" && ${opts} == "--skip-flatten" ]] ; then 19 echo "Skipped ${testcase} with ${opts}: known issue with enum in anonymous allOf not validated. See you next PR" 20 continue 21 fi 22 23 spec=${testcase} 24 testcase=`basename ${testcase}` 25 if [[ -z ${opts} ]]; then 26 target=./gen-${testcase%.*}-flatten 27 else 28 target=./gen-${testcase%.*}-expand 29 fi 30 serverName="codegensrv" 31 rm -rf ${target} 32 mkdir ${target} 33 echo "Model generation for ${spec} with opts=${opts}" 34 swagger generate model --skip-validation ${opts} --spec=${spec} --target=${target} --output=${testcase%.*}.log 35 # 1>x.log 2>&1 36 # 37 if [[ $? != 0 ]] ; then 38 echo "Generation failed for ${spec}" 39 if [[ ! -z ${continueOnError} ]] ; then 40 failures="${failures} codegen:${spec}" 41 continue 42 else 43 exit 1 44 fi 45 fi 46 echo "${spec}: Generation OK" 47 if [[ ! -d ${target}/models ]] ; then 48 echo "No model in this spec! Skipped" 49 else 50 (cd ${target}/models; go build) 51 if [[ $? != 0 ]] ; then 52 echo "Build failed for ${spec}" 53 if [[ ! -z ${continueOnError} ]] ; then 54 failures="${failures} build:${spec}" 55 continue 56 else 57 exit 1 58 fi 59 fi 60 echo "${spec}: Build OK" 61 if [[ -n ${clean} ]] ; then 62 rm -rf ${target} 63 fi 64 fi 65 done 66 done 67 if [[ ! -z ${failures} ]] ; then 68 echo ${failures}|tr ' ' '\n' 69 else 70 echo "No failures" 71 fi 72 exit