github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/fixtures/bugs/1755/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-1755.yaml" 9 #for opts in "--with-flatten=minimal" "--with-flatten=full" "--with-expand" ; do 10 for opts in "" ; do 11 for testcase in ${testcases} ; do 12 grep -q discriminator ${testcase} 13 discriminated=$? 14 if [[ ${discriminated} -eq 0 && ${opts} == "--with-expand" ]] ; 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} == "--with-expand" ]] ; 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} || ${opts} == "--with-flatten=minimal" ]]; then 26 target=./gen-${testcase%.*}-minimal 27 elif [[ ${opts} == "--with-flatten=full" ]] ; then 28 target=./gen-${testcase%.*}-flatten 29 else 30 target=./gen-${testcase%.*}-expand 31 fi 32 serverName="codegensrv" 33 rm -rf ${target} 34 mkdir ${target} 35 echo "Model generation for ${spec} with opts=${opts}" 36 serverName="nrcodegen" 37 swagger generate server --skip-validation ${opts} --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1 38 # 1>x.log 2>&1 39 # 40 if [[ $? != 0 ]] ; then 41 echo "Generation failed for ${spec}" 42 if [[ ! -z ${continueOnError} ]] ; then 43 failures="${failures} codegen:${spec}" 44 continue 45 else 46 exit 1 47 fi 48 fi 49 echo "${spec}: Generation OK" 50 if [[ ! -d ${target}/models ]] ; then 51 echo "No model in this spec! Continue building server" 52 fi 53 if [[ -d ${target}/cmd/${serverName}"-server" ]] ; then 54 (cd ${target}/cmd/${serverName}"-server"; go build) 55 #(cd ${target}/models; go build) 56 if [[ $? != 0 ]] ; then 57 echo "Build failed for ${spec}" 58 if [[ ! -z ${continueOnError} ]] ; then 59 failures="${failures} build:${spec}" 60 continue 61 else 62 exit 1 63 fi 64 fi 65 echo "${spec}: Build OK" 66 if [[ -n ${clean} ]] ; then 67 rm -rf ${target} 68 fi 69 fi 70 done 71 done 72 if [[ ! -z ${failures} ]] ; then 73 echo ${failures}|tr ' ' '\n' 74 else 75 echo "No failures" 76 fi 77 exit