Download the PHP package ybelenko/openapi-data-mocker-server-middleware without Composer
On this page you can find all versions of the php package ybelenko/openapi-data-mocker-server-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package openapi-data-mocker-server-middleware
Openapi Data Mocker Server Middleware
PSR-15 HTTP Server Middleware to create mock responses from OpenAPI Schemas(OAS 3.0). This package was an enhancement of PHP Slim4 server in OpenAPI Generator project, but it easier to maintain it in separated repo.
Requirements
- PHP ^7.3
Important notice! While PHP 8.0 declared in composer.json this package hasn't been tested against it.
Installation via Composer
Run in terminal:
Constructor Arguments
$mocker: OpenApiDataMockerInterface
- is mocker class instance. To create custom data mocker extend
OpenAPIServer\Mock\OpenApiDataMockerInterface
.
- is mocker class instance. To create custom data mocker extend
$responses: array
- Array with OAS3 response definitions of applied route. Check examples/get_mock_responses.php file.
$responseFactory: ResponseFactoryInterface
- Any PSR-17 compliant response factory. PSR-17: HTTP Factories - 2.2 ResponseFactoryInterface
$getMockStatusCodeCallback: callable|null = null
- is callback before mock data generation. Below example shows how to enable mock feature for only requests with
X-OpenAPIServer-Mock: ping
HTTP header. Adjust requests filtering to fit your project requirements. This function must return single response schema from$responses
array parameter. Mock feature is disabled when callback returns anything beside existent key from$responses
array, eg'default'
or200
.
- is callback before mock data generation. Below example shows how to enable mock feature for only requests with
$afterCallback: callable|null = null
- is callback executed after mock data generation. Most obvious use case is append specific HTTP headers to distinguish real and fake responses. This function must always return response instance.
Usage Example
All versions of openapi-data-mocker-server-middleware with dependencies
PHP Build Version
Package Version
Requires
php Version
^7.3 || ^8.0
psr/http-server-middleware Version ^1.0
psr/http-factory Version ^1.0
ybelenko/openapi-data-mocker-interfaces Version ^1.0.0
psr/http-server-middleware Version ^1.0
psr/http-factory Version ^1.0
ybelenko/openapi-data-mocker-interfaces Version ^1.0.0
The package ybelenko/openapi-data-mocker-server-middleware contains the following files
Loading the files please wait ....