github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/bugs/1893/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-1893.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      clientName="codegen-client"
    30      rm -rf ${target}
    31      mkdir ${target}
    32      echo "Client generation for ${spec} with opts=${opts}"
    33      serverName="nrcodegen"
    34      swagger generate server --skip-validation ${opts} --spec ${spec} --target ${target} --name=${serverName} 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      if [[ -d ${target}/cmd/${serverName}"-server" ]] ; then
    45          (cd ${target}/cmd/${serverName}"-server"; go build)
    46          #(cd ${target}/models; go build)
    47          if [[ $? != 0 ]] ; then
    48              echo "Build failed for ${spec}"
    49              if [[ ! -z ${continueOnError} ]] ; then
    50                  failures="${failures} build:${spec}"
    51                  continue
    52              else
    53                  exit 1
    54              fi
    55          fi
    56          echo "${spec}: Build OK"
    57          if [[ -n ${clean} ]] ; then
    58               rm -rf ${target}
    59          fi
    60      fi
    61  
    62      clientName="client"
    63      swagger generate client --skip-validation ${opts} --spec ${spec} --target ${target} --name=${clientName} 1>${testcase%.*}.log 2>&1
    64      if [[ $? != 0 ]] ; then
    65          echo "Generation failed for ${spec}"
    66          if [[ ! -z ${continueOnError} ]] ; then
    67              failures="${failures} codegen:${spec}"
    68              continue
    69          else
    70              exit 1
    71          fi
    72      fi
    73      echo "${spec}: Generation OK"
    74      if [[ ! -d ${target}/models ]] ; then
    75          echo "No model in this spec! Continue building server"
    76      fi
    77      if [[ -d ${target}/client ]] ; then
    78          (cd ${target}/client ; go build)
    79          #(cd ${target}/models; go build)
    80          if [[ $? != 0 ]] ; then
    81              echo "Build failed for ${spec}"
    82              if [[ ! -z ${continueOnError} ]] ; then
    83                  failures="${failures} build:${spec}"
    84                  continue
    85              else
    86                  exit 1
    87              fi
    88          fi
    89          echo "${spec}: Build OK"
    90          if [[ -n ${clean} ]] ; then
    91               rm -rf ${target}
    92          fi
    93      fi
    94  done
    95  done
    96  if [[ ! -z ${failures} ]] ; then
    97      echo ${failures}|tr ' ' '\n'
    98  else
    99      echo "No failures"
   100  fi
   101  exit