forked from loafle/openapi-generator-original
* [Slim4] Add OpenApiDataMocker interface template * [Slim4] Implement scalar types in data mocker * [Slim4] Cleanup, remove unused variables I've rejected the idea to keep Composer dependencies in Java/codegen variables at some point of time. It seems that after Git rebase I forgot to delete them. * [Slim4] Refresh samples * [Slim4] Add pattern option to mockString method [ref] https://tools.ietf.org/html/draft-wright-json-schema-validation-00#section-5.8 * [Slim4] Add enum option to mockString method [ref] https://tools.ietf.org/html/draft-wright-json-schema-validation-00#section-5.20 * [Slim4] Refactor mockInteger and mockNumber tests * [Slim4] Refactor mockString tests * [Slim4] Use null coalescing operator * [Slim4] Implement enum option in mockString method * [Slim4] Add tests for enum option of mockString
182 lines
6.0 KiB
PHP
182 lines
6.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* OpenApiDataMockerInterface
|
|
* @ref https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#data-types
|
|
*
|
|
* PHP version 7.1
|
|
*
|
|
* @package OpenAPIServer
|
|
* @author OpenAPI Generator team
|
|
* @link https://github.com/openapitools/openapi-generator
|
|
*/
|
|
|
|
/**
|
|
* OpenAPI Petstore
|
|
*
|
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
|
* The version of the OpenAPI document: 1.0.0
|
|
* Generated by: https://github.com/openapitools/openapi-generator.git
|
|
*/
|
|
|
|
/**
|
|
* NOTE: This class is auto generated by the openapi generator program.
|
|
* https://github.com/openapitools/openapi-generator
|
|
* Do not edit the class manually.
|
|
*/
|
|
namespace OpenAPIServer\Mock;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
/**
|
|
* OpenApiDataMockerInterface Class Doc Comment
|
|
*
|
|
* @package OpenAPIServer\Mock
|
|
* @author OpenAPI Generator team
|
|
* @link https://github.com/openapitools/openapi-generator
|
|
*/
|
|
interface OpenApiDataMockerInterface
|
|
{
|
|
/** @var string DATA_TYPE_INTEGER */
|
|
public const DATA_TYPE_INTEGER = 'integer';
|
|
|
|
/** @var string DATA_TYPE_NUMBER */
|
|
public const DATA_TYPE_NUMBER = 'number';
|
|
|
|
/** @var string DATA_TYPE_STRING */
|
|
public const DATA_TYPE_STRING = 'string';
|
|
|
|
/** @var string DATA_TYPE_BOOLEAN */
|
|
public const DATA_TYPE_BOOLEAN = 'boolean';
|
|
|
|
/** @var string DATA_TYPE_FILE */
|
|
public const DATA_TYPE_FILE = 'file';
|
|
|
|
/** @var string DATA_FORMAT_INT32 Signed 32 bits */
|
|
public const DATA_FORMAT_INT32 = 'int32';
|
|
|
|
/** @var string DATA_FORMAT_INT64 Signed 64 bits */
|
|
public const DATA_FORMAT_INT64 = 'int64';
|
|
|
|
/** @var string DATA_FORMAT_FLOAT */
|
|
public const DATA_FORMAT_FLOAT = 'float';
|
|
|
|
/** @var string DATA_FORMAT_DOUBLE */
|
|
public const DATA_FORMAT_DOUBLE = 'double';
|
|
|
|
/** @var string DATA_FORMAT_BYTE base64 encoded characters */
|
|
public const DATA_FORMAT_BYTE = 'byte';
|
|
|
|
/** @var string DATA_FORMAT_BINARY Any sequence of octets */
|
|
public const DATA_FORMAT_BINARY = 'binary';
|
|
|
|
/** @var string DATA_FORMAT_DATE As defined by full-date [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) */
|
|
public const DATA_FORMAT_DATE = 'date';
|
|
|
|
/** @var string DATA_FORMAT_DATE_TIME As defined by date-time [RFC3339](http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14) */
|
|
public const DATA_FORMAT_DATE_TIME = 'date-time';
|
|
|
|
/** @var string DATA_FORMAT_PASSWORD Used to hint UIs the input needs to be obscured. */
|
|
public const DATA_FORMAT_PASSWORD = 'password';
|
|
|
|
/** @var string DATA_FORMAT_EMAIL */
|
|
public const DATA_FORMAT_EMAIL = 'email';
|
|
|
|
/** @var string DATA_FORMAT_UUID */
|
|
public const DATA_FORMAT_UUID = 'uuid';
|
|
|
|
/**
|
|
* Mocks OpenApi Data.
|
|
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#data-types
|
|
*
|
|
* @param $dataType string OpenApi data type. Use constants from this class
|
|
* @param $dataFormat string (optional) OpenApi data format
|
|
* @param $options array|null (optional) OpenApi data options
|
|
*
|
|
* @throws \InvalidArgumentException when invalid arguments passed
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function mock(
|
|
$dataType,
|
|
$dataFormat = null,
|
|
$options = []
|
|
);
|
|
|
|
/**
|
|
* Shortcut to mock integer type
|
|
* Equivalent to mockData(DATA_TYPE_INTEGER);
|
|
*
|
|
* @param string|null $dataFormat (optional) int32 or int64
|
|
* @param number|null $minimum (optional) Default is 0
|
|
* @param number|null $maximum (optional) Default is mt_getrandmax()
|
|
* @param bool|null $exclusiveMinimum (optional) Default is false
|
|
* @param bool|null $exclusiveMaximum (optional) Default is false
|
|
*
|
|
* @throws \InvalidArgumentException when $maximum less than $minimum or invalid arguments provided
|
|
*
|
|
* @return int
|
|
*/
|
|
public function mockInteger(
|
|
$dataFormat = null,
|
|
$minimum = null,
|
|
$maximum = null,
|
|
$exclusiveMinimum = false,
|
|
$exclusiveMaximum = false
|
|
);
|
|
|
|
/**
|
|
* Shortcut to mock number type
|
|
* Equivalent to mockData(DATA_TYPE_NUMBER);
|
|
*
|
|
* @param string|null $dataFormat (optional) float or double
|
|
* @param number|null $minimum (optional) Default is 0
|
|
* @param number|null $maximum (optional) Default is mt_getrandmax()
|
|
* @param bool|null $exclusiveMinimum (optional) Default is false
|
|
* @param bool|null $exclusiveMaximum (optional) Default is false
|
|
*
|
|
* @throws \InvalidArgumentException when $maximum less than $minimum or invalid arguments provided
|
|
*
|
|
* @return float
|
|
*/
|
|
public function mockNumber(
|
|
$dataFormat = null,
|
|
$minimum = null,
|
|
$maximum = null,
|
|
$exclusiveMinimum = false,
|
|
$exclusiveMaximum = false
|
|
);
|
|
|
|
/**
|
|
* Shortcut to mock string type
|
|
* Equivalent to mockData(DATA_TYPE_STRING);
|
|
*
|
|
* @param string|null $dataFormat (optional) one of byte, binary, date, date-time, password
|
|
* @param int|null $minLength (optional) Default is 0
|
|
* @param int|null $maxLength (optional) Default is 100 chars
|
|
* @param array $enum (optional) This array should have at least one element.
|
|
* Elements in the array should be unique.
|
|
* @param string|null $pattern (optional) This string should be a valid regular expression, according to the ECMA 262 regular expression dialect.
|
|
* Recall: regular expressions are not implicitly anchored.
|
|
*
|
|
* @throws \InvalidArgumentException when invalid arguments passed
|
|
*
|
|
* @return string
|
|
*/
|
|
public function mockString(
|
|
$dataFormat = null,
|
|
$minLength = 0,
|
|
$maxLength = null,
|
|
$enum = null,
|
|
$pattern = null
|
|
);
|
|
|
|
/**
|
|
* Shortcut to mock boolean type
|
|
* Equivalent to mockData(DATA_TYPE_BOOLEAN);
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function mockBoolean();
|
|
}
|