github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/fixtures/bugs/1232/gen-fixtures.sh (about) 1 #! /bin/bash 2 if [[ ${1} == "--clean" ]] ; then 3 clean=1 4 fi 5 # Acknowledgements 6 testcases="${testcases} fixture-1232.yaml" 7 #testcases="${testcases} ../1198/fixture-1198.yaml" # passed ok 8 # A small utility to build fixture servers 9 # Fixtures with models only 10 #testcases="${testcases} fixture-allOf.yaml" # this one still reveals bugs 11 # non reg 12 #testcases="${testcases} ../../codegen/billforward.discriminators.yml" 13 #testcases="${testcases} ../1277/cloudbreak.json" 14 15 #testcases="${testcases} fixture-1479-part.yaml" # passed ok 16 #testcases="${testcases} fixture-simple-allOf.yaml" # passed ok 17 #testcases="${testcases} fixture-complex-allOf.yaml" # passed ok 18 #testcases="${testcases} fixture-is-nullable.yaml" # passed ok 19 #testcases="${testcases} fixture-itching.yaml" # passed ok 20 #testcases="${testcases} fixture-additionalProps.yaml" # passed ok 21 #testcases="${testcases} fixture-tuple.yaml" # passed ok 22 #testcases="fixture-1047.yaml fixture-1093.yaml fixture-1066.yaml fixture-arrays.yaml fixture-nested.yaml fixture-1203.yaml fixture-1328.yaml fixture-x-const.yaml fixture-ci.yaml fixture-types.yaml quay-discovery.json fixture-body.yaml fixture-951.json fixture-1062.json fixture-984.yaml" 23 #testcases="${testcase} todolist.schemavalidation.yml todolist.enums.yml fixture-tuple.yaml fixture-edge.yaml fixture-1047.yaml fixture-1093.yaml fixture-1066.yaml fixture-arrays.yaml fixture-nested.yaml fixture-1203.yaml fixture-1328.yaml fixture-x-const.yaml fixture-ext.yaml fixture-ci.yaml fixture-types.yaml fixture-body.yaml" 24 #testcases="${testcases} fixture-simple-tuple.yaml" 25 for testcase in ${testcases} ; do 26 spec=${testcase} 27 testcase=`basename ${testcase}` 28 target=./gen-${testcase%.*} 29 serverName="codegensrv" 30 rm -rf ${target} 31 mkdir ${target} 32 echo "Model generation for ${spec}" 33 swagger generate model --skip-validation --spec ${spec} --target ${target} --output=${testcase%.*}.log 34 # 1>x.log 2>&1 35 # 36 if [[ $? != 0 ]] ; then 37 echo "Generation failed for ${spec}" 38 exit 1 39 fi 40 echo "${spec}: Generation OK" 41 if [[ ! -d ${target}/models ]] ; then 42 echo "No model in this spec! Skipped" 43 else 44 (cd ${target}/models; go build) 45 if [[ $? != 0 ]] ; then 46 echo "Build failed for ${spec}" 47 exit 1 48 fi 49 echo "${spec}: Build OK" 50 if [[ -n ${clean} ]] ; then 51 rm -rf ${target} 52 fi 53 fi 54 done 55 exit 56 # Non reg codegen 57 # NOTE(fredbi): 58 # - azure: invalid spec 59 # - bitbucket: model does not compile 60 # - issue72: invalid spec 61 # - todolist.discriminator: ok now 62 testcases=`cd ../../codegen;ls -1|grep -vE 'azure|bitbucket|existing-model|issue72|todolist.simple.yml'` 63 #testcases=${testcases}" fixture-1062.json fixture-984.yaml" 64 #testcases=`cd ../../codegen;ls -1|grep 'todolist.enums.yml'` 65 for testcase in ${testcases} ; do 66 target=./gen-${testcase%.*} 67 if [[ -f ../../codegen/${testcase} ]] ; then 68 spec=../../codegen/${testcase} 69 else 70 spec=${testcase} 71 fi 72 serverName="nrcodegen" 73 rm -rf ${target} 74 mkdir ${target} 75 echo "Server generation for ${spec}" 76 swagger generate server --skip-validation --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1 77 #--output=${testcase%.*}.log 78 if [[ $? != 0 ]] ; then 79 echo "Generation failed for ${spec}" 80 exit 1 81 fi 82 echo "${spec}: Generation OK" 83 (cd ${target}/cmd/${serverName}"-server"; go build) 84 if [[ $? != 0 ]] ; then 85 echo "Build failed for ${spec}" 86 exit 1 87 fi 88 echo "${spec}: Build OK" 89 if [[ -n ${clean} ]] ; then 90 rm -rf ${target} 91 fi 92 done 93 # TODO(fredbi): enable non reg again 94 testcases= 95 for testcase in ${testcases} ; do 96 target=./gen-${testcase%.*} 97 spec=./${testcase} 98 serverName="bugfix" 99 rm -rf ${target} 100 mkdir ${target} 101 echo "Generation for ${spec}" 102 swagger generate server --spec ${spec} --target ${target} --quiet --name=${serverName} 103 if [[ $? != 0 ]] ; then 104 echo "Generation failed for ${spec}" 105 exit 1 106 fi 107 echo "${spec}: Generation OK" 108 (cd ${target}/cmd/${serverName}"-server"; go build) 109 if [[ $? != 0 ]] ; then 110 echo "Build failed for ${spec}" 111 exit 1 112 fi 113 echo "${spec}: Build OK" 114 if [[ -n ${clean} ]] ; then 115 rm -rf ${target} 116 fi 117 done