File tree Expand file tree Collapse file tree 2 files changed +49
-40
lines changed
Expand file tree Collapse file tree 2 files changed +49
-40
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ name : Validate OpenAPI JSON
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - ' app/Http/Controllers/Api/**/*.php'
7+ - ' app/OpenApi/**/*.php'
8+
9+ jobs :
10+ update-openapi :
11+ runs-on : ubuntu-24.04
12+
13+ steps :
14+ - name : Checkout PR branch
15+ uses : actions/checkout@v5
16+ with :
17+ fetch-depth : 0
18+ ref : ${{ github.event.pull_request.head.ref }}
19+ repository : ${{ github.event.pull_request.head.repo.full_name }}
20+
21+ - name : Set up PHP
22+ uses : shivammathur/setup-php@v2
23+ with :
24+ php-version : ' 8.4'
25+
26+ - name : Install dependencies
27+ run : composer install -q --no-ansi --no-interaction --no-scripts --no-progress
28+
29+ # Generate OpenAPI file into a temp location
30+ - name : Generate OpenAPI JSON
31+ run : ./vendor/bin/openapi ./app/Http/Controllers/Api ./app/OpenApi -o openapi_temp.json -f json
32+
33+ # Compare the generated file to the committed file
34+ - name : Validate OpenAPI JSON is up to date
35+ run : |
36+ if ! diff -q openapi.json openapi_temp.json; then
37+ echo "❌ OpenAPI documentation is out of sync!"
38+ echo ""
39+ echo "API code was modified but openapi.json was NOT updated."
40+ echo ""
41+ echo "Please regenerate the OpenAPI JSON and commit it:"
42+ echo " ./vendor/bin/openapi ./app/Http/Controllers/Api ./app/OpenApi -o openapi.json -f json"
43+ echo ""
44+ exit 1
45+ fi
46+
47+ - name : ✓ OpenAPI is up to date
48+ if : success()
49+ run : echo "✅ OpenAPI documentation matches the committed version!"
You can’t perform that action at this time.
0 commit comments