Skip to content

Commit fe9b00a

Browse files
committed
Change logic
1 parent f5e5c01 commit fe9b00a

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

src/lib/AttributeResolver.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,7 @@ protected function resolveProperty(
278278
if ($property->isRefPointerToSelf()) {
279279
$relation->asSelfReference();
280280
}
281-
// if (empty($property->getAttr(CustomSpecAttr::NO_RELATION))) {
282281
$this->relations[$property->getName()] = $relation;
283-
// }
284282
if (!$property->isRefPointerToSelf()) {
285283
$this->addInverseRelation($relatedClassName, $attribute, $property, $fkProperty);
286284
}
@@ -323,25 +321,21 @@ protected function resolveProperty(
323321
$fkProperty->getName(),
324322
'_id'
325323
)) {
326-
// if (empty($property->getAttr(CustomSpecAttr::NO_RELATION))) {
327324
$this->relations[$property->getName()] =
328325
Yii::createObject(
329326
AttributeRelation::class,
330327
[static::relationName($property->getName(), $property->fkColName), $relatedTableName, $relatedClassName]
331328
)
332329
->asHasMany([$fkProperty->getName() => $fkProperty->getName()])->asSelfReference();
333-
// }
334330
return;
335331
}
336332
$foreignPk = Inflector::camel2id($fkProperty->getName(), '_') . '_id';
337-
// if (empty($property->getAttr(CustomSpecAttr::NO_RELATION))) {
338333
$this->relations[$property->getName()] =
339334
Yii::createObject(
340335
AttributeRelation::class,
341336
[static::relationName($property->getName(), $property->fkColName), $relatedTableName, $relatedClassName]
342337
)
343338
->asHasMany([$foreignPk => $this->componentSchema->getPkName()]);
344-
// }
345339
return;
346340
}
347341
$relatedClassName = $property->getRefClassName();
@@ -355,15 +349,13 @@ protected function resolveProperty(
355349
return;
356350
}
357351
$attribute->setPhpType($relatedClassName . '[]');
358-
// if (empty($property->getAttr(CustomSpecAttr::NO_RELATION))) {
359352
$this->relations[$property->getName()] =
360353
Yii::createObject(
361354
AttributeRelation::class,
362355
[static::relationName($property->getName(), $property->fkColName), $relatedTableName, $relatedClassName]
363356
)
364357
->asHasMany([Inflector::camel2id($this->schemaName, '_') . '_id' => $this->componentSchema->getPkName()])
365358
->setInverse(Inflector::variablize($this->schemaName));
366-
// }
367359
return;
368360
}
369361
if ($this->componentSchema->isNonDb() && $attribute->isReference()) {

src/lib/openapi/PropertySchema.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function __construct(SpecObjectInterface $property, string $name, Compone
145145
$property = $this->property;
146146
}
147147

148+
// don't go reference part if `x-no-relation` is true
148149
if ($this->getAttr(CustomSpecAttr::NO_RELATION)) {
149150
return;
150151
}
@@ -186,10 +187,6 @@ private function initReference():void
186187
if ($this->refSchema && $this->refSchema->isNonDb()) {
187188
$this->isNonDbReference = true;
188189
}
189-
if ($this->getAttr(CustomSpecAttr::NO_RELATION)) {
190-
$this->isReference = false;
191-
$this->isNonDbReference = true;
192-
}
193190
}
194191

195192
/**
@@ -199,9 +196,6 @@ private function initReference():void
199196
private function initItemsReference():void
200197
{
201198
$this->isItemsReference = true;
202-
if ($this->getAttr(CustomSpecAttr::NO_RELATION)) {
203-
$this->isItemsReference = false;
204-
}
205199
$items = $this->property->items ?? null;
206200
if (!$items) {
207201
return;
@@ -217,9 +211,6 @@ private function initItemsReference():void
217211
if ($this->refSchema && $this->refSchema->isNonDb()) {
218212
$this->isNonDbReference = true;
219213
}
220-
if ($this->getAttr(CustomSpecAttr::NO_RELATION)) {
221-
$this->isNonDbReference = true;
222-
}
223214
}
224215

225216
public function setName(string $name):void
@@ -511,7 +502,7 @@ public function guessDbType($forReference = false):string
511502
}
512503
return YiiDbSchema::TYPE_TEXT;
513504
case 'object':
514-
case 'array': // TODO WIP Resume from here
505+
case 'array':
515506
{
516507
return YiiDbSchema::TYPE_JSON;
517508
}

0 commit comments

Comments
 (0)