-
Notifications
You must be signed in to change notification settings - Fork 9
71 lines (57 loc) · 1.83 KB
/
api-swagger.yml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# SPDX-FileCopyrightText: 2023 Siemens AG
# SPDX-FileContributor: Gaurav Mishra <[email protected]>
# SPDX-License-Identifier: GPL-2.0-only
name: Swagger API Updated
on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
doc-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
check-latest: true
cache: true
- name: Code Generation
run: |
cp external_ref_fields.example.yaml external_ref_fields.yaml && go generate ./...
- name: Install swag
run: |
go install github.com/swaggo/swag/cmd/swag@latest
- name: Build Swagger documents
run: |
swag init --parseDependency --generalInfo api.go --dir ./pkg/api,./pkg/auth,./pkg/db,./pkg/models,./pkg/utils --output ./swag/docs
- name: Check doc diff
run: |
diff swag/docs/docs.go cmd/laas/docs/docs.go > swagger-diff.txt || true
# Check if file swagger-diff.txt is empty
if [ -s swagger-diff.txt ]
then
# If file is not empty, echo a message and exit 1
echo "Swagger docs are not up to date. Please run 'swag init' and commit the changes."
exit 1
fi
doc-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
check-latest: true
cache: true
- name: Install swag
run: |
go install github.com/swaggo/swag/cmd/swag@latest
- name: Format Swagger documents
run: |
swag fmt --generalInfo ./pkg/api/api.go --dir ./pkg/api,./pkg/auth,./pkg/db,./pkg/models,./pkg/utils
- name: Check file diff
run: |
git diff --exit-code