@@ -60,7 +60,7 @@ class AttributeResolver
60
60
/**
61
61
* @var ComponentSchema
62
62
*/
63
- private $ schema ;
63
+ private $ componentSchema ;
64
64
65
65
/**
66
66
* @var \cebe\yii2openapi\lib\items\JunctionSchemas
@@ -79,7 +79,7 @@ class AttributeResolver
79
79
public function __construct (string $ schemaName , ComponentSchema $ schema , JunctionSchemas $ junctions , ?Config $ config = null )
80
80
{
81
81
$ this ->schemaName = $ schemaName ;
82
- $ this ->schema = $ schema ;
82
+ $ this ->componentSchema = $ schema ;
83
83
$ this ->tableName = $ schema ->resolveTableName ($ schemaName );
84
84
$ this ->junctions = $ junctions ;
85
85
$ this ->isJunctionSchema = $ junctions ->isJunctionSchema ($ schemaName );
@@ -94,10 +94,10 @@ public function __construct(string $schemaName, ComponentSchema $schema, Junctio
94
94
*/
95
95
public function resolve ():DbModel
96
96
{
97
- foreach ($ this ->schema ->getProperties () as $ property ) {
97
+ foreach ($ this ->componentSchema ->getProperties () as $ property ) {
98
98
/** @var $property \cebe\yii2openapi\lib\openapi\PropertySchema */
99
99
100
- $ isRequired = $ this ->schema ->isRequiredProperty ($ property ->getName ());
100
+ $ isRequired = $ this ->componentSchema ->isRequiredProperty ($ property ->getName ());
101
101
$ nullableValue = $ property ->getProperty ()->getSerializableData ()->nullable ?? null ;
102
102
if ($ nullableValue === false ) { // see docs in README regarding NOT NULL, required and nullable
103
103
$ isRequired = true ;
@@ -113,18 +113,20 @@ public function resolve():DbModel
113
113
}
114
114
return Yii::createObject (DbModel::class, [
115
115
[
116
- 'pkName ' => $ this ->schema ->getPkName (),
116
+ /** @see \cebe\openapi\spec\Schema */
117
+ 'openapiSchema ' => $ this ->componentSchema ->getSchema (),
118
+ 'pkName ' => $ this ->componentSchema ->getPkName (),
117
119
'name ' => $ this ->schemaName ,
118
120
'tableName ' => $ this ->tableName ,
119
- 'description ' => $ this ->schema ->getDescription (),
121
+ 'description ' => $ this ->componentSchema ->getDescription (),
120
122
'attributes ' => $ this ->attributes ,
121
123
'relations ' => $ this ->relations ,
122
124
'nonDbRelations ' => $ this ->nonDbRelations ,
123
125
'many2many ' => $ this ->many2many ,
124
- 'indexes ' => $ this ->prepareIndexes ($ this ->schema ->getIndexes ()),
126
+ 'indexes ' => $ this ->prepareIndexes ($ this ->componentSchema ->getIndexes ()),
125
127
//For valid primary keys for junction tables
126
128
'junctionCols ' => $ this ->isJunctionSchema ? $ this ->junctions ->junctionCols ($ this ->schemaName ) : [],
127
- 'isNotDb ' => $ this ->schema ->isNonDb (),
129
+ 'isNotDb ' => $ this ->componentSchema ->isNonDb (),
128
130
],
129
131
]);
130
132
}
@@ -185,7 +187,7 @@ protected function resolveHasMany2ManyTableProperty(PropertySchema $property, bo
185
187
'relatedSchemaName ' => $ junkAttribute ['relatedClassName ' ],
186
188
'tableName ' => $ this ->tableName ,
187
189
'relatedTableName ' => $ junkAttribute ['relatedTableName ' ],
188
- 'pkAttribute ' => $ this ->attributes [$ this ->schema ->getPkName ()],
190
+ 'pkAttribute ' => $ this ->attributes [$ this ->componentSchema ->getPkName ()],
189
191
'hasViaModel ' => true ,
190
192
'viaModelName ' => $ viaModel ,
191
193
'viaRelationName ' => Inflector::id2camel ($ junkRef , '_ ' ),
@@ -197,7 +199,7 @@ protected function resolveHasMany2ManyTableProperty(PropertySchema $property, bo
197
199
198
200
$ this ->relations [Inflector::pluralize ($ junkRef )] =
199
201
Yii::createObject (AttributeRelation::class, [$ junkRef , $ junkAttribute ['junctionTable ' ], $ viaModel ])
200
- ->asHasMany ([$ junkAttribute ['pairProperty ' ] . '_id ' => $ this ->schema ->getPkName ()]);
202
+ ->asHasMany ([$ junkAttribute ['pairProperty ' ] . '_id ' => $ this ->componentSchema ->getPkName ()]);
201
203
return ;
202
204
}
203
205
@@ -328,7 +330,7 @@ protected function resolveProperty(
328
330
AttributeRelation::class,
329
331
[$ property ->getName (), $ relatedTableName , $ relatedClassName ]
330
332
)
331
- ->asHasMany ([$ foreignPk => $ this ->schema ->getPkName ()]);
333
+ ->asHasMany ([$ foreignPk => $ this ->componentSchema ->getPkName ()]);
332
334
return ;
333
335
}
334
336
$ relatedClassName = $ property ->getRefClassName ();
@@ -347,10 +349,10 @@ protected function resolveProperty(
347
349
AttributeRelation::class,
348
350
[$ property ->getName (), $ relatedTableName , $ relatedClassName ]
349
351
)
350
- ->asHasMany ([Inflector::camel2id ($ this ->schemaName , '_ ' ) . '_id ' => $ this ->schema ->getPkName ()]);
352
+ ->asHasMany ([Inflector::camel2id ($ this ->schemaName , '_ ' ) . '_id ' => $ this ->componentSchema ->getPkName ()]);
351
353
return ;
352
354
}
353
- if ($ this ->schema ->isNonDb () && $ attribute ->isReference ()) {
355
+ if ($ this ->componentSchema ->isNonDb () && $ attribute ->isReference ()) {
354
356
$ this ->attributes [$ property ->getName ()] = $ attribute ;
355
357
return ;
356
358
}
@@ -398,7 +400,7 @@ protected function catchManyToMany(
398
400
'relatedSchemaName ' => $ relatedSchemaName ,
399
401
'tableName ' => $ this ->tableName ,
400
402
'relatedTableName ' => $ relatedTableName ,
401
- 'pkAttribute ' => $ this ->attributes [$ this ->schema ->getPkName ()],
403
+ 'pkAttribute ' => $ this ->attributes [$ this ->componentSchema ->getPkName ()],
402
404
],
403
405
]);
404
406
$ this ->many2many [$ propertyName ] = $ relation ;
@@ -480,7 +482,7 @@ protected function resolvePropertyRef(PropertySchema $property, Attribute $attri
480
482
$ fkProperty = new PropertySchema (
481
483
$ property ->getRefSchema ()->getSchema (),
482
484
$ property ->getName (),
483
- $ this ->schema
485
+ $ this ->componentSchema
484
486
);
485
487
[$ min , $ max ] = $ fkProperty ->guessMinMax ();
486
488
$ attribute ->setPhpType ($ fkProperty ->guessPhpType ())
0 commit comments