github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/enhancements/2163/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-2163.yaml"
     9  #testcases="${testcases} ../1487/fixture-844-variations.yaml"
    10  #testcases="${testcases} ../1487/fixture-itching.yaml"
    11  for opts in  "" ; do
    12  for testcase in ${testcases} ; do
    13      grep -q discriminator ${testcase}
    14      discriminated=$?
    15      if [[ ${discriminated} -eq 0 && ${opts} == "--with-expand" ]] ; then
    16          echo "Skipped ${testcase} with ${opts}: discriminator not supported with ${opts}"
    17          continue
    18      fi
    19      if [[ ${testcase} == "../1479/fixture-1479-part.yaml" && ${opts} == "--with-expand" ]] ; then
    20          echo "Skipped ${testcase} with ${opts}: known issue with enum in anonymous allOf not validated. See you next PR"
    21          continue
    22      fi
    23  
    24      spec=${testcase}
    25      testcase=`basename ${testcase}`
    26      if [[ -z ${opts} ]]; 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