Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gueff/mymvc_module_openapi
OpenAPI module for myMVC
https://github.com/gueff/mymvc_module_openapi
mymvc mymvc-module openapi php php-framework
Last synced: 9 days ago
JSON representation
OpenAPI module for myMVC
- Host: GitHub
- URL: https://github.com/gueff/mymvc_module_openapi
- Owner: gueff
- License: gpl-3.0
- Created: 2022-10-20T13:50:22.000Z (over 2 years ago)
- Default Branch: 1.x
- Last Pushed: 2024-01-15T15:18:06.000Z (about 1 year ago)
- Last Synced: 2024-12-12T22:08:48.719Z (2 months ago)
- Topics: mymvc, mymvc-module, openapi, php, php-framework
- Language: PHP
- Homepage:
- Size: 62.5 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE.md
Awesome Lists containing this project
README
# myMVC_module_OpenApi
## Requirements
- Linux
- php >= 8
- `pdo` extension
- myMVC 3.x
- `git clone --branch 3.x https://github.com/gueff/myMVC.git myMVC_3.x`
- Docs:
- github:---
## Installation
_git clone_
~~~bash
cd /modules/;git clone --branch 1.x \
https://github.com/gueff/myMVC_module_OpenApi.git \
OpenApi;
~~~---
## Usage
_validate against openapi **file**_
~~~php
use OpenApi\Model\Validate;$oDTValidateRequestResponse = Validate::request(
$oDTRequestCurrent,
Config::get_MVC_PUBLIC_PATH() . '/openapi/api.yaml'
);header('Content-Type: application/json');
echo json_encode(Convert::objectToArray($oDTValidateRequestResponse));
~~~_validate against openapi **URL**_
~~~php
use OpenApi\Model\Validate;// validate against openapi URL
$oDTValidateRequestResponse = Validate::request(
$oDTRequestCurrent,
'https://example.com/api/openapi.yaml'
);header('Content-Type: application/json');
echo json_encode(Convert::objectToArray($oDTValidateRequestResponse));
~~~**auto-creating myMVC Routes from openapi file**
_All Routes lead to their given `operationId`, set in openapi_
~~~php
\OpenApi\Model\Route::autoCreateFromOpenApiFile(
Config::get_MVC_PUBLIC_PATH() . '/openapi/api.yaml',
'\Foo\Controller\Api'
);
~~~_All Routes lead explicitely to `Api::delegate()`_
~~~php
\OpenApi\Model\Route::autoCreateFromOpenApiFile(
Config::get_MVC_PUBLIC_PATH() . '/openapi/api.yaml',
'\Foo\Controller\Api',
'delegate'
);
~~~---
## Get Logs
Logs are fired to Events.
Available events are:
- `myMVC_module_OpenApi::sYamlSource`
_listen to event and write its content to a logfile_
~~~php
\MVC\Event::bind('myMVC_module_OpenApi::sYamlSource', function($sContent){
\MVC\Log::write($sContent, 'openapi.log');
});
~~~