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