Skip to content

Commit c005d4d

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

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

.github/workflows/restapi-docs.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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 `phpDocumentor`
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
26+
- name: Install phpDocumentor
27+
run: |
28+
wget https://phpdoc.org/phpDocumentor.phar
29+
chmod +x phpDocumentor.phar
30+
mv phpDocumentor.phar /usr/local/bin/phpDocumentor
31+
- name: Verify phpDocumentor version
32+
run: phpDocumentor --version
33+
- name: Generate documentation
34+
run: composer run-php-documentor
35+
- name: Zip phpDocumentor directory
36+
run: zip -r phpdocumentor.zip docs/phpdocumentor
37+
- name: Upload generated doc files
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: doc-files
41+
path: phpdocumentor.zip
42+
deploy-docs:
43+
name: Deploy Core Docs
44+
runs-on: ubuntu-20.04
45+
needs: make-restapi-docs
46+
steps:
47+
- name: Checkout phplist/core-docs
48+
uses: actions/checkout@v3
49+
with:
50+
repository: phpList/core-docs
51+
fetch-depth: 0
52+
token: ${{ secrets.PUSH_CORE_DOCS }}
53+
- name: Restore REST API Spec
54+
uses: actions/download-artifact@v4
55+
with:
56+
name: doc-files
57+
- name: Unzip phpDocumentor
58+
run: |
59+
unzip phpdocumentor.zip
60+
rm phpdocumentor.zip
61+
- name: List Files
62+
run: ls
63+
- name: Sync old files with newly generated ones
64+
run: rsync -av docs/phpdocumentor/* .
65+
- name: Remove temporary directories
66+
run: rm -rf docs
67+
- name: Check if updates/changes
68+
run: git status --porcelain > repo-changes.txt
69+
- name: Check changes file
70+
run: cat repo-changes.txt
71+
- name: Verify updates
72+
id: allow-deploy
73+
run: |
74+
if [ -s repo-changes.txt ]; then
75+
echo "Updates made to documentation";
76+
echo 'DEPLOY=true' >> $GITHUB_ENV;
77+
else
78+
echo "No updates made to documentation. Deployment would be skipped.";
79+
echo 'DEPLOY=false' >> $GITHUB_ENV;
80+
fi
81+
- name: Commit changes and deploy
82+
if: ${{ env.DEPLOY == 'true' }}
83+
run: |
84+
rm repo-changes.txt
85+
git config user.name "github-actions"
86+
git config user.email "github-actions@restapi-docs.workflow"
87+
git add .
88+
git commit -s -m "phplist/core docs deployment `date`"
89+
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)