-
Notifications
You must be signed in to change notification settings - Fork 2
[WIP] open api 3 spec dynamic generation #1
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
Open
stefanorosanelli
wants to merge
22
commits into
master
Choose a base branch
from
feat/open-api-dynamic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 fea1568
feat: spec generation with array config + templates
stefanorosanelli 82c58fd
chore: introduce api/core dependencies
stefanorosanelli cf17c00
test: allow BE integration tests against`API` and `Core` plugins
stefanorosanelli 03a2906
chore: travis build with sqlite only
stefanorosanelli 886872c
chore: simplified testing -temporary removed `prefer lowest`
stefanorosanelli f0bc2b8
chore: core and api test classes autoload
stefanorosanelli d8850ed
chore: travis `before_script` - temporary removed code coverage
stefanorosanelli aec0dbc
chore: add empty `tmp/` (for tests only)
stefanorosanelli 61f42c6
chore: remove unused folder
stefanorosanelli be8a005
refactor: test plugin app contains all test config
stefanorosanelli 46b14fe
chore: test plugin app namespace
stefanorosanelli 165c73b
chore: restore code coverage via travis / codecov
stefanorosanelli 8bbb0f7
feat: multiple files config + dynamic types
stefanorosanelli fb222df
test: improve coverage - clear() method
stefanorosanelli c95b437
chore: docblock updates [ci skip]
stefanorosanelli 3705008
[minor] chore: typo on description [ci skip]
stefanorosanelli 127322c
Merge branch 'master' into feat/open-api-dynamic
stefanorosanelli 77c8eb9
chore: avoid plugin version conflicts for now - use `*` temporary
stefanorosanelli 1d7c8a5
Merge branch 'master' into feat/open-api-dynamic
stefanorosanelli 9cfef2e
fix: update JsonSchema namespace
stefanorosanelli 864161e
fix: replace deprecated `url` attribute
stefanorosanelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' => [], | ||
| ], | ||
| ]; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
|
|
||
| ], | ||
| ] | ||
| ], | ||
| ]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.