-
Notifications
You must be signed in to change notification settings - Fork 240
93 lines (79 loc) · 3.18 KB
/
apidoc.yaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Verify and Publish OpenAPI Specs
on:
push:
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'CODEOWNERS'
- 'LICENSE'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Verify-OpenAPI-Definitions:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
apiGroup: [ 'management-api', 'control-api' ]
env:
rootDir: resources/openapi/yaml/${{ matrix.apiGroup }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-build
- name: Save previous OpenAPI definition
run: |
mkdir -p git-sorted/${{ matrix.apiGroup }}
files=($(ls $rootDir))
for file in ${files[@]}; do
yq -P 'sort_keys(..)' $rootDir/$file > git-sorted/${{ matrix.apiGroup }}/$file
done
- name: Generate OpenAPI definitions from code
run: |
export
./gradlew resolve
# Can be used (and yq tasks removed) when https://github.com/kpramesh2212/openapi-merger-plugin/pull/11/files is merged
#- name: Check OpenAPI definitions match code
# run: git diff --exit-code
- name: Check OpenAPI definitions match code
run: |
mkdir -p git-regen/${{ matrix.apiGroup }}
files=($(ls resources/openapi/yaml/${{ matrix.apiGroup}}))
for file in ${files[@]}; do
yq -P 'sort_keys(..)' $rootDir/$file > git-regen/${{ matrix.apiGroup }}/$file
done
diff -r git-sorted git-regen
Publish-To-SwaggerHub:
# do NOT run on forks or on PRs. The Org ("edc") is unique all across SwaggerHub
if: github.repository == 'eclipse-edc/Connector' && github.event_name == 'push' && github.ref_name == 'main'
runs-on: ubuntu-latest
needs: [ Verify-OpenAPI-Definitions ]
strategy:
matrix:
apiGroup: [ 'management-api', 'control-api' ]
env:
rootDir: resources/openapi/yaml/${{ matrix.apiGroup }}
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_TOKEN }}
SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-build
- uses: actions/setup-node@v3
# merge together all api groups
- name: Generate API Specs
run: |
./gradlew -PapiTitle="${{ matrix.apiGroup }}" -PapiDescription="REST API documentation for the ${{ matrix.apiGroup }}" :mergeApiSpec --input=${{ env.rootDir }} --output=${{ matrix.apiGroup }}.yaml
# install swaggerhub CLI
- name: Install SwaggerHub CLI
run: npm i -g swaggerhub-cli
# create API, will fail if exists
- name: Create API
continue-on-error: true
run: |
swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/${{ matrix.apiGroup}} -f ${{ matrix.apiGroup }}.yaml --visibility=public --published=unpublish
# Post the API to SwaggerHub as "unpublished", because published APIs cannot be overwritten
- name: Publish API Specs to SwaggerHub
run: |
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/${{ matrix.apiGroup}} -f ${{ matrix.apiGroup }}.yaml --visibility=public --published=unpublish