aboutsummaryrefslogtreecommitdiffstats
path: root/build/openapi-checker.sh
blob: ca9d382a1cf47f41afd2919a845d6faaf37f08ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash

for path in core/openapi.json apps/*/openapi.json; do
	composer exec generate-spec "$(dirname "$path")" "$path" || exit 1
done

files="$(git diff --name-only)"
changed=false
for file in $files; do
    if [[ $file == *"openapi.json" ]]; then
        changed=true
        break
    fi
done

if [ $changed = true ]
then
	git --no-pager diff
    echo "The OpenAPI specifications are not up to date"
    echo "Please run: bash build/openapi-checker.sh"
    echo "And commit the result"
    exit 1
else
    echo "OpenAPI specifications up to date. Carry on"
    exit 0
fi