Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e4c114d
feat: minimal open api 3 spec dynamic generation in `/tools/open-api`
stefanorosanelli Sep 22, 2017
fea1568
feat: spec generation with array config + templates
stefanorosanelli Dec 8, 2017
82c58fd
chore: introduce api/core dependencies
stefanorosanelli Dec 8, 2017
cf17c00
test: allow BE integration tests against`API` and `Core` plugins
stefanorosanelli Dec 8, 2017
03a2906
chore: travis build with sqlite only
stefanorosanelli Dec 8, 2017
886872c
chore: simplified testing -temporary removed `prefer lowest`
stefanorosanelli Dec 8, 2017
f0bc2b8
chore: core and api test classes autoload
stefanorosanelli Dec 8, 2017
d8850ed
chore: travis `before_script` - temporary removed code coverage
stefanorosanelli Dec 8, 2017
aec0dbc
chore: add empty `tmp/` (for tests only)
stefanorosanelli Dec 8, 2017
61f42c6
chore: remove unused folder
stefanorosanelli Dec 9, 2017
be8a005
refactor: test plugin app contains all test config
stefanorosanelli Dec 9, 2017
46b14fe
chore: test plugin app namespace
stefanorosanelli Dec 9, 2017
165c73b
chore: restore code coverage via travis / codecov
stefanorosanelli Dec 9, 2017
8bbb0f7
feat: multiple files config + dynamic types
stefanorosanelli Dec 11, 2017
fb222df
test: improve coverage - clear() method
stefanorosanelli Dec 11, 2017
c95b437
chore: docblock updates [ci skip]
stefanorosanelli Dec 11, 2017
3705008
[minor] chore: typo on description [ci skip]
stefanorosanelli Dec 13, 2017
127322c
Merge branch 'master' into feat/open-api-dynamic
stefanorosanelli Dec 13, 2017
77c8eb9
chore: avoid plugin version conflicts for now - use `*` temporary
stefanorosanelli Dec 13, 2017
1d7c8a5
Merge branch 'master' into feat/open-api-dynamic
stefanorosanelli Jun 26, 2020
9cfef2e
fix: update JsonSchema namespace
stefanorosanelli Jun 26, 2020
864161e
fix: replace deprecated `url` attribute
stefanorosanelli Jul 14, 2020
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
36 changes: 22 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ language: php
dist: trusty
sudo: false

php:
- 5.6
- 7.0
- 7.1
- hhvm

cache:
directories:
- vendor
Expand All @@ -18,13 +12,24 @@ jobs:
fast_finish: true

include:
- php: 7.0
env: "DB=sqlite db_dsn='sqlite:///tmp/test.sql'"

- php: 5.6
env: "PREFER_LOWEST=1"
install:
- composer install --prefer-dist --no-interaction
- composer update --prefer-dist --prefer-lowest --no-interaction
# Ensure PHPUnit is installed from source (i.e.: Git repository) otherwise a wrong version is being detected. :|
- rm -rf vendor/phpunit/phpunit vendor/bin/phpunit && COMPOSER_CACHE_DIR=/dev/null composer update --prefer-source --prefer-lowest --no-interaction
env: "DB=sqlite db_dsn='sqlite:///tmp/test.sql'"

# - php: 5.6
# env: "PREFER_LOWEST=1 DB=sqlite db_dsn='sqlite:///tmp/test.sql'"
# install:
# - composer install --prefer-dist --no-interaction
# - composer update --prefer-dist --prefer-lowest --no-interaction
# # Ensure PHPUnit is installed from source (i.e.: Git repository) otherwise a wrong version is being detected. :|
# - rm -rf vendor/phpunit/phpunit vendor/bin/phpunit && COMPOSER_CACHE_DIR=/dev/null composer update --prefer-source --prefer-lowest --no-interaction

- php: 7.1
env: "DB=sqlite db_dsn='sqlite:///tmp/test.sql'"
script: vendor/bin/phpunit --coverage-clover=clover.xml
after_success: bash <(curl -s https://codecov.io/bash)

- php: 7.0
env: "RUN=phpcs"
Expand Down Expand Up @@ -54,9 +59,12 @@ before_install:
install:
# Install Composer dependencies.
- composer install --prefer-dist --no-interaction
- if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ]; then composer require lorenzo/multiple-iterator=~1.0; fi

script: vendor/bin/phpunit --coverage-clover=clover.xml # Run PHPUnit.
before_script:
- phpenv rehash
- set +H

script: vendor/bin/phpunit # Run PHPUnit.

after_success: bash <(curl -s https://codecov.io/bash) # Upload test coverage reports to CodeCov.

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
}
],
"require": {
"cakephp/cakephp": ">=3.4.4, <4.0",
"cakephp/debug_kit": "~3.2 !=3.5.1"
"bedita/core": "dev-4-cactus",
"bedita/api": "dev-4-cactus",
"cakephp/debug_kit": "~3.10"
},
"require-dev": {
"phpunit/phpunit": "*",
Expand All @@ -37,6 +38,9 @@
"autoload-dev": {
"psr-4": {
"BEdita\\DevTools\\Test\\": "tests",
"BEdita\\App\\": "tests/TestPluginApp/src",
"BEdita\\Core\\Test\\": "./vendor/bedita/core/tests",
"BEdita\\API\\Test\\": "./vendor/bedita/api/tests",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
}
},
Expand Down
77 changes: 77 additions & 0 deletions config/OpenAPI/_open_api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
return [
/**
* OpenAPI main file.
*
* First configuration file loaded, contains spec main file structure in terms of 'openapi', 'info', 'servers',
* 'paths' and 'components'
* - some values will be changed dynamically, e.g. 'info.title'
* - keys like 'paths' and 'components' will be merged with arrays in other configuration files or dynamically created
*
* Other noteworthy configuration files:
* - `{name}_endpoint.php` - 'paths' and 'components' for a specific endpoint
* - `components.php` - common 'components'
* - `templates.php` - templates in `OATemplates` will be rendered usign actual resources and object types
*
*/
'OpenAPI' => [
'openapi' => '3.0.0',
'info' => [
'title' => '', // will be 'project name'
'description' => 'Auto-generated specification',
'version' => '', // will be 'BEdita version'
],
'servers' => [
[
'url' => '', // will be 'project base URL'
],
],
'paths' => [
'/status' => [
'get' => [
'summary' => 'API Status',
'description' => 'Service status response',
'tags' => ['status'],
'responses' => [
'200' => [
'description' => '',
'content' => [
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/status'
],
]
],
],
'401' => [
'$ref' => '#/components/responses/401',
],
],
],
],
'/home' => [
'get' => [
'summary' => 'API Home page',
'description' => 'Information on avilable endpoints and methods',
'tags' => ['home'],
'responses' => [
'200' => [
'description' => '',
'content' => [
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/home'
],
],
],
],
'401' => [
'$ref' => '#/components/responses/401',
],
],
],
],
],
'components' => [],
],
];
130 changes: 130 additions & 0 deletions config/OpenAPI/auth_endpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
return [
/**
* OpenAPI `auth/` specification
*/
'OpenAPI' => [
'paths' => [
'/auth' => [
'post' => [
'description' => "Authentication process and token renewal.
You do auth with POST /auth, passing auth data in as formData parameters. For instance:

```
username: johndoe
password: ******
```

You renew token with POST /auth, using header parameter Authorization. For example:

```
Authorization: 'Bearer eyJ0eXAiOi...2ljSerKQygk2T8'
```",
'summary' => 'Perform auth or renew token',
'tags' => ['auth'],

'parameters' => [
[
'in' => 'header',
'name' => 'Authorization',
'description' => "Use token prefixed with 'Bearer'",
'required' => false,
'type' => 'string',
],
],

'requestBody' => [
'description' => 'Login with username/password or renew auth token',
'required' => false,
'content' => [
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/auth_login'
],
],
'application/x-www-form-urlencoded' => [
'schema' => [
'$ref' => '#/components/schemas/auth_login'
],
],
],
],
'responses' => [
'200' => [
'description' => 'Successful login',
'content' => [
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/auth_success'
],
],
],
],
'401' => [
'$ref' => '#/components/responses/401',
],
],
],

'get' => [
'summary' => 'Get logged user profile data',
'tags' => ['auth'],
'responses' => [
'200' => [
'content' => [
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/users'
],
],
],
],
'401' => [
'$ref' => '#/components/responses/401',
],
],
],
],
],

// components used only in `auth/`
'components' => [

'schemas' => [

'auth_login' => [
'type' => 'object',
'properties' => [
'username' => [
'type' => 'string',
],
'password' => [
'type' => 'string',
],
],
],

'auth_success' => [
'type' => 'object',
'properties' => [
'links' => [
'$ref' => '#/components/schemas/links',
],
'meta' => [
'type' => 'object',
'properties' => [
'jwt' => [
'type' => 'string',
],
'renew' => [
'type' => 'string',
],
],
],
],
],

],
]
],
];
Loading