github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/fixtures/bugs/2330/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="fixture-2330.yaml" 9 10 # Generation options 11 fullFlatten="--with-flatten=full" 12 withExpand="--with-expand" 13 minimal="--with-flatten=minimal" 14 for opts in ${fullFlatten} ${withExpand} ${minimal} ; do 15 for testcase in ${testcases} ; do 16 spec=${testcase} 17 testcase=`basename ${testcase}` 18 if [[ -z ${opts} || ${opts} == ${minimal} ]] ; then 19 target=./gen-${testcase%.*}-minimal 20 elif [[ ${opts} == ${fullFlatten} ]] ; then 21 target=./gen-${testcase%.*}-flatten 22 else 23 target=./gen-${testcase%.*}-expand 24 fi 25 serverName="codegensrv" 26 rm -rf ${target} 27 mkdir ${target} 28 echo "Server generation for ${spec} with opts=${opts}" 29 swagger generate server --skip-validation ${opts} --spec=${spec} --target=${target} --log-output=${testcase%.*}.log 30 # 1>x.log 2>&1 31 # 32 if [[ $? != 0 ]] ; then 33 echo "Generation failed for ${spec}" 34 if [[ ! -z ${continueOnError} ]] ; then 35 failures="${failures} codegen:${spec}" 36 continue 37 else 38 exit 1 39 fi 40 fi 41 echo "${spec}: Generation OK" 42 if [[ ! -d ${target}/models ]] ; then 43 echo "No model in this spec! Skipped" 44 else 45 (cd ${target}/models; go build) 46 if [[ $? != 0 ]] ; then 47 echo "Build failed for ${spec}" 48 if [[ ! -z ${continueOnError} ]] ; then 49 failures="${failures} build:${spec}" 50 continue 51 else 52 exit 1 53 fi 54 fi 55 echo "${spec}: Build OK" 56 if [[ -n ${clean} ]] ; then 57 rm -rf ${target} 58 fi 59 fi 60 done 61 done 62 if [[ ! -z ${failures} ]] ; then 63 echo ${failures}|tr ' ' '\n' 64 else 65 echo "No failures" 66 fi 67 exit 68 # Non reg codegen 69 # NOTE(fredbi): 70 # - azure: invalid spec 71 # - bitbucket: model does not compile 72 # - issue72: invalid spec 73 # - todolist.discriminator: ok now 74 testcases=`cd ../../codegen;ls -1|grep -vE 'azure|bitbucket|existing-model|issue72|todolist.simple.yml'` 75 #testcases=${testcases}" fixture-1062.json fixture-984.yaml" 76 #testcases=`cd ../../codegen;ls -1|grep 'todolist.enums.yml'` 77 for testcase in ${testcases} ; do 78 target=./gen-${testcase%.*} 79 if [[ -f ../../codegen/${testcase} ]] ; then 80 spec=../../codegen/${testcase} 81 else 82 spec=${testcase} 83 fi 84 serverName="nrcodegen" 85 rm -rf ${target} 86 mkdir ${target} 87 echo "Server generation for ${spec}" 88 swagger generate server --skip-validation --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1 89 #--log-output=${testcase%.*}.log 90 if [[ $? != 0 ]] ; then 91 echo "Generation failed for ${spec}" 92 exit 1 93 fi 94 echo "${spec}: Generation OK" 95 (cd ${target}/cmd/${serverName}"-server"; go build) 96 if [[ $? != 0 ]] ; then 97 echo "Build failed for ${spec}" 98 exit 1 99 fi 100 echo "${spec}: Build OK" 101 if [[ -n ${clean} ]] ; then 102 rm -rf ${target} 103 fi 104 done 105 # TODO(fredbi): enable non reg again 106 testcases= 107 for testcase in ${testcases} ; do 108 target=./gen-${testcase%.*} 109 spec=./${testcase} 110 serverName="bugfix" 111 rm -rf ${target} 112 mkdir ${target} 113 echo "Generation for ${spec}" 114 swagger generate server --spec ${spec} --target ${target} --quiet --name=${serverName} 115 if [[ $? != 0 ]] ; then 116 echo "Generation failed for ${spec}" 117 exit 1 118 fi 119 echo "${spec}: Generation OK" 120 (cd ${target}/cmd/${serverName}"-server"; go build) 121 if [[ $? != 0 ]] ; then 122 echo "Build failed for ${spec}" 123 exit 1 124 fi 125 echo "${spec}: Build OK" 126 if [[ -n ${clean} ]] ; then 127 rm -rf ${target} 128 fi 129 done