1
0

openapi-checker.sh 587 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bash
  2. for path in core/openapi.json apps/*/openapi.json; do
  3. composer exec generate-spec "$(dirname "$path")" "$path" || exit 1
  4. done
  5. files="$(git diff --name-only)"
  6. changed=false
  7. for file in $files; do
  8. if [[ $file == *"openapi.json" ]]; then
  9. changed=true
  10. break
  11. fi
  12. done
  13. if [ $changed = true ]
  14. then
  15. git --no-pager diff
  16. echo "The OpenAPI specifications are not up to date"
  17. echo "Please run: bash build/openapi-checker.sh"
  18. echo "And commit the result"
  19. exit 1
  20. else
  21. echo "OpenAPI specifications up to date. Carry on"
  22. exit 0
  23. fi