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