Skip to content

Commit 4d7ee61

Browse files
committed
ISSUE-344: api doc
1 parent d93647d commit 4d7ee61

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

.github/workflows/restapi-docs.yml

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