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