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