A single $ref can already be declared as "not a foreign key" and then generates an abstract
getter the app implements itself:
document:
allOf:
- $ref: '#/components/schemas/Document'
- x-db-type: false
abstract public function getDocument(): \yii\db\ActiveQuery;
For type: array there is no spec form that reaches this.
Wanted
One of these inputs should work (or both, whichever is cheaper):
# form 1
customFieldLeads:
type: array
readOnly: true
x-db-type: false
items:
$ref: '#/components/schemas/Lead'
# form 2
customFieldLeads:
allOf:
- type: array
readOnly: true
items:
$ref: '#/components/schemas/Lead'
- x-db-type: false
The output must be identical to the plain form without the marker (property type, transformer
include, client relations() entry), with two differences: no DB column, and
- public function getCustomFieldLeads()
- {
- return $this->hasMany(\common\models\Lead::class, ['order_id' => 'id'])->inverseOf('order');
- }
+ abstract public function getCustomFieldLeads(): \yii\db\ActiveQuery;
Now
Form 1 throws:
InvalidDefinitionException: References not supported for virtual attributes
src/lib/AttributeResolver.php:306
Form 2 loses the whole inner schema. getAttr() reads the top level only, and the allOf loop in
PropertySchema::__construct() applies x-db-type: false only when the allOf holds a $ref.
The property degenerates to string and gets trim/string rules plus a real text column.
Root cause for both: initItemsReference() sets isNonDbReference only when the referenced
schema is non-DB (PropertySchema.php:217-219), never from the property's own x-db-type: false.
A single
$refcan already be declared as "not a foreign key" and then generates an abstractgetter the app implements itself:
For
type: arraythere is no spec form that reaches this.Wanted
One of these inputs should work (or both, whichever is cheaper):
The output must be identical to the plain form without the marker (property type, transformer
include, client
relations()entry), with two differences: no DB column, andNow
Form 1 throws:
Form 2 loses the whole inner schema.
getAttr()reads the top level only, and theallOfloop inPropertySchema::__construct()appliesx-db-type: falseonly when theallOfholds a$ref.The property degenerates to
stringand getstrim/stringrules plus a realtextcolumn.Root cause for both:
initItemsReference()setsisNonDbReferenceonly when the referencedschema is non-DB (
PropertySchema.php:217-219), never from the property's ownx-db-type: false.