openapi-checker.sh 657 B

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