Skip to content

Commit 47e5e84

Browse files
committed
Revert "Example usage for #98 (comment)"
This reverts commit 9538035.
1 parent 9538035 commit 47e5e84

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/lib/FakerStubResolver.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use cebe\openapi\ReferenceContext;
1717
use cebe\openapi\spec\Reference;
1818
use cebe\openapi\spec\Schema;
19-
use cebe\openapi\SpecBaseObject;
2019
use cebe\openapi\SpecObjectInterface;
2120
use cebe\yii2openapi\lib\exceptions\InvalidDefinitionException;
2221
use cebe\yii2openapi\lib\items\Attribute;
@@ -330,9 +329,7 @@ public function fakeForObject(SpecObjectInterface $items): string
330329
if (!empty($prop->properties)) { // nested object
331330
$result = $this->{__FUNCTION__}($prop);
332331
} else {
333-
// ($prop instanceof SpecBaseObject) && var_dump($prop->rawSpec);
334-
// $result = $this->aElementFaker(['items' => $prop->getSerializableData()], $name);
335-
$result = $this->aElementFaker(['items' => $prop->rawSpec], $name);
332+
$result = $this->aElementFaker(['items' => $prop->getSerializableData()], $name);
336333
}
337334
$props .= '\'' . $name . '\' => ' . $result . ',' . PHP_EOL;
338335
}
@@ -361,7 +358,7 @@ public function handleOneOf(SpecObjectInterface $items, int $count): string
361358
foreach ($items->oneOf as $key => $aDataType) {
362359
/** @var Schema|Reference $aDataType */
363360

364-
$inp = $aDataType instanceof Reference ? $aDataType : ['items' => $aDataType->rawSpec];
361+
$inp = $aDataType instanceof Reference ? $aDataType : ['items' => $aDataType->getSerializableData()];
365362
$aFaker = $this->aElementFaker($inp, $this->attribute->columnName);
366363
$result .= '$dataType' . $key . ' = ' . $aFaker . ';';
367364
}
@@ -406,7 +403,7 @@ public function aElementFaker($data, ?string $columnName = null): ?string
406403
return '(new ' . $class . ')->generateModel()->attributes';
407404
}
408405

409-
$inp = $data instanceof SpecObjectInterface ? $data->rawSpec : $data;
406+
$inp = $data instanceof SpecObjectInterface ? $data->getSerializableData() : $data;
410407
$aElementData = Json::decode(Json::encode($inp));
411408
$columnName = $columnName ?? 'unnamedProp';
412409
$compoSchemaData = [

0 commit comments

Comments
 (0)