github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/bugs/1487/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-moreAddProps.yaml" 9 testcases="${testcases} ../../codegen/issue72.json" 10 testcases="${testcases} ../../canary/bitbucket.org/swagger.json" 11 testcases="${testcases} ../../codegen/azure-text-analyis-fixed.json" 12 testcases="${testcases} ../../codegen/todolist.simple.yml" 13 testcases="${testcases} ../../codegen/swagger-gsma.json" 14 testcases="${testcases} ../844/swagger.json" 15 testcases="${testcases} fixture-844-variations.yaml" 16 testcases="${testcases} fixture-nested-maps.yaml" 17 testcases="${testcases} fixture-errors.yaml" 18 testcases="${testcases} fixture-simple-allOf.yaml" 19 testcases="${testcases} fixture-complex-allOf.yaml" 20 testcases="${testcases} fixture-is-nullable.yaml" 21 testcases="${testcases} fixture-itching.yaml" 22 testcases="${testcases} fixture-additionalProps.yaml" 23 testcases="${testcases} fixture-tuple.yaml" 24 testcases="${testcases} fixture-allOf.yaml" 25 testcases="${testcases} ../1479/fixture-1479-part.yaml" 26 testcases="${testcases} ../1198/fixture-1198.yaml" 27 testcases="${testcases} ../1042/fixture-1042.yaml" 28 testcases="${testcases} ../1042/fixture-1042-2.yaml" 29 testcases="${testcases} ../979/fixture-979.yaml" 30 testcases="${testcases} ../842/fixture-842.yaml" 31 testcases="${testcases} ../607/fixture-607.yaml" 32 testcases="${testcases} ../1336/fixture-1336.yaml" 33 testcases="${testcases} ../1277/cloudbreak.json" 34 testcases="${testcases} ../../codegen/todolist.schemavalidation.yml" 35 testcases="${testcases} ../../codegen/todolist.discriminators.yml" 36 testcases="${testcases} ../../codegen/billforward.discriminators.yml" 37 38 # Generation options 39 fullFlatten="--with-flatten=full" 40 withExpand="--with-expand" 41 minimal="--with-flatten=minimal" 42 for opts in ${fullFlatten} ${withExpand} ${minimal} ; do 43 for testcase in ${testcases} ; do 44 grep -q discriminator ${testcase} 45 discriminated=$? 46 if [[ ${discriminated} -eq 0 && ${opts} == ${withExpand} ]] ; then 47 echo "Skipped ${testcase} with ${opts}: discriminator not supported with ${opts}" 48 continue 49 fi 50 if [[ ${testcase} == "../1479/fixture-1479-part.yaml" && ${opts} == ${withExpand} ]] ; then 51 echo "Skipped ${testcase} with ${opts}: known issue with enum in anonymous allOf not validated. See you next PR" 52 continue 53 fi 54 55 spec=${testcase} 56 testcase=`basename ${testcase}` 57 if [[ -z ${opts} || ${opts} == ${minimal} ]] ; then 58 target=./gen-${testcase%.*}-minimal 59 elif [[ ${opts} == ${fullFlatten} ]] ; then 60 target=./gen-${testcase%.*}-flatten 61 else 62 target=./gen-${testcase%.*}-expand 63 fi 64 serverName="codegensrv" 65 rm -rf ${target} 66 mkdir ${target} 67 echo "Model generation for ${spec} with opts=${opts}" 68 swagger generate model --skip-validation ${opts} --spec=${spec} --target=${target} --log-output=${testcase%.*}.log 69 # 1>x.log 2>&1 70 # 71 if [[ $? != 0 ]] ; then 72 echo "Generation failed for ${spec}" 73 if [[ ! -z ${continueOnError} ]] ; then 74 failures="${failures} codegen:${spec}" 75 continue 76 else 77 exit 1 78 fi 79 fi 80 echo "${spec}: Generation OK" 81 if [[ ! -d ${target}/models ]] ; then 82 echo "No model in this spec! Skipped" 83 else 84 (cd ${target}/models; go build) 85 if [[ $? != 0 ]] ; then 86 echo "Build failed for ${spec}" 87 if [[ ! -z ${continueOnError} ]] ; then 88 failures="${failures} build:${spec}" 89 continue 90 else 91 exit 1 92 fi 93 fi 94 echo "${spec}: Build OK" 95 if [[ -n ${clean} ]] ; then 96 rm -rf ${target} 97 fi 98 fi 99 done 100 done 101 if [[ ! -z ${failures} ]] ; then 102 echo ${failures}|tr ' ' '\n' 103 else 104 echo "No failures" 105 fi 106 exit 107 # Non reg codegen 108 # NOTE(fredbi): 109 # - azure: invalid spec 110 # - bitbucket: model does not compile 111 # - issue72: invalid spec 112 # - todolist.discriminator: ok now 113 testcases=`cd ../../codegen;ls -1|grep -vE 'azure|bitbucket|existing-model|issue72|todolist.simple.yml'` 114 #testcases=${testcases}" fixture-1062.json fixture-984.yaml" 115 #testcases=`cd ../../codegen;ls -1|grep 'todolist.enums.yml'` 116 for testcase in ${testcases} ; do 117 target=./gen-${testcase%.*} 118 if [[ -f ../../codegen/${testcase} ]] ; then 119 spec=../../codegen/${testcase} 120 else 121 spec=${testcase} 122 fi 123 serverName="nrcodegen" 124 rm -rf ${target} 125 mkdir ${target} 126 echo "Server generation for ${spec}" 127 swagger generate server --skip-validation --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1 128 #--log-output=${testcase%.*}.log 129 if [[ $? != 0 ]] ; then 130 echo "Generation failed for ${spec}" 131 exit 1 132 fi 133 echo "${spec}: Generation OK" 134 (cd ${target}/cmd/${serverName}"-server"; go build) 135 if [[ $? != 0 ]] ; then 136 echo "Build failed for ${spec}" 137 exit 1 138 fi 139 echo "${spec}: Build OK" 140 if [[ -n ${clean} ]] ; then 141 rm -rf ${target} 142 fi 143 done 144 # TODO(fredbi): enable non reg again 145 testcases= 146 for testcase in ${testcases} ; do 147 target=./gen-${testcase%.*} 148 spec=./${testcase} 149 serverName="bugfix" 150 rm -rf ${target} 151 mkdir ${target} 152 echo "Generation for ${spec}" 153 swagger generate server --spec ${spec} --target ${target} --quiet --name=${serverName} 154 if [[ $? != 0 ]] ; then 155 echo "Generation failed for ${spec}" 156 exit 1 157 fi 158 echo "${spec}: Generation OK" 159 (cd ${target}/cmd/${serverName}"-server"; go build) 160 if [[ $? != 0 ]] ; then 161 echo "Build failed for ${spec}" 162 exit 1 163 fi 164 echo "${spec}: Build OK" 165 if [[ -n ${clean} ]] ; then 166 rm -rf ${target} 167 fi 168 done