forked from loafle/openapi-generator-original
[PHP] Fix date
format serialization (#5754)
* [PHP] Honor Swagger/OpenAPI 'date' format Per spec (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types), DateTime instances defined as 'date' datatype need to be serialized as defined by full-date - RFC3339, which has the format: full-date = date-fullyear "-" date-month "-" date-mday ref: https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14 see #5531 fixes #5607 * [PHP] Add `date` and `date-time` serializer tests See #5531 See #5607 * [PHP] Improve codestyle of generated code * [PHP] Regenerate PHP Petstore sample * [PHP] Regenerate PHP Security sample
This commit is contained in:
parent
00f2dc422d
commit
d5b3cc0534
@ -32,16 +32,18 @@ class ObjectSerializer
|
||||
/**
|
||||
* Serialize data
|
||||
*
|
||||
* @param mixed $data the data to serialize
|
||||
* @param mixed $data the data to serialize
|
||||
* @param string $type the SwaggerType of the data
|
||||
* @param string $format the format of the Swagger type of the data
|
||||
*
|
||||
* @return string|object serialized form of $data
|
||||
*/
|
||||
public static function sanitizeForSerialization($data)
|
||||
public static function sanitizeForSerialization($data, $type = null, $format = null)
|
||||
{
|
||||
if (is_scalar($data) || null === $data) {
|
||||
return $data;
|
||||
} elseif ($data instanceof \DateTime) {
|
||||
return $data->format(\DateTime::ATOM);
|
||||
return ($format === 'date') ? $data->format('Y-m-d') : $data->format(\DateTime::ATOM);
|
||||
} elseif (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = self::sanitizeForSerialization($value);
|
||||
@ -49,6 +51,7 @@ class ObjectSerializer
|
||||
return $data;
|
||||
} elseif (is_object($data)) {
|
||||
$values = [];
|
||||
$formats = $data::swaggerFormats();
|
||||
foreach ($data::swaggerTypes() as $property => $swaggerType) {
|
||||
$getter = $data::getters()[$property];
|
||||
$value = $data->$getter();
|
||||
@ -58,7 +61,7 @@ class ObjectSerializer
|
||||
throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'");
|
||||
}
|
||||
if ($value !== null) {
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value);
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]);
|
||||
}
|
||||
}
|
||||
return (object)$values;
|
||||
|
@ -80,8 +80,10 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Operation {{{operationId}}}
|
||||
{{#summary}}
|
||||
*
|
||||
* {{{summary}}}
|
||||
{{/summary}}
|
||||
*
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
@ -101,8 +103,10 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Operation {{{operationId}}}WithHttpInfo
|
||||
{{#summary}}
|
||||
*
|
||||
* {{{summary}}}
|
||||
{{/summary}}
|
||||
*
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
|
@ -39,7 +39,6 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +46,6 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,7 +53,6 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,10 +60,9 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
|
||||
/**
|
||||
* Test case for {{{operationId}}}
|
||||
*
|
||||
@ -75,9 +71,7 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
*/
|
||||
public function test{{vendorExtensions.x-testOperationId}}()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
@ -1,4 +1,5 @@
|
||||
class {{classname}} {
|
||||
class {{classname}}
|
||||
{
|
||||
/**
|
||||
* Possible values of this enum
|
||||
*/
|
||||
|
@ -17,11 +17,25 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
|
||||
{{/hasMore}}{{/vars}}
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
{{#vars}}'{{name}}' => {{#dataFormat}}'{{{dataFormat}}}'{{/dataFormat}}{{^dataFormat}}null{{/dataFormat}}{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes{{#parentSchema}} + parent::swaggerTypes(){{/parentSchema}};
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats{{#parentSchema}} + parent::swaggerFormats(){{/parentSchema}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -39,7 +39,6 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +46,6 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,7 +53,6 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,7 +60,6 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,18 +67,15 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function test{{classname}}()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{{#vars}}
|
||||
|
||||
/**
|
||||
* Test attribute "{{name}}"
|
||||
*/
|
||||
public function testProperty{{nameInCamelCase}}()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{{/vars}}
|
||||
}
|
||||
{{/model}}
|
||||
|
@ -0,0 +1 @@
|
||||
2.2.3-SNAPSHOT
|
@ -129,7 +129,7 @@ class FakeApi
|
||||
if ($test_code_inject____end____rn_n_r !== null) {
|
||||
$formParams['test code inject */ ' " =end -- \r\n \n \r'] = $this->apiClient->getSerializer()->toFormValue($test_code_inject____end____rn_n_r);
|
||||
}
|
||||
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
|
@ -167,7 +167,7 @@ class ApiClient
|
||||
if ($this->config->getCurlConnectTimeout() != 0) {
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->config->getCurlConnectTimeout());
|
||||
}
|
||||
|
||||
|
||||
// return the result on success, rather than just true
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
@ -199,6 +199,10 @@ class ApiClient
|
||||
$url = ($url . '?' . http_build_query($queryParams));
|
||||
}
|
||||
|
||||
if ($this->config->getAllowEncoding()) {
|
||||
curl_setopt($curl, CURLOPT_ENCODING, '');
|
||||
}
|
||||
|
||||
if ($method === self::$POST) {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
|
@ -177,6 +177,13 @@ class Configuration
|
||||
*/
|
||||
protected $proxyPassword;
|
||||
|
||||
/**
|
||||
* Allow Curl encoding header
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $allowEncoding = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -445,6 +452,16 @@ class Configuration
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to accept encoding
|
||||
* @param bool $allowEncoding
|
||||
*/
|
||||
public function setAllowEncoding($allowEncoding)
|
||||
{
|
||||
$this->allowEncoding = $allowEncoding;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTTP connect timeout value
|
||||
*
|
||||
@ -455,6 +472,15 @@ class Configuration
|
||||
return $this->curlConnectTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether to allow encoding
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getAllowEncoding()
|
||||
{
|
||||
return $this->allowEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTTP Proxy Host
|
||||
|
@ -58,11 +58,24 @@ class ModelReturn implements ArrayAccess
|
||||
'return' => 'int'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'return' => 'int32'
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -42,16 +42,18 @@ class ObjectSerializer
|
||||
/**
|
||||
* Serialize data
|
||||
*
|
||||
* @param mixed $data the data to serialize
|
||||
* @param mixed $data the data to serialize
|
||||
* @param string $type the SwaggerType of the data
|
||||
* @param string $format the format of the Swagger type of the data
|
||||
*
|
||||
* @return string|object serialized form of $data
|
||||
*/
|
||||
public static function sanitizeForSerialization($data)
|
||||
public static function sanitizeForSerialization($data, $type = null, $format = null)
|
||||
{
|
||||
if (is_scalar($data) || null === $data) {
|
||||
return $data;
|
||||
} elseif ($data instanceof \DateTime) {
|
||||
return $data->format(\DateTime::ATOM);
|
||||
return ($format === 'date') ? $data->format('Y-m-d') : $data->format(\DateTime::ATOM);
|
||||
} elseif (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = self::sanitizeForSerialization($value);
|
||||
@ -59,6 +61,7 @@ class ObjectSerializer
|
||||
return $data;
|
||||
} elseif (is_object($data)) {
|
||||
$values = [];
|
||||
$formats = $data::swaggerFormats();
|
||||
foreach ($data::swaggerTypes() as $property => $swaggerType) {
|
||||
$getter = $data::getters()[$property];
|
||||
$value = $data->$getter();
|
||||
@ -68,7 +71,7 @@ class ObjectSerializer
|
||||
throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'");
|
||||
}
|
||||
if ($value !== null) {
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value);
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]);
|
||||
}
|
||||
}
|
||||
return (object)$values;
|
||||
|
@ -90,8 +90,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterBooleanSerialize
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return \Swagger\Client\Model\OuterBoolean
|
||||
@ -105,8 +103,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterBooleanSerializeWithHttpInfo
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return array of \Swagger\Client\Model\OuterBoolean, HTTP status code, HTTP response headers (array of strings)
|
||||
@ -165,8 +161,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterCompositeSerialize
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return \Swagger\Client\Model\OuterComposite
|
||||
@ -180,8 +174,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterCompositeSerializeWithHttpInfo
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return array of \Swagger\Client\Model\OuterComposite, HTTP status code, HTTP response headers (array of strings)
|
||||
@ -240,8 +232,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterNumberSerialize
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return \Swagger\Client\Model\OuterNumber
|
||||
@ -255,8 +245,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterNumberSerializeWithHttpInfo
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return array of \Swagger\Client\Model\OuterNumber, HTTP status code, HTTP response headers (array of strings)
|
||||
@ -315,8 +303,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterStringSerialize
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterString $body Input string as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return \Swagger\Client\Model\OuterString
|
||||
@ -330,8 +316,6 @@ class FakeApi
|
||||
/**
|
||||
* Operation fakeOuterStringSerializeWithHttpInfo
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param \Swagger\Client\Model\OuterString $body Input string as post body (optional)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
* @return array of \Swagger\Client\Model\OuterString, HTTP status code, HTTP response headers (array of strings)
|
||||
|
@ -58,11 +58,25 @@ class AdditionalPropertiesClass implements ArrayAccess
|
||||
'map_of_map_property' => 'map[string,map[string,string]]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'map_property' => null,
|
||||
'map_of_map_property' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,25 @@ class Animal implements ArrayAccess
|
||||
'color' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'class_name' => null,
|
||||
'color' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class AnimalFarm implements ArrayAccess
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -59,11 +59,26 @@ class ApiResponse implements ArrayAccess
|
||||
'message' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'code' => 'int32',
|
||||
'type' => null,
|
||||
'message' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class ArrayOfArrayOfNumberOnly implements ArrayAccess
|
||||
'array_array_number' => 'float[][]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'array_array_number' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class ArrayOfNumberOnly implements ArrayAccess
|
||||
'array_number' => 'float[]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'array_number' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -59,11 +59,26 @@ class ArrayTest implements ArrayAccess
|
||||
'array_array_of_model' => '\Swagger\Client\Model\ReadOnlyFirst[][]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'array_of_string' => null,
|
||||
'array_array_of_integer' => 'int64',
|
||||
'array_array_of_model' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -62,11 +62,29 @@ class Capitalization implements ArrayAccess
|
||||
'att_name' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'small_camel' => null,
|
||||
'capital_camel' => null,
|
||||
'small_snake' => null,
|
||||
'capital_snake' => null,
|
||||
'sca_eth_flow_points' => null,
|
||||
'att_name' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class Cat extends Animal implements ArrayAccess
|
||||
'declawed' => 'bool'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'declawed' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes + parent::swaggerTypes();
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats + parent::swaggerFormats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,25 @@ class Category implements ArrayAccess
|
||||
'name' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'id' => 'int64',
|
||||
'name' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,24 @@ class ClassModel implements ArrayAccess
|
||||
'_class' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'_class' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class Client implements ArrayAccess
|
||||
'client' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'client' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class Dog extends Animal implements ArrayAccess
|
||||
'breed' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'breed' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes + parent::swaggerTypes();
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats + parent::swaggerFormats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,25 @@ class EnumArrays implements ArrayAccess
|
||||
'array_enum' => 'string[]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'just_symbol' => null,
|
||||
'array_enum' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -37,7 +37,8 @@ namespace Swagger\Client\Model;
|
||||
* @author Swagger Codegen team
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class EnumClass {
|
||||
class EnumClass
|
||||
{
|
||||
/**
|
||||
* Possible values of this enum
|
||||
*/
|
||||
|
@ -60,11 +60,27 @@ class EnumTest implements ArrayAccess
|
||||
'outer_enum' => '\Swagger\Client\Model\OuterEnum'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'enum_string' => null,
|
||||
'enum_integer' => 'int32',
|
||||
'enum_number' => 'double',
|
||||
'outer_enum' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -69,11 +69,36 @@ class FormatTest implements ArrayAccess
|
||||
'password' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'integer' => null,
|
||||
'int32' => 'int32',
|
||||
'int64' => 'int64',
|
||||
'number' => null,
|
||||
'float' => 'float',
|
||||
'double' => 'double',
|
||||
'string' => null,
|
||||
'byte' => 'byte',
|
||||
'binary' => 'binary',
|
||||
'date' => 'date',
|
||||
'date_time' => 'date-time',
|
||||
'uuid' => 'uuid',
|
||||
'password' => 'password'
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,25 @@ class HasOnlyReadOnly implements ArrayAccess
|
||||
'foo' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'bar' => null,
|
||||
'foo' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,25 @@ class MapTest implements ArrayAccess
|
||||
'map_of_enum_string' => 'map[string,string]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'map_map_of_string' => null,
|
||||
'map_of_enum_string' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -59,11 +59,26 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ArrayAccess
|
||||
'map' => 'map[string,\Swagger\Client\Model\Animal]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'uuid' => 'uuid',
|
||||
'date_time' => 'date-time',
|
||||
'map' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -59,11 +59,25 @@ class Model200Response implements ArrayAccess
|
||||
'class' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'name' => 'int32',
|
||||
'class' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class ModelList implements ArrayAccess
|
||||
'_123_list' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'_123_list' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,24 @@ class ModelReturn implements ArrayAccess
|
||||
'return' => 'int'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'return' => 'int32'
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -61,11 +61,27 @@ class Name implements ArrayAccess
|
||||
'_123_number' => 'int'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'name' => 'int32',
|
||||
'snake_case' => 'int32',
|
||||
'property' => null,
|
||||
'_123_number' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class NumberOnly implements ArrayAccess
|
||||
'just_number' => 'float'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'just_number' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -62,11 +62,29 @@ class Order implements ArrayAccess
|
||||
'complete' => 'bool'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'id' => 'int64',
|
||||
'pet_id' => 'int64',
|
||||
'quantity' => 'int32',
|
||||
'ship_date' => 'date-time',
|
||||
'status' => null,
|
||||
'complete' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class OuterBoolean implements ArrayAccess
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -59,11 +59,26 @@ class OuterComposite implements ArrayAccess
|
||||
'my_boolean' => '\Swagger\Client\Model\OuterBoolean'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'my_number' => null,
|
||||
'my_string' => null,
|
||||
'my_boolean' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -37,7 +37,8 @@ namespace Swagger\Client\Model;
|
||||
* @author Swagger Codegen team
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class OuterEnum {
|
||||
class OuterEnum
|
||||
{
|
||||
/**
|
||||
* Possible values of this enum
|
||||
*/
|
||||
|
@ -57,11 +57,24 @@ class OuterNumber implements ArrayAccess
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class OuterString implements ArrayAccess
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -62,11 +62,29 @@ class Pet implements ArrayAccess
|
||||
'status' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'id' => 'int64',
|
||||
'category' => null,
|
||||
'name' => null,
|
||||
'photo_urls' => null,
|
||||
'tags' => null,
|
||||
'status' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,25 @@ class ReadOnlyFirst implements ArrayAccess
|
||||
'baz' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'bar' => null,
|
||||
'baz' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -57,11 +57,24 @@ class SpecialModelName implements ArrayAccess
|
||||
'special_property_name' => 'int'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'special_property_name' => 'int64'
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -58,11 +58,25 @@ class Tag implements ArrayAccess
|
||||
'name' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'id' => 'int64',
|
||||
'name' => null
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -64,11 +64,31 @@ class User implements ArrayAccess
|
||||
'user_status' => 'int'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'id' => 'int64',
|
||||
'username' => null,
|
||||
'first_name' => null,
|
||||
'last_name' => null,
|
||||
'email' => null,
|
||||
'password' => null,
|
||||
'phone' => null,
|
||||
'user_status' => 'int32'
|
||||
];
|
||||
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
|
@ -42,16 +42,18 @@ class ObjectSerializer
|
||||
/**
|
||||
* Serialize data
|
||||
*
|
||||
* @param mixed $data the data to serialize
|
||||
* @param mixed $data the data to serialize
|
||||
* @param string $type the SwaggerType of the data
|
||||
* @param string $format the format of the Swagger type of the data
|
||||
*
|
||||
* @return string|object serialized form of $data
|
||||
*/
|
||||
public static function sanitizeForSerialization($data)
|
||||
public static function sanitizeForSerialization($data, $type = null, $format = null)
|
||||
{
|
||||
if (is_scalar($data) || null === $data) {
|
||||
return $data;
|
||||
} elseif ($data instanceof \DateTime) {
|
||||
return $data->format(\DateTime::ATOM);
|
||||
return ($format === 'date') ? $data->format('Y-m-d') : $data->format(\DateTime::ATOM);
|
||||
} elseif (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = self::sanitizeForSerialization($value);
|
||||
@ -59,6 +61,7 @@ class ObjectSerializer
|
||||
return $data;
|
||||
} elseif (is_object($data)) {
|
||||
$values = [];
|
||||
$formats = $data::swaggerFormats();
|
||||
foreach ($data::swaggerTypes() as $property => $swaggerType) {
|
||||
$getter = $data::getters()[$property];
|
||||
$value = $data->$getter();
|
||||
@ -68,7 +71,7 @@ class ObjectSerializer
|
||||
throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'");
|
||||
}
|
||||
if ($value !== null) {
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value);
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]);
|
||||
}
|
||||
}
|
||||
return (object)$values;
|
||||
|
@ -4,7 +4,14 @@
|
||||
<description>Arnes Drupal code checker</description>
|
||||
|
||||
<rule ref="PSR2" />
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
|
||||
<!-- Getting rid of extra newlines at the end of generated files is not worth the trouble -->
|
||||
<rule ref="PSR2.Files.EndFileNewline.TooMany">
|
||||
<exclude-pattern>*</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<!-- Avoiding generating code lines to grow too long is not worth the trouble -->
|
||||
<rule ref="Generic.Files.LineLength.TooLong">
|
||||
<exclude-pattern>*</exclude-pattern>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Swagger\Client;
|
||||
|
||||
use Swagger\Client\Model\FormatTest;
|
||||
|
||||
class DateTimeSerializerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDateTimeSanitazion()
|
||||
{
|
||||
$dateTime = new \DateTime('April 30, 1973 17:05 CEST');
|
||||
|
||||
$input = new FormatTest([
|
||||
'date_time' => $dateTime,
|
||||
]);
|
||||
|
||||
$data = ObjectSerializer::sanitizeForSerialization($input);
|
||||
|
||||
$this->assertEquals($data->dateTime, '1973-04-30T17:05:00+02:00');
|
||||
}
|
||||
|
||||
public function testDateSanitazion()
|
||||
{
|
||||
$dateTime = new \DateTime('April 30, 1973 17:05 CEST');
|
||||
|
||||
$input = new FormatTest([
|
||||
'date' => $dateTime,
|
||||
]);
|
||||
|
||||
$data = ObjectSerializer::sanitizeForSerialization($input);
|
||||
|
||||
$this->assertEquals($data->date, '1973-04-30');
|
||||
}
|
||||
}
|
@ -349,7 +349,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$response = $pet_api->uploadFile($pet_id, "test meta", "./composer.json");
|
||||
// return ApiResponse
|
||||
$this->assertInstanceOf('Swagger\Client\Model\ApiResponse', $response);
|
||||
|
||||
}
|
||||
|
||||
// test get inventory
|
||||
@ -402,7 +401,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$new_pet = new Model\Pet;
|
||||
// the empty object should be serialised to {}
|
||||
$this->assertSame("{}", "$new_pet");
|
||||
|
||||
}
|
||||
|
||||
// test inheritance in the model
|
||||
@ -493,6 +491,7 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$pet_host = $pet_api->getApiClient()->getConfig()->getHost();
|
||||
$this->assertSame($pet_host, $new_default->getHost());
|
||||
|
||||
Configuration::setDefaultConfiguration($orig_default); // Reset to original to prevent failure of other tests that rely on this state
|
||||
// Reset to original to prevent failure of other tests that rely on this state
|
||||
Configuration::setDefaultConfiguration($orig_default);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,5 @@ class UserApiTest extends \PHPUnit_Framework_TestCase
|
||||
$response,
|
||||
"response string starts with 'logged in user session'"
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user