-
Notifications
You must be signed in to change notification settings - Fork 118
37 lines (31 loc) · 923 Bytes
/
check-openapi.yml
File metadata and controls
37 lines (31 loc) · 923 Bytes
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
name: Check OpenAPI Schema
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
check-openapi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Generate OpenAPI schema
run: go run main.go server --print-openapi dummy > generated-openapi.json
- name: Check OpenAPI schema
run: |
if [ ! -f "openapi.json" ]; then
echo "::warning::openapi.json does not exist"
exit 1
fi
# Compare schemas
if ! cmp -s openapi.json generated-openapi.json; then
echo "::error::The openapi.json file is out of sync with the generated schema"
echo "Diff:"
diff -u openapi.json generated-openapi.json || true
exit 1
fi
echo "OpenAPI schema is up to date"