swagger-gen 835 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env 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. ${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
  9. # Let see if the working directory is clean
  10. diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"
  11. if [ "$diffs" ]; then
  12. {
  13. echo 'The result of hack/generate-swagger-api.sh differs'
  14. echo
  15. echo "$diffs"
  16. echo
  17. echo 'Please update api/swagger.yaml with any api changes, then '
  18. echo 'run `hack/generate-swagger-api.sh`.'
  19. } >&2
  20. false
  21. else
  22. echo 'Congratulations! All api changes are done the right way.'
  23. fi
  24. else
  25. echo 'No api/types/ or api/swagger.yaml changes in diff.'
  26. fi