github.com/kaisawind/go-swagger@v0.19.0/fixtures/bugs/1537/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-1537.yaml"
     9  testcases="${testcases} fixture-1537-2.yaml"
    10  #export SWAGGER_DEBUG=1
    11  for opts in  "" "--skip-flatten" ; do
    12  #for opts in  "" ; do
    13  for testcase in ${testcases} ; do
    14      grep -q discriminator ${testcase}
    15      discriminated=$?
    16      if [[ ${discriminated} -eq 0 && ${opts} == "--skip-flatten" ]] ; then
    17          echo "Skipped ${testcase} with ${opts}: discriminator not supported with ${opts}"
    18          continue
    19      fi
    20      if [[ ${testcase} == "../1479/fixture-1479-part.yaml" && ${opts} == "--skip-flatten" ]] ; then
    21          echo "Skipped ${testcase} with ${opts}: known issue with enum in anonymous allOf not validated. See you next PR"
    22          continue
    23      fi
    24  
    25      spec=${testcase}
    26      testcase=`basename ${testcase}`
    27      if [[ -z ${opts} ]]; then
    28          target=./gen-${testcase%.*}-flatten
    29      else
    30          target=./gen-${testcase%.*}-expand
    31      fi
    32      serverName="codegensrv"
    33      rm -rf ${target}
    34      mkdir ${target}
    35      echo "Model generation for ${spec} with opts=${opts}"
    36      serverName="nrcodegen"
    37      swagger generate server --skip-validation ${opts} --spec ${spec} --target ${target} --name=${serverName} 1>${testcase%.*}.log 2>&1
    38      # 1>x.log 2>&1
    39      #
    40      if [[ $? != 0 ]] ; then
    41          echo "Generation failed for ${spec}"
    42          if [[ ! -z ${continueOnError} ]] ; then
    43              failures="${failures} codegen:${spec}"
    44              continue
    45          else
    46              exit 1
    47          fi
    48      fi
    49      echo "${spec}: Generation OK"
    50      if [[ ! -d ${target}/models ]] ; then
    51          echo "No model in this spec! Skipped"
    52      else
    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