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

3x dev #43

Merged
merged 6 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
version: 2
updates:
- package-ecosystem: composer
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
time: "17:00"
open-pull-requests-limit: 10
interval: "weekly"
16 changes: 11 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ name: build
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
call-laravel:
uses: DerManoMann/openapi-router/.github/workflows/laravel.yml@master
uses: ./.github/workflows/laravel.yml
with:
php-versions: '8.1,8.2,8.3,8.4'
call-lumen:
uses: DerManoMann/openapi-router/.github/workflows/lumen.yml@master
uses: ./.github/workflows/lumen.yml
with:
php-versions: '8.1,8.2,8.3,8.4'
call-slim:
uses: DerManoMann/openapi-router/.github/workflows/slim.yml@master
uses: ./.github/workflows/slim.yml
with:
php-versions: '8.1,8.2,8.3,8.4'
8 changes: 4 additions & 4 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ name: code-style
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
php-cs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout repository

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'

- uses: ramsey/composer-install@v1
with:
Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: laravel

on:
workflow_call:
inputs:
php-versions:
required: true
type: string

jobs:
test:
Expand All @@ -13,26 +17,19 @@ jobs:
fail-fast: true
matrix:
operating-system: [ ubuntu-latest ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
laravel: [ '7.0', '8.0', '9.0' ]
php: ${{ fromJson(format('[{0}]', inputs.php-versions)) }}
laravel: [ '10.0', '11.0' ]
dependencies: [ 'lowest', ' highest' ]
exclude:
- php: '7.2'
laravel: '9.0'
- php: '7.2'
laravel: '8.0'
- php: '7.3'
laravel: '9.0'
- php: '7.4'
laravel: '9.0'
- php: '8.1'
laravel: '7.0'
- dependencies: 'lowest'
laravel: '11.0'
- laravel: '11.0'
dependencies: 'lowest'

name: PHP ${{ matrix.php }} / Laravel ${{ matrix.laravel }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout repository

- name: Setup PHP
Expand Down
23 changes: 7 additions & 16 deletions .github/workflows/lumen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: lumen

on:
workflow_call:
inputs:
php-versions:
required: true
type: string

jobs:
test:
Expand All @@ -13,27 +17,14 @@ jobs:
fail-fast: true
matrix:
operating-system: [ ubuntu-latest ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
lumen: [ '8.0', '9.0' ]
php: ${{ fromJson(format('[{0}]', inputs.php-versions)) }}
lumen: [ '10.0' ]
dependencies: [ 'highest' ]
exclude:
- php: '7.2'
lumen: '9.0'
- php: '7.2'
lumen: '8.0'
- php: '7.3'
lumen: '9.0'
- php: '7.4'
lumen: '9.0'
- php: '8.1'
lumen: '8.0'
- php: '8.1'
dependencies: 'lowest'

name: PHP ${{ matrix.php }} / Lumen ${{ matrix.lumen }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout repository

- name: Setup PHP
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/security-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,25 @@ name: security-checks
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
security-checker:
runs-on: ${{ matrix.operating-system }}
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: true
matrix:
operating-system: [ ubuntu-latest ]
php: [ '8.0', '8.1' ]
php: [ '8.1', '8.2', '8.3', '8.4' ]
dependencies: [ 'highest' ]

name: PHP ${{ matrix.php }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout repository

- name: Setup PHP
Expand All @@ -33,15 +30,15 @@ jobs:
php-version: ${{ matrix.php }}

- name: Composer install
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.composer-options }} --no-dev

- name: Cache security checker dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.symfony/cache
key: security-checker-db

- uses: symfonycorp/security-checker-action@v2
- uses: symfonycorp/security-checker-action@v5
11 changes: 6 additions & 5 deletions .github/workflows/slim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: slim

on:
workflow_call:
inputs:
php-versions:
required: true
type: string

jobs:
test:
Expand All @@ -13,17 +17,14 @@ jobs:
fail-fast: true
matrix:
operating-system: [ ubuntu-latest ]
php: [ '8.0', '8.1' ]
php: ${{ fromJson(format('[{0}]', inputs.php-versions)) }}
slim: [ '4.0' ]
dependencies: [ 'lowest', 'highest' ]
exclude:
- php: '8.1'
dependencies: 'lowest'

name: PHP ${{ matrix.php }} / Slim ${{ matrix.slim }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout repository

- name: Setup PHP
Expand Down
57 changes: 28 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Introduction
Allows to (re-)use [Swagger-PHP](https://github.com/zircote/swagger-php) annotations to configure routes in the
following frameworks:
Allows to (re-)use [Swagger-PHP](https://github.com/zircote/swagger-php) attributes (docblock annotations are deprecated),
to configure routes in the following frameworks:

* [Laravel](https://github.com/laravel/laravel)
* [Lumen](https://github.com/laravel/lumen)
* [Slim](https://github.com/slimphp/Slim)


## Requirements
* [PHP 7.2 or higher](http://www.php.net/) - depending on framework version.
* [PHP 8.1 or higher](http://www.php.net/) - depending on framework version.

## Installation

Expand All @@ -34,7 +35,30 @@ After that all required classes should be availabe in your project to add routin

## Basic usage

Example using the `Slim` framework adapter and standard [OpenApi annotations](https://github.com/zircote/swagger-php/tree/master/src/Annotations) only.
Example using the `Slim` framework adapter and standard [OpenApi attributes](https://zircote.github.io/swagger-php/guide/attributes) only.

**Controller**
```php
<?php

namespace MyApp\Controllers\V1;

use OpenApi\Attributes as OA;
use Radebatz\OpenApi\Extras\Attributes as OAX;

/* Things shared by all endpoints in this controller.*/
#[OAX\Controller(prefix: '/api/v1')]
#[OA\Response(response: 200, description: 'OK')]
#[OAX\Middleware(names: ['auth', 'admin'])]
class GetController
{
#[OA\Get(path: '/getme', operationId: 'getme')]
#[OA\Response(response: 400, description: 'Not good enough')]
public function getme($request, $response) {
return $response->write('Get me');
}
}
```

**index.php**
```php
Expand All @@ -53,33 +77,8 @@ $app = new App();
$app->run();
```

**Controller**
```php
<?php

namespace MyApp\Controllers;

class GetController
{

/**
* @OA\Get(
* path="/getme",
* x={
* "name": "getme"
* },
* @OA\Response(response="200", description="All good")
* )
*/
public function getme($request, $response) {
return $response->write('Get me');
}
}
```

## Documentation
* [Configuration](docs/Configuration.md)
* [Annotation extensions](docs/AnnotationExtensions.md)

## License

Expand Down
4 changes: 0 additions & 4 deletions TODO

This file was deleted.

23 changes: 13 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,27 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-main": "3.x-dev"
}
},
"require": {
"php": ">=7.2",
"doctrine/annotations": "^1.13",
"psr/simple-cache": "^1.0 || ^2.0",
"zircote/swagger-php": "^4.2.3"
"php": ">=8.1",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"radebatz/openapi-extras": "^2.1",
"slim/slim": "^4.14",
"zircote/swagger-php": "^4.11.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17 || ^3.0",
"doctrine/annotations": "^2.0",
"friendsofphp/php-cs-fixer": "^3.0",
"nyholm/psr7": "^1.4",
"nyholm/psr7-server": "^1.0",
"phpunit/phpunit": ">=8.0",
"symfony/cache": "^5.0 || ^6.0",
"symfony/psr-http-message-bridge": "^2.1"
"phpunit/phpunit": "^9.0 || ^10.5",
"symfony/cache": "^6.0 || ^7.0",
"symfony/psr-http-message-bridge": "^6.0 || ^7.0"
},
"suggest": {
"radebatz/openapi-verifier": "Allows your PHPUnit tests to validate your controller response against the OpenAPI annotations."
"radebatz/openapi-verifier": "Allows your PHPUnit tests to validate your controller response against your OpenAPI spec."
}
}
Loading
Loading