forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.55 KB
/
validate-openapi.yml
File metadata and controls
49 lines (41 loc) · 1.55 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Validate OpenAPI JSON
on:
pull_request:
paths:
- 'app/Http/Controllers/Api/**/*.php'
- 'app/OpenApi/**/*.php'
jobs:
update-openapi:
runs-on: ubuntu-24.04
steps:
- name: Checkout PR branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- name: Install dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress
# Generate OpenAPI file into a temp location
- name: Generate OpenAPI JSON
run: ./vendor/bin/openapi ./app/Http/Controllers/Api ./app/OpenApi -o openapi_temp.json -f json
# Compare the generated file to the committed file
- name: Validate OpenAPI JSON is up to date
run: |
if ! diff -q openapi.json openapi_temp.json; then
echo "❌ OpenAPI documentation is out of sync!"
echo ""
echo "API code was modified but openapi.json was NOT updated."
echo ""
echo "Please regenerate the OpenAPI JSON and commit it:"
echo " ./vendor/bin/openapi ./app/Http/Controllers/Api ./app/OpenApi -o openapi.json -f json"
echo ""
exit 1
fi
- name: ✓ OpenAPI is up to date
if: success()
run: echo "✅ OpenAPI documentation matches the committed version!"