github.com/emreu/go-swagger@v0.22.1/fixtures/bugs/1518/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-1518.yaml"
     9  for opts in  "" ; 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%.*}-flatten
    26      else
    27          target=./gen-${testcase%.*}-expand
    28      fi
    29      serverName="codegensrv"
    30      rm -rf ${target}
    31      mkdir ${target}
    32      echo "Client generation for ${spec} with opts=${opts}"
    33      clientName="nrcodegen"
    34      swagger generate client --skip-validation ${opts} --spec ${spec} --target ${target} --name=${clientName} 1>${testcase%.*}.log 2>&1
    35      if [[ $? != 0 ]] ; then
    36          echo "Generation failed for ${spec}"
    37          if [[ ! -z ${continueOnError} ]] ; then
    38              failures="${failures} codegen:${spec}"
    39              continue
    40          else
    41              exit 1
    42          fi
    43      fi
    44      echo "${spec}: Generation OK"
    45      if [[ ! -d ${target}/models ]] ; then
    46          echo "No model in this spec! Continue building client"
    47      fi
    48      if [[ -d ${target}/client ]] ; then
    49          (cd ${target}/client ; go build)
    50          if [[ $? != 0 ]] ; then
    51              echo "Build failed for ${spec}"
    52              if [[ ! -z ${continueOnError} ]] ; then
    53                  failures="${failures} build:${spec}"
    54                  continue
    55              else
    56                  exit 1
    57              fi
    58          fi
    59          echo "${spec}: Build OK"
    60          if [[ -n ${clean} ]] ; then
    61               rm -rf ${target}
    62          fi
    63      fi
    64  done
    65  done
    66  if [[ ! -z ${failures} ]] ; then
    67      echo ${failures}|tr ' ' '\n'
    68  else
    69      echo "No failures"
    70  fi
    71  exit