Skip to content

Commit fb5c055

Browse files
authored
Merge pull request #4657 from nextcloud/enh/open-api
Finally add an OpenAPI spec for the OCS Endpoints
2 parents 12f3e6a + d94fdef commit fb5c055

31 files changed

Lines changed: 13709 additions & 711 deletions

.github/workflows/openapi.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-FileCopyrightText: 2024 Arthur Schiwon <blizzz@arthur-schiwon.de>
8+
# SPDX-License-Identifier: MIT
9+
10+
name: OpenAPI
11+
12+
on: pull_request
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: openapi-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
openapi:
23+
runs-on: ubuntu-latest
24+
25+
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30+
with:
31+
persist-credentials: false
32+
33+
- name: Get php version
34+
id: php_versions
35+
uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
36+
37+
- name: Set up php
38+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0
39+
with:
40+
php-version: ${{ steps.php_versions.outputs.php-available }}
41+
extensions: xml
42+
coverage: none
43+
ini-file: development
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Check Typescript OpenApi types
48+
id: check_typescript_openapi
49+
uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
50+
with:
51+
files: "src/types/openapi/openapi*.ts"
52+
53+
- name: Read package.json node and npm engines version
54+
if: steps.check_typescript_openapi.outputs.files_exists == 'true'
55+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
56+
id: node_versions
57+
continue-on-error: true
58+
with:
59+
fallbackNode: '^24'
60+
fallbackNpm: '^11.3'
61+
62+
- name: Set up node ${{ steps.node_versions.outputs.nodeVersion }}
63+
if: ${{ steps.node_versions.outputs.nodeVersion }}
64+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
65+
with:
66+
node-version: ${{ steps.node_versions.outputs.nodeVersion }}
67+
68+
- name: Set up npm ${{ steps.node_versions.outputs.npmVersion }}
69+
if: ${{ steps.node_versions.outputs.npmVersion }}
70+
run: npm i -g 'npm@${{ steps.node_versions.outputs.npmVersion }}'
71+
72+
- name: Install dependencies
73+
if: ${{ steps.node_versions.outputs.nodeVersion }}
74+
env:
75+
CYPRESS_INSTALL_BINARY: 0
76+
PUPPETEER_SKIP_DOWNLOAD: true
77+
run: npm ci
78+
79+
- name: Set up dependencies
80+
run: composer i
81+
82+
- name: Regenerate OpenAPI
83+
run: composer run openapi
84+
85+
- name: Check openapi*.json and typescript changes
86+
run: |
87+
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please run \"composer run openapi\" and commit the openapi*.json files and (if applicable) src/types/openapi/openapi*.ts, see the section \"Show changes on failure\" for details' && exit 1)"
88+
89+
- name: Show changes on failure
90+
if: failure()
91+
run: |
92+
git status
93+
git --no-pager diff
94+
exit 1

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"psalm:info": "psalm --no-diff --show-info=true",
5454
"psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",
5555
"psalm:baseline:update": "psalm --update-baseline",
56+
"openapi": "php vendor-bin/openapi-extractor/vendor/nextcloud/openapi-extractor/generate-spec.php",
57+
"generate-spec": "@openapi",
5658
"bin": "echo 'bin not installed'",
5759
"post-install-cmd": [
5860
"@composer bin all install --ansi",

0 commit comments

Comments
 (0)