openapi-checker.sh 776 B

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