github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/fixtures/bugs/1596/gen-fixtures.sh (about) 1 #! /bin/bash 2 if [[ ${1} == "--clean" ]] ; then 3 clean=1 4 fi 5 # A small utility to build fixture servers 6 # Fixtures with models only 7 testcases="${testcases} fixture-1596.yaml" 8 # For this, skip --with-expand (contains polymorphic models): 9 #testcases="${testcases} ../../codegen/todolist.models.yml" 10 for opts in "--with-flatten=minimal" "--with-flatten=full" "--with-expand" ;do 11 for testcase in ${testcases} ; do 12 target=./gen-`basename ${testcase%.*}` 13 case ${opts} in 14 "--with-flatten=minimal") 15 target=${target}"-minimal" 16 ;; 17 "--with-flatten=full") 18 target=${target}"-full" 19 ;; 20 "--with-expand") 21 target=${target}"-expand" 22 ;; 23 esac 24 spec=./${testcase} 25 serverName="codegensrv" 26 rm -rf ${target} 27 mkdir ${target} 28 echo "Model generation for ${spec} with ${opts}" 29 swagger generate server --skip-validation ${opts} --spec ${spec} --target ${target} --name=${serverName} --output=${testcase%.*}.log 30 # 1>x.log 2>&1 31 # 32 if [[ $? != 0 ]] ; then 33 echo "Generation failed for ${spec}" 34 exit 1 35 fi 36 echo "${spec}: Generation OK" 37 (cd ${target}/cmd/${serverName}-server; go build) 38 if [[ $? != 0 ]] ; then 39 echo "Build failed for ${spec}" 40 exit 1 41 fi 42 echo "${spec}: Build OK" 43 if [[ -n ${clean} ]] ; then 44 rm -rf ${target} 45 fi 46 done 47 done 48 exit