github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/enhancements/guard-formats/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="fixture-guard-formats.yaml"
     9  for opts in  "" "--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%.*}-flatten
    26      else
    27          target=./gen-${testcase%.*}-expand
    28      fi
    29      serverName="codegensrv"
    30      rm -rf ${target}
    31      mkdir ${target}
    32      echo "Model 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      # 1>x.log 2>&1
    36      #
    37      if [[ $? != 0 ]] ; then
    38          echo "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 "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  done
    68  done
    69  if [[ ! -z ${failures} ]] ; then
    70      echo ${failures}|tr ' ' '\n'
    71  else
    72      echo "No failures"
    73  fi
    74  exit