Skip to content

Commit 4f137bc

Browse files
committed
Fix this issue
1 parent 5b785c4 commit 4f137bc

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/lib/openapi/PropertySchema.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,22 @@ public function isRefPointerToSchema():bool
269269

270270
public function isRefPointerToSelf():bool
271271
{
272+
$schema = Json::decode(Json::encode($this->schema->getSchema()->getSerializableData()));
273+
274+
if (isset($schema['properties'][$this->name]['allOf'])) { # fixes https://github.com/php-openapi/yii2-openapi/issues/68
275+
$allOfs = $schema['properties'][$this->name]['allOf'];
276+
$refCounter = 0;
277+
foreach ($allOfs as $allOf) {
278+
if (isset($allOf['$ref'])) {
279+
$refCounter++;
280+
}
281+
}
282+
if ($refCounter === 1) {
283+
return $this->isRefPointerToSchema()
284+
&& str_ends_with($this->refPointer, '/' . $this->schema->getName()) !== false;
285+
}
286+
}
287+
272288
return $this->isRefPointerToSchema()
273289
&& strpos($this->refPointer, '/' . $this->schema->getName() . '/') !== false
274290
&& strpos($this->refPointer, '/properties/') !== false;

tests/specs/issue_fix/52_bug_dependenton_allof_with_x_faker_false/mysql/models/base/Invoice.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,4 @@ public function getAnimal()
7878
{
7979
return $this->hasOne(\app\models\Animal::class, ['id' => 'animal_id']);
8080
}
81-
82-
public function getInvoice()
83-
{
84-
return $this->hasOne(\app\models\Invoice::class, ['reference_invoice_id' => 'id'])->inverseOf('reference_invoice');
85-
}
86-
87-
public function getInvoice2()
88-
{
89-
return $this->hasOne(\app\models\Invoice::class, ['reference_invoice_2_id' => 'id'])->inverseOf('reference_invoice_2');
90-
}
9181
}

0 commit comments

Comments
 (0)