github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/fixtures/bugs/1437/gen-fixtures.sh (about)

     1  #! /bin/bash 
     2  if [[ ${1} == "--clean" ]] ; then
     3      clean=1
     4  fi
     5  # A small utility to build fixture servers
     6  # Fixtures with models only
     7  testcases="fixture-1437-3.yaml fixture-1437-2.yaml fixture-1191.yaml fixture-1437.yaml fixture-1437-4.yaml"
     8  #testcases="fixture-debug-2.yaml"
     9  for testcase in ${testcases} ; do
    10      target=./gen-${testcase%.*}
    11      spec=./${testcase}
    12      serverName="codegensrv"
    13      rm -rf ${target}
    14      mkdir ${target}
    15      echo "Generation for ${spec}"
    16      swagger generate model --skip-validation --spec ${spec} --target ${target} --output=${testcase%.*}.log 
    17      # 1>x.log 2>&1
    18      #
    19      if [[ $? != 0 ]] ; then
    20          echo "Generation failed for ${spec}"
    21          exit 1
    22      fi
    23      echo "${spec}: Generation OK"
    24      if [[ ! -d ${target}/models ]] ; then
    25          echo "No model in this spec! Skipped"
    26      else
    27          (cd ${target}/models; go build)
    28          if [[ $? != 0 ]] ; then
    29              echo "Build failed for ${spec}"
    30              exit 1
    31          fi
    32          echo "${spec}: Build OK"
    33          if [[ -n ${clean} ]] ; then 
    34               rm -rf ${target}
    35          fi
    36      fi
    37  done
    38  # Non reg codegen
    39  # NOTE(fredbi): 
    40  # - azure: invalid spec 
    41  # - bitbucket: model does not compile
    42  # - issue72: invalid spec
    43  # - todolist.discriminator: known issue with schemavalidator
    44  testcases=`cd ../../codegen;ls -1 *.yaml *.yml *.json|grep -vE 'azure|bitbucket|existing-model|issue72|todolist.discriminator|todolist.simple.yml'`
    45  for testcase in ${testcases} ; do
    46      target=./gen-${testcase%.*}
    47      spec=../../codegen/${testcase}
    48      serverName="nrcodegen"
    49      rm -rf ${target}
    50      mkdir ${target}
    51      echo "Generation for ${spec}"
    52      swagger generate server --skip-validation --spec ${spec} --target ${target} --name=${serverName} --output=${testcase%.*}.log
    53      if [[ $? != 0 ]] ; then
    54          echo "Generation failed for ${spec}"
    55          exit 1
    56      fi
    57      echo "${spec}: Generation OK"
    58      (cd ${target}/cmd/${serverName}"-server"; go build)
    59      if [[ $? != 0 ]] ; then
    60          echo "Build failed for ${spec}"
    61          exit 1
    62      fi
    63      echo "${spec}: Build OK"
    64      if [[ -n ${clean} ]] ; then 
    65          rm -rf ${target}
    66      fi
    67  done
    68  # 
    69  testcases=
    70  for testcase in ${testcases} ; do
    71      target=./gen-${testcase%.*}
    72      spec=./${testcase}
    73      serverName="bugfix"
    74      rm -rf ${target}
    75      mkdir ${target}
    76      echo "Generation for ${spec}"
    77      swagger generate server --spec ${spec} --target ${target} --quiet --name=${serverName}
    78      if [[ $? != 0 ]] ; then
    79          echo "Generation failed for ${spec}"
    80          exit 1
    81      fi
    82      echo "${spec}: Generation OK"
    83      (cd ${target}/cmd/${serverName}"-server"; go build)
    84      if [[ $? != 0 ]] ; then
    85          echo "Build failed for ${spec}"
    86          exit 1
    87      fi
    88      echo "${spec}: Build OK"
    89      if [[ -n ${clean} ]] ; then 
    90          rm -rf ${target}
    91      fi
    92  done