PHPackages                             ybelenko/openapi-data-mocker-interfaces - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. ybelenko/openapi-data-mocker-interfaces

ActiveLibrary[Testing &amp; Quality](/categories/testing)

ybelenko/openapi-data-mocker-interfaces
=======================================

Package with OpenApiDataMocker interfaces.

1.1.0(4y ago)030.5k↓45.9%12MITPHPPHP ^7.3 || ^8.0

Since Jun 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ybelenko/openapi-data-mocker-interfaces)[ Packagist](https://packagist.org/packages/ybelenko/openapi-data-mocker-interfaces)[ RSS](/packages/ybelenko-openapi-data-mocker-interfaces/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (7)Used By (2)

OpenApi Data Mocker Interfaces
==============================

[](#openapi-data-mocker-interfaces)

[![Coding Style](https://github.com/ybelenko/openapi-data-mocker-interfaces/actions/workflows/ci.yml/badge.svg)](https://github.com/ybelenko/openapi-data-mocker-interfaces/actions/workflows/ci.yml)

This repository holds interfaces to generate fake data from OpenAPI Specification(OAS3). Note that this is not an implementation.

Requirements
------------

[](#requirements)

PHP 7.3 or newer. It could work with older versions, but it's not worth to support *EOL(end of life)* PHP.

**Important notice! While PHP 8.0 declared in `composer.json` this package hasn't been tested against it.**

Interfaces
----------

[](#interfaces)

Class NameDescription[OpenAPIServer\\Mock\\OpenApiModelInterface](src/Mock/OpenApiModelInterface.php)All referenced components must implement that interface.[OpenAPIServer\\Mock\\OpenApiDataMockerInterface](src/Mock/OpenApiDataMockerInterface.php)Basic data generator. Can mock scalar data types.[OpenAPIServer\\Mock\\OpenApiServerMockerInterface](src/Mock/OpenApiServerMockerInterface.php)Enhanced data generator. Can mock server request and server response.[OpenAPIServer\\Mock\\Exceptions\\OpenApiDataMockerException](src/Mock/Exceptions/OpenApiDataMockerException.php)Implementation should throw exceptions inherited from that class.### `OpenAPIServer\Mock\OpenApiDataMockerInterface` Constants

[](#openapiservermockopenapidatamockerinterface-constants)

[OpenAPISpecification - Data Types](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#dataTypes)

Constant NameReferenced OAS typeReferenced OAS format`DATA_TYPE_INTEGER``integer``DATA_TYPE_NUMBER``number``DATA_TYPE_STRING``string``DATA_TYPE_BOOLEAN``boolean``DATA_TYPE_ARRAY``array``DATA_TYPE_OBJECT``object``DATA_FORMAT_INT32``int32``DATA_FORMAT_INT64``int64``DATA_FORMAT_FLOAT``float``DATA_FORMAT_DOUBLE``double``DATA_FORMAT_BYTE``byte``DATA_FORMAT_BINARY``binary``DATA_FORMAT_DATE``date``DATA_FORMAT_DATE_TIME``date-time``DATA_FORMAT_PASSWORD``password``DATA_FORMAT_EMAIL``DATA_FORMAT_UUID`### `OpenAPIServer\Mock\OpenApiDataMockerInterface` Methods

[](#openapiservermockopenapidatamockerinterface-methods)

Method NameDescriptionReturn Type`mockData(string $dataType, ?string $dataFormat = null, ?array $options = [])`Mocks OpenApi Data.`mixed``mockInteger(?string $dataFormat = null, ?float $minimum = null, ?float $maximum = null, ?bool $exclusiveMinimum = false, ?bool $exclusiveMaximum = false): int`Shortcut to mock integer type. Equivalent to `mockData(DATA_TYPE_INTEGER)`\*.`int``mockNumber($dataFormat = null, $minimum = null, $maximum = null, $exclusiveMinimum = false, $exclusiveMaximum = false): float`Shortcut to mock number type. Equivalent to `mockData(DATA_TYPE_NUMBER)`\*.`float``mockString(?string $dataFormat = null, ?int $minLength = 0, ?int $maxLength = null, ?array $enum = null, ?string $pattern = null): string`Shortcut to mock string type. Equivalent to `mockData(DATA_TYPE_STRING)`\*.`string``mockBoolean(): bool`Shortcut to mock boolean type. Equivalent to `mockData(DATA_TYPE_BOOLEAN)`\*`bool``mockArray(array $items, ?int $minItems = 0, ?int $maxItems = null, ?bool $uniqueItems = false): array`Shortcut to mock array type. `Equivalent to mockData(DATA_TYPE_ARRAY)`\*.`array``mockObject(array $properties, ?int $minProperties = 0, ?int $maxProperties = null, $additionalProperties = null, ?array $required = null): object`Shortcut to mock object type. Equivalent to `mockData(DATA_TYPE_OBJECT)`\*.`object``mockSchemaObject(array $schema)`Mocks OpenApi Schema Object.`mixed`\* constant class is omitted, so `mockData(DATA_TYPE_INTEGER)` means `mockData(\OpenAPIServer\Mock\OpenApiDataMockerInterface\DATA_TYPE_INTEGER)`.

### `OpenAPIServer\Mock\OpenApiModelInterface` Methods

[](#openapiservermockopenapimodelinterface-methods)

Method NameDescriptionReturn Typestatic `getOpenApiSchema(): array`Gets OAS 3.0 schema mapped to current class.`array`static `createFromData($data): OpenApiModelInterface`Creates new instance from provided data.`OpenAPIServer\Mock\OpenApiModelInterface``jsonSerialize()` inherited from `JsonSerializable`Serializes the object to a value that can be serialized natively by `json_encode()`.`mixed`### `OpenAPIServer\Mock\OpenApiServerMockerInterface` Methods

[](#openapiservermockopenapiservermockerinterface-methods)

Same methods as `OpenAPIServer\Mock\OpenApiDataMockerInterface` + following methods:

Method NameDescriptionReturn Type`setServer(?string $url = null, ?array $variables = null): void`Sets base url for mocked requests.`void``mockRequest(string $path, string $method, ?array $parameters = null, ?array $requestBody = null, ?array $security = null, ?array $callbacks = null): ServerRequestInterface`Mocks PSR-7 server request.`Psr\Http\Message\ServerRequestInterface``mockResponse(string $httpStatusCode = '200', ?array $headers = null, ?string $contentMediaType = null, ?array $contentSchema = null): ResponseInterface`Mocks PSR-7 server response.`Psr\Http\Message\ResponseInterface`### `OpenAPIServer\Mock\Exceptions\OpenApiDataMockerException`

[](#openapiservermockexceptionsopenapidatamockerexception)

This class makes possible to catch exceptions related to mocking feature only. It's highly encouraged not to throw builtin PHP exceptions like `Exception`, `InvalidArgumentException` etc. Use this class or extend it with your own exceptions to fit your needs.

Related Packages
----------------

[](#related-packages)

- [Openapi Data Mocker](https://github.com/ybelenko/openapi-data-mocker) - first implementation of OAS3 fake data generator.
- [Openapi Data Mocker Server Middleware](https://github.com/ybelenko/openapi-data-mocker-server-middleware) - PSR-15 HTTP server middleware.

Copyright
---------

[](#copyright)

While author of this package is top contributor to OpenAPI-Generator project he's not member of OpenAPI Initiative (OAI).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~211 days

Total

3

Last Release

1738d ago

Major Versions

0.0.1 → 1.0.02020-06-18

PHP version history (3 changes)0.0.1PHP ^7.1

1.0.0PHP ^7.2

1.1.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc88fb16ce6ab53268f3ea38dec05691aa20360ab4dc91f3ddab815e7625545a?d=identicon)[ybelenko](/maintainers/ybelenko)

---

Top Contributors

[![ybelenko](https://avatars.githubusercontent.com/u/5541023?v=4)](https://github.com/ybelenko "ybelenko (22 commits)")

---

Tags

datafakefakerinterfacemockmockeroasoas3openapiswaggerfakerdataswaggeropenapimockfakemocker

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ybelenko-openapi-data-mocker-interfaces/health.svg)

```
[![Health](https://phpackages.com/badges/ybelenko-openapi-data-mocker-interfaces/health.svg)](https://phpackages.com/packages/ybelenko-openapi-data-mocker-interfaces)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M678](/packages/phpspec-prophecy)[ybelenko/openapi-data-mocker

Library that generates fake data from Swagger 2.0|Openapi 3.0 spec

1230.5k1](/packages/ybelenko-openapi-data-mocker)[nelmio/alice

Expressive fixtures generator

2.5k43.4M133](/packages/nelmio-alice)[fakerino/fakerino

Faker framework, for generate every kind of fake data for test, database seed, mock responses, other

12214.8k5](/packages/fakerino-fakerino)[icecave/isolator

Dependency injection for global functions.

371.3M29](/packages/icecave-isolator)[dnadesign/silverstripe-populate

Populate your database through YAML files

25102.3k2](/packages/dnadesign-silverstripe-populate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
