Skip to content

Commit 1986e45

Browse files
committed
merge main
2 parents 3453581 + 5307afd commit 1986e45

File tree

5 files changed

+56
-11
lines changed

5 files changed

+56
-11
lines changed

.github/CONTRIBUTING.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,43 @@ have a chance of keeping on top of things:
6060
8. Add a changelog entry.
6161
9. [Commit](#git-commits) and push your changes.
6262
10. [Create a pull request](https://help.github.com/articles/about-pull-requests/)
63-
for your changes. Check that the Travis build is green. (If it is not, fix the
64-
problems listed by Travis.)
63+
for your changes. Check that the [Github actions](https://github.com/phpList/rest-api/actions/workflows/ci.yml) build is green. (If it is not, fix the
64+
problems listed by [Github actions](https://github.com/phpList/rest-api/actions/workflows/ci.yml).)
6565
We have provided a template for pull requests as well.
6666
11. [Request a review](https://help.github.com/articles/about-pull-request-reviews/).
6767
11. Together with your reviewer, polish your changes until they are ready to be
6868
merged.
6969

70+
## API Documenting with `OPENAPI`
71+
72+
Controllers are annotated with the [`OpenAPI`](https://swagger.io/docs/specification/about/) specification using the `PHPDoc` implementation from [zircote/swagger-php](https://github.com/zircote/swagger-php).
73+
74+
If you add or modify existing annotations, you should run `composer openapi-generate` to have the updated openapi decription of the API.
75+
76+
### Notes
77+
- `composer openapi-generate` produces `openapi.json` in `docs/`
78+
- The generated `docs/openapi.json` is excluded in commits. _See .gitignore_
79+
- The only reason you should generate `openapi.json` is for debugging and testing.
80+
81+
### Debugging `openapi.json` description.
82+
83+
To ensure builds pass and new annotations are deployed, do validate `openapi.json` by copy-pasting it's content in `https://validator.swagger.io/`
84+
85+
In addition you can also use the [openapi-checker](github.com/phplist/openapi-checker) to validate you file as follows;
86+
87+
- `npm install -g openapi-checker`
88+
- `openapi-checker docs/openapi.json`
89+
90+
### More on `composer openapi-generate`
91+
92+
`composer openapi-generate` basically runs `vendor/bin/openapi -o docs/openapi.json --format json src` defined in the scripts section of `composer.json` which as mentioned above generates `openapi.json` description file in the `docs/` directory.
93+
94+
### Swagger UI
95+
96+
[Swagger UI](https://github.com/swagger-api/swagger-ui) is used to visualize generated api description and is visible at [phplist.github.io/restapi-docs](https://phplist.github.io/restapi-docs) after a successful CI build.
97+
98+
You might also achieve local visualization by cloning [phplist/restapi-docs](https://github.com/phpList/restapi-docs) and temporally changing the `url` property of `SwaggerUIBundle` to point to your generated file.
99+
70100

71101
## Unit-test your changes
72102

.github/workflows/ci.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,29 @@ jobs:
4848
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
4949
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
5050
restore-keys: ${{ runner.os }}-composer-
51-
- name: Install the lowest dependencies
52-
run: composer update --with-dependencies --prefer-stable --prefer-dist --prefer-lowest
51+
- name: Install dependencies
52+
run: composer update --with-dependencies --prefer-stable --prefer-dist
5353
if: ${{ matrix.dependencies }} == "latest"
5454
- name: Install current dependencies from composer.lock
5555
run: composer install
56-
if: ${{ matrix.dependencies }} == "oldest"
5756
- name: Set up database schema
5857
run: mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} ${{ env.DB_DATABASE }} < vendor/phplist/core/resources/Database/Schema.sql
5958
- name: Validating composer.json
6059
run: composer validate --no-check-all --no-check-lock --strict;
6160
- name: Linting all php files
6261
run: find src/ tests/ public/ -name ''*.php'' -print0 | xargs -0 -n 1 -P 4 php -l; php -l;
63-
- name: Run integration tests with phpunit
64-
run: vendor/bin/phpunit tests/Integration/
65-
- name: Running the system tests
66-
run: vendor/bin/phpunit tests/System/;
62+
- name: Running unit tests
63+
run: vendor/bin/phpunit tests/Unit/;
64+
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
65+
- name: Running the integration tests
66+
run: |
67+
export PHPLIST_DATABASE_NAME=${{ env.DB_DATABASE }}
68+
export PHPLIST_DATABASE_USER=${{ env.DB_USERNAME }}
69+
export PHPLIST_DATABASE_PASSWORD=${{ env.DB_PASSWORD }}
70+
export PHPLIST_DATABASE_PORT=${{ job.services.mysql.ports['3306'] }}
71+
export PHPLIST_DATABASE_HOST=127.0.0.1
72+
vendor/bin/phpunit tests/Integration/
73+
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
6774
- name: Running static analysis
6875
run: vendor/bin/phpstan analyse -l 5 src/ tests/;
6976
- name: Running PHPMD

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/config/config_modules.yml
1010
/config/parameters.yml
1111
/config/routing_modules.yml
12+
/docs/openapi.json
1213
/nbproject
1314
/public/
1415
/var/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ which also has more detailed installation instructions in the README.
4040

4141
Visit `/docs` endpoint to access the full interactive documentation for `phpList/rest-api`.
4242

43+
Look at the **"API Documentation with Swagger"** section in the [contribution guide](.github/CONTRIBUTING.md) for more information on API documenation.
44+
4345
## Local demo with Postman
4446

4547
You can try out the API using pre-prepared requests and the Postman GUI

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
"homepage": "https://www.phplist.com/",
1414
"license": "AGPL-3.0-or-later",
1515
"authors": [
16+
{
17+
"name": "Xheni Myrtaj",
18+
"email": "xheni@phplist.com",
19+
"role": "Maintainer"
20+
},
1621
{
1722
"name": "Oliver Klee",
1823
"email": "oliver@phplist.com",
19-
"role": "Developer"
24+
"role": "Former developer"
2025
}
2126
],
2227
"support": {
@@ -90,7 +95,7 @@
9095
},
9196
"extra": {
9297
"branch-alias": {
93-
"dev-ISSUE-337": "5.0.x-dev"
98+
"dev-master": "5.0.x-dev"
9499
},
95100
"symfony-app-dir": "bin",
96101
"symfony-bin-dir": "bin",

0 commit comments

Comments
 (0)