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