@@ -170,6 +170,10 @@ private function castToSchemaType($value, ?string $type)
170
170
return $ this ->convertToSerializationStyle ($ value , $ this ->schema );
171
171
}
172
172
173
+ if (($ type === CebeType::OBJECT ) && is_string ($ value )) {
174
+ return $ this ->convertToSerializationStyle ($ value , $ this ->schema );
175
+ }
176
+
173
177
return $ value ;
174
178
}
175
179
@@ -185,6 +189,9 @@ protected function convertToSerializationStyle($value, ?CebeSchema $schema)
185
189
case 'path ' :
186
190
return $ this ->convertToSerializationStyleForPath ($ value , $ schema );
187
191
192
+ case 'header ' :
193
+ return $ this ->convertToSerializationStyleForHeader ($ value , $ schema );
194
+
188
195
default :
189
196
return $ this ->convertToSerializationStyleForQuery ($ value , $ schema );
190
197
}
@@ -257,6 +264,29 @@ protected function convertToSerializationStyleForPath($value, ?CebeSchema $schem
257
264
return $ value ;
258
265
}
259
266
267
+ /**
268
+ * @param mixed $value
269
+ * @param CebeSchema|null $schema - optional schema of value to convert it in case of DeepObject serialisation
270
+ *
271
+ * @return mixed
272
+ */
273
+ protected function convertToSerializationStyleForHeader ($ value , ?CebeSchema $ schema )
274
+ {
275
+ $ value = explode (', ' , $ value );
276
+
277
+ if (! is_iterable ($ value )) {
278
+ throw TypeMismatch::becauseTypeDoesNotMatch (['iterable ' ], $ value );
279
+ }
280
+
281
+ $ array = [];
282
+ foreach ($ value as &$ val ) {
283
+ $ splitVal = explode ('= ' , $ val );
284
+ $ array [$ splitVal [0 ]] = $ this ->castToSchemaType ($ splitVal [1 ], $ schema ->properties [$ splitVal [0 ]]->type ?? null );
285
+ }
286
+
287
+ return $ array ;
288
+ }
289
+
260
290
/**
261
291
* @param mixed $value
262
292
* @param CebeSchema|null $schema - optional schema of value to convert it in case of DeepObject serialisation
0 commit comments