@@ -272,7 +272,7 @@ private function fakeForArray(SpecObjectInterface $property, int $count = 4): st
272272 // TODO consider example of OpenAPI spec
273273
274274 /** @var Schema|Reference|null $items */
275- $ items = $ property ->items ; # later is used only in `oneOf`
275+ $ items = $ property ->items ;
276276
277277 if (!$ items ) {
278278 return $ this ->arbitraryArray ();
@@ -290,7 +290,7 @@ private function fakeForArray(SpecObjectInterface $property, int $count = 4): st
290290 if ($ type === null ) {
291291 return $ this ->arbitraryArray ();
292292 }
293- $ aElementFaker = $ this ->aElementFaker ();
293+ $ aElementFaker = $ this ->aElementFaker ($ this -> property -> getProperty ()-> getSerializableData () );
294294
295295 if (in_array ($ type , ['string ' , 'number ' , 'integer ' , 'boolean ' ])) {
296296 return $ this ->wrapAsArray ($ aElementFaker , $ uniqueItems , $ count );
@@ -375,7 +375,7 @@ public function handleOneOf($items, $count): string
375375 /** @var Schema|Reference $aDataType */
376376
377377// $a1 = $this->fakeForArray($aDataType, 1);
378- $ a1 = $ this ->aElementFaker ();
378+ $ a1 = $ this ->aElementFaker ($ aDataType -> getSerializableData () );
379379 $ result .= '$dataType ' . $ key . ' = ' . $ a1 . '; ' ;
380380 }
381381 $ ct = count ($ items ->oneOf ) - 1 ;
@@ -396,12 +396,12 @@ public function arbitraryArray(): string
396396 return '$faker->words() ' ;
397397 }
398398
399- public function aElementFaker (): ?string
399+ public function aElementFaker ($ data ): ?string
400400 {
401- $ aElementData = Json::decode (Json::encode ($ this -> property -> getProperty ()-> getSerializableData () ));
401+ $ aElementData = Json::decode (Json::encode ($ data ));
402402 $ compoSchemaData = [
403403 'properties ' => [
404- 'unnamedProp ' => $ aElementData ['items ' ]
404+ 'unnamedProp ' => $ aElementData ['items ' ] ?? $ aElementData # later is used only in `oneOf`
405405 ]
406406 ];
407407 $ cs = new ComponentSchema (new Schema ($ compoSchemaData ), 'UnnamedCompo ' );
0 commit comments