Download the PHP package ybelenko/openapi-data-mocker without Composer
On this page you can find all versions of the php package ybelenko/openapi-data-mocker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package openapi-data-mocker
Openapi Data Mocker
Openapi Data Mocker helps to generate fake data from OpenAPI 3.0 documents. Most of the methods may work with 2.0 version(fka Swagger 2.0), but it's not tested. 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:
Usage example
Imagine we have OpenAPI Specification 3.0.3 - Schema Object like this:
Notice! While schema object presented in YAML format this library doesn't support YAML or JSON parsing right now. It means that
mockSchemaObject
method expects already decoded JSON value as argument.
When we mock mentioned schema with mockSchemaObject
method:
the output looks like:
Of course that output will be slightly different on every call. That's what mocker package has been developed for.
You can check extended example at examples/extended_example.php.
Supported features
All data types supported except specific string formats: email
, uuid
, password
which are poorly implemented.
Data Types Support
Data Type | Data Format | Supported |
---|---|---|
integer |
int32 |
:white_check_mark: |
integer |
int64 |
:white_check_mark: |
number |
float |
:white_check_mark: |
number |
double |
|
string |
byte |
:white_check_mark: |
string |
binary |
:white_check_mark: |
boolean |
:white_check_mark: | |
string |
date |
:white_check_mark: |
string |
date-time |
:white_check_mark: |
string |
password |
:white_check_mark: |
string |
email |
:white_check_mark: |
string |
uuid |
:white_check_mark: |
Data Options Support
Data Type | Option | Supported |
---|---|---|
string |
minLength |
:white_check_mark: |
string |
maxLength |
:white_check_mark: |
string |
enum |
:white_check_mark: |
string |
pattern |
|
integer |
minimum |
:white_check_mark: |
integer |
maximum |
:white_check_mark: |
integer |
exclusiveMinimum |
:white_check_mark: |
integer |
exclusiveMaximum |
:white_check_mark: |
number |
minimum |
:white_check_mark: |
number |
maximum |
:white_check_mark: |
number |
exclusiveMinimum |
:white_check_mark: |
number |
exclusiveMaximum |
:white_check_mark: |
array |
items |
:white_check_mark: |
array |
additionalItems |
|
array |
minItems |
:white_check_mark: |
array |
maxItems |
:white_check_mark: |
array |
uniqueItems |
|
object |
properties |
:white_check_mark: |
object |
maxProperties |
|
object |
minProperties |
|
object |
patternProperties |
|
object |
additionalProperties |
|
object |
required |
|
* |
$ref |
:white_check_mark: |
* |
allOf |
|
* |
anyOf |
|
* |
oneOf |
|
* |
not |
Known Limitations
Avoid circular refs in your schema. Schema below can cause infinite loop and Out of Memory
PHP error:
Don't ref scalar types, because generator will not produce models which mock server can find. So schema below will cause error: