@@ -33,12 +33,11 @@ class ObjectSerializer
33
33
* Serialize data
34
34
*
35
35
* @param mixed $data the data to serialize
36
- * @param string $type the SwaggerType of the data
37
36
* @param string $format the format of the Swagger type of the data
38
37
*
39
38
* @return string|object serialized form of $data
40
39
*/
41
- public static function sanitizeForSerialization($data , $type = null, $ format = null)
40
+ public static function sanitizeForSerialization($data , $format = null)
42
41
{
43
42
if (is_scalar($data ) || null === $data ) {
44
43
return $data ;
@@ -109,22 +108,23 @@ class ObjectSerializer
109
108
* later.
110
109
*
111
110
* @param string[]|string|\DateTime $object an object to be serialized to a string
111
+ * @param string|null $format the format of the parameter
112
112
*
113
113
* @return string the serialized object
114
114
*/
115
- public static function toQueryValue($object)
115
+ public static function toQueryValue($object, $format = null )
116
116
{
117
117
if (is_array($object )) {
118
118
return implode(' ,' , $object );
119
119
} else {
120
- return self::toString($object );
120
+ return self::toString($object , $ format );
121
121
}
122
122
}
123
123
124
124
/**
125
125
* Take value and turn it into a string suitable for inclusion in
126
126
* the header. If it's a string, pass through unchanged
127
- * If it's a datetime object, format it in ISO8601
127
+ * If it's a datetime object, format it in RFC3339
128
128
*
129
129
* @param string $value a string which will be part of the header
130
130
*
@@ -138,7 +138,7 @@ class ObjectSerializer
138
138
/**
139
139
* Take value and turn it into a string suitable for inclusion in
140
140
* the http body (form parameter). If it's a string, pass through unchanged
141
- * If it's a datetime object, format it in ISO8601
141
+ * If it's a datetime object, format it in RFC3339
142
142
*
143
143
* @param string|\SplFileObject $value the value of the form parameter
144
144
*
@@ -156,16 +156,18 @@ class ObjectSerializer
156
156
/**
157
157
* Take value and turn it into a string suitable for inclusion in
158
158
* the parameter. If it's a string, pass through unchanged
159
- * If it's a datetime object, format it in ISO8601
159
+ * If it's a datetime object, format it in RFC3339
160
+ * If it's a date, format it in Y-m-d
160
161
*
161
162
* @param string|\DateTime $value the value of the parameter
163
+ * @param string|null $format the format of the parameter
162
164
*
163
165
* @return string the header string
164
166
*/
165
- public static function toString($value)
167
+ public static function toString($value, $format = null )
166
168
{
167
- if ($value instanceof \DateTime) { // datetime in ISO8601 format
168
- return $value -> format (\DateTime::ATOM);
169
+ if ($value instanceof \DateTime) {
170
+ return ( $ format === ' date ' ) ? $ value -> format ( ' Y-m-d ' ) : $value -> format (\DateTime::ATOM);
169
171
} else {
170
172
return $value ;
171
173
}
0 commit comments