Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-344: api updates #143

Merged
merged 13 commits into from
Mar 5, 2025
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
dependencies: ['latest', 'oldest']
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
Expand All @@ -41,7 +41,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/restapi-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Publish REST API Docs
on:
push:
branches:
- main
pull_request:

jobs:
make-restapi-docs:
name: Checkout phpList rest-api and generate docs specification (OpenAPI latest-restapi.json)
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup PHP with Composer and Extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: mbstring, dom, fileinfo, mysql

- name: Cache Composer Dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer Dependencies
run: composer install --no-interaction --prefer-dist

- name: Generate OpenAPI Specification JSON
run: vendor/bin/openapi -o docs/latest-restapi.json --format json src

- name: Upload REST API Specification
uses: actions/upload-artifact@v4
with:
name: restapi-json
path: docs/latest-restapi.json

deploy-docs:
name: Deploy REST API Specification
runs-on: ubuntu-20.04
needs: make-restapi-docs
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install openapi-checker
run: npm install -g swagger-cli

- name: Checkout REST API Docs Repository
uses: actions/checkout@v3
with:
repository: phpList/restapi-docs
fetch-depth: 0
token: ${{ secrets.PUSH_REST_API_DOCS }}

- name: Download Generated REST API Specification
uses: actions/download-artifact@v4
with:
name: restapi-json
path: docs

- name: Validate OpenAPI Specification
run: swagger-cli validate docs/latest-restapi.json

- name: Compare Specifications
run: git diff --no-index --output=restapi-diff.txt docs/latest-restapi.json restapi.json || true

- name: Check Differences and Decide Deployment
id: allow-deploy
run: |
if [ -s restapi-diff.txt ]; then
echo "Updates detected in the REST API specification. Proceeding with deployment.";
echo 'DEPLOY=true' >> $GITHUB_ENV;
else
echo "No changes detected in the REST API specification. Skipping deployment.";
echo 'DEPLOY=false' >> $GITHUB_ENV;
fi

- name: Commit and Deploy Updates
if: env.DEPLOY == 'true'
run: |
mv docs/latest-restapi.json docs/restapi.json
git config user.name "github-actions"
git config user.email "[email protected]"
git add docs/restapi.json
git commit -m "Update REST API documentation `date`"
git push
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"require": {
"php": "^8.1",
"phplist/core": "dev-ISSUE-337",
"phplist/core": "v5.0.0-alpha3",
"friendsofsymfony/rest-bundle": "*",
"symfony/test-pack": "^1.0",
"symfony/process": "^6.4",
Expand Down Expand Up @@ -85,9 +85,6 @@
]
},
"extra": {
"branch-alias": {
"dev-ISSUE-337": "5.0.x-dev"
},
"symfony-app-dir": "bin",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
Expand Down
13 changes: 8 additions & 5 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
services:
Psr\Container\ContainerInterface:
alias: 'service_container'
alias: 'service_container'

PhpList\RestBundle\Controller\:
resource: '../src/Controller'
public: true
autowire: true
tags: ['controller.service_arguments']

# Symfony\Component\Serializer\SerializerInterface:
# autowire: true
# autoconfigure: true
# Symfony\Component\Serializer\SerializerInterface:
# autowire: true
# autoconfigure: true

my.secure_handler:
class: \PhpList\RestBundle\ViewHandler\SecuredViewHandler
class: PhpList\RestBundle\ViewHandler\SecuredViewHandler

my.secure_view_handler:
parent: fos_rest.view_handler.default
Expand All @@ -35,3 +35,6 @@ services:
PhpList\RestBundle\EventListener\ResponseListener:
tags:
- { name: kernel.event_listener, event: kernel.response }
PhpList\RestBundle\Serializer\SubscriberNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true
Empty file added docs/.gitkeep
Empty file.
55 changes: 0 additions & 55 deletions openapi.yaml

This file was deleted.

Loading
Loading