swagger-gen 882 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. source "${SCRIPTDIR}/.validate"
  4. IFS=$'\n'
  5. files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true) )
  6. unset IFS
  7. if [ ${#files[@]} -gt 0 ]; then
  8. # We run vndr to and see if we have a diff afterwards
  9. ${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
  10. # Let see if the working directory is clean
  11. diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"
  12. if [ "$diffs" ]; then
  13. {
  14. echo 'The result of hack/generate-swagger-api.sh differs'
  15. echo
  16. echo "$diffs"
  17. echo
  18. echo 'Please update api/swagger.yaml with any api changes, then '
  19. echo 'run `hack/generate-swagger-api.sh`.'
  20. } >&2
  21. false
  22. else
  23. echo 'Congratulations! All api changes are done the right way.'
  24. fi
  25. else
  26. echo 'No api/types/ or api/swagger.yaml changes in diff.'
  27. fi