Skip to content

Commit b517cd8

Browse files
TatevikGrtatevikg1
andauthoredMar 5, 2025··
Api updates (#143)
* ISSUE-344: api doc * ISSUE-344: update core version * ISSUE-344: add get subscriber by id route * ISSUE-344: add docs workflow * ISSUE-344: install from branch * ISSUE-344: fix parameter names * ISSUE-344: refactor * ISSUE-344: update action version * ISSUE-344: update configs * ISSUE-344: add fields in normalizer * ISSUE-344: fix warning * ISSUE-344: fix style * ISSUE-344: core version update --------- Co-authored-by: Tatevik <[email protected]>
1 parent d93647d commit b517cd8

12 files changed

+361
-130
lines changed
 

‎.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
dependencies: ['latest', 'oldest']
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
3030
- name: Setup PHP, with composer and extensions
3131
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
3232
with:
@@ -41,7 +41,7 @@ jobs:
4141
id: composer-cache
4242
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
4343
- name: Cache composer dependencies
44-
uses: actions/cache@v2
44+
uses: actions/cache@v3
4545
with:
4646
path: ${{ steps.composer-cache.outputs.dir }}
4747
# Use composer.json for key, if composer.lock is not committed.

‎.github/workflows/restapi-docs.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish REST API Docs
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
make-restapi-docs:
10+
name: Checkout phpList rest-api and generate docs specification (OpenAPI latest-restapi.json)
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: Setup PHP with Composer and Extensions
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: 8.1
20+
extensions: mbstring, dom, fileinfo, mysql
21+
22+
- name: Cache Composer Dependencies
23+
uses: actions/cache@v3
24+
with:
25+
path: ~/.composer/cache
26+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-composer-
29+
30+
- name: Install Composer Dependencies
31+
run: composer install --no-interaction --prefer-dist
32+
33+
- name: Generate OpenAPI Specification JSON
34+
run: vendor/bin/openapi -o docs/latest-restapi.json --format json src
35+
36+
- name: Upload REST API Specification
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: restapi-json
40+
path: docs/latest-restapi.json
41+
42+
deploy-docs:
43+
name: Deploy REST API Specification
44+
runs-on: ubuntu-20.04
45+
needs: make-restapi-docs
46+
steps:
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: 14
51+
52+
- name: Install openapi-checker
53+
run: npm install -g swagger-cli
54+
55+
- name: Checkout REST API Docs Repository
56+
uses: actions/checkout@v3
57+
with:
58+
repository: phpList/restapi-docs
59+
fetch-depth: 0
60+
token: ${{ secrets.PUSH_REST_API_DOCS }}
61+
62+
- name: Download Generated REST API Specification
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: restapi-json
66+
path: docs
67+
68+
- name: Validate OpenAPI Specification
69+
run: swagger-cli validate docs/latest-restapi.json
70+
71+
- name: Compare Specifications
72+
run: git diff --no-index --output=restapi-diff.txt docs/latest-restapi.json restapi.json || true
73+
74+
- name: Check Differences and Decide Deployment
75+
id: allow-deploy
76+
run: |
77+
if [ -s restapi-diff.txt ]; then
78+
echo "Updates detected in the REST API specification. Proceeding with deployment.";
79+
echo 'DEPLOY=true' >> $GITHUB_ENV;
80+
else
81+
echo "No changes detected in the REST API specification. Skipping deployment.";
82+
echo 'DEPLOY=false' >> $GITHUB_ENV;
83+
fi
84+
85+
- name: Commit and Deploy Updates
86+
if: env.DEPLOY == 'true'
87+
run: |
88+
mv docs/latest-restapi.json docs/restapi.json
89+
git config user.name "github-actions"
90+
git config user.email "github-actions@restapi-docs.workflow"
91+
git add docs/restapi.json
92+
git commit -m "Update REST API documentation `date`"
93+
git push

‎composer.json

+1-4
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": "v5.0.0-alpha3",
3535
"friendsofsymfony/rest-bundle": "*",
3636
"symfony/test-pack": "^1.0",
3737
"symfony/process": "^6.4",
@@ -85,9 +85,6 @@
8585
]
8686
},
8787
"extra": {
88-
"branch-alias": {
89-
"dev-ISSUE-337": "5.0.x-dev"
90-
},
9188
"symfony-app-dir": "bin",
9289
"symfony-bin-dir": "bin",
9390
"symfony-var-dir": "var",

‎config/services.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
services:
22
Psr\Container\ContainerInterface:
3-
alias: 'service_container'
3+
alias: 'service_container'
44

55
PhpList\RestBundle\Controller\:
66
resource: '../src/Controller'
77
public: true
88
autowire: true
99
tags: ['controller.service_arguments']
1010

11-
# Symfony\Component\Serializer\SerializerInterface:
12-
# autowire: true
13-
# autoconfigure: true
11+
# Symfony\Component\Serializer\SerializerInterface:
12+
# autowire: true
13+
# autoconfigure: true
1414

1515
my.secure_handler:
16-
class: \PhpList\RestBundle\ViewHandler\SecuredViewHandler
16+
class: PhpList\RestBundle\ViewHandler\SecuredViewHandler
1717

1818
my.secure_view_handler:
1919
parent: fos_rest.view_handler.default
@@ -35,3 +35,6 @@ services:
3535
PhpList\RestBundle\EventListener\ResponseListener:
3636
tags:
3737
- { name: kernel.event_listener, event: kernel.response }
38+
PhpList\RestBundle\Serializer\SubscriberNormalizer:
39+
tags: [ 'serializer.normalizer' ]
40+
autowire: true

‎docs/.gitkeep

Whitespace-only changes.

‎openapi.yaml

-55
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.