Skip to content

Commit 92e5475

Browse files
committed
ISSUE-344: api doc
1 parent d93647d commit 92e5475

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

.github/workflows/restapi-docs.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Publish Core Docs
2+
on: [push, pull_request]
3+
4+
jobs:
5+
make-restapi-docs:
6+
name: Checkout phpList core and generate docs using `openapi`
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
- name: Setup PHP, with composer and extensions
12+
uses: shivammathur/setup-php@v2
13+
with:
14+
php-version: 8.1
15+
extensions: mbstring, dom, fileinfo, mysql
16+
- name: Get composer cache directory
17+
id: composer-cache
18+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
19+
- name: Cache composer dependencies
20+
uses: actions/cache@v3
21+
with:
22+
path: ${{ env.dir }}
23+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
24+
restore-keys: ${{ runner.os }}-composer-
25+
- name: Install current dependencies from composer.lock
26+
run: composer install --no-interaction --prefer-dist
27+
- name: Ensure docs directory exists
28+
run: mkdir -p docs
29+
- name: Generate OpenAPI documentation
30+
run: php vendor/bin/openapi --output docs/openapi.json src/
31+
- name: Zip OpenAPI documentation
32+
run: zip -r openapi-docs.zip docs/openapi.json
33+
- name: Upload generated doc files
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: doc-files
37+
path: openapi-docs.zip
38+
39+
deploy-docs:
40+
name: Deploy Core Docs
41+
runs-on: ubuntu-20.04
42+
needs: make-restapi-docs
43+
steps:
44+
- name: Checkout phplist/core-docs
45+
uses: actions/checkout@v3
46+
with:
47+
repository: phpList/core-docs
48+
fetch-depth: 0
49+
token: ${{ secrets.PUSH_CORE_DOCS }}
50+
- name: Restore OpenAPI Spec
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: doc-files
54+
- name: Unzip OpenAPI documentation
55+
run: |
56+
unzip openapi-docs.zip
57+
rm openapi-docs.zip
58+
- name: List Files
59+
run: ls
60+
- name: Sync old files with newly generated ones
61+
run: rsync -av docs/openapi.json .
62+
- name: Remove temporary directories
63+
run: rm -rf docs
64+
- name: Check if updates/changes
65+
run: git status --porcelain > repo-changes.txt
66+
- name: Check changes file
67+
run: cat repo-changes.txt
68+
- name: Verify updates
69+
id: allow-deploy
70+
run: |
71+
if [ -s repo-changes.txt ]; then
72+
echo "Updates made to documentation";
73+
echo 'DEPLOY=true' >> $GITHUB_ENV;
74+
else
75+
echo "No updates made to documentation. Deployment would be skipped.";
76+
echo 'DEPLOY=false' >> $GITHUB_ENV;
77+
fi
78+
- name: Commit changes and deploy
79+
if: ${{ env.DEPLOY == 'true' }}
80+
run: |
81+
rm repo-changes.txt
82+
git config user.name "github-actions"
83+
git config user.email "[email protected]"
84+
git add .
85+
git commit -s -m "phplist/core docs deployment `date`"
86+
git push origin main --force

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"require": {
3333
"php": "^8.1",
34-
"phplist/core": "dev-ISSUE-337",
34+
"phplist/core": "dev-main",
3535
"friendsofsymfony/rest-bundle": "*",
3636
"symfony/test-pack": "^1.0",
3737
"symfony/process": "^6.4",

src/Controller/SubscriberController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939

4040
#[Route('/subscribers', name: 'create_subscriber', methods: ['POST'])]
4141
#[OA\Post(
42-
path: '/subscriber',
42+
path: '/subscribers',
4343
description: 'Creates a new subscriber (if there is no subscriber with the given email address yet).',
4444
summary: 'Create a subscriber',
4545
requestBody: new OA\RequestBody(

0 commit comments

Comments
 (0)