@@ -60,7 +60,7 @@ class AttributeResolver
6060 /**
6161 * @var ComponentSchema
6262 */
63- private $ schema ;
63+ private $ componentSchema ;
6464
6565 /**
6666 * @var \cebe\yii2openapi\lib\items\JunctionSchemas
@@ -79,7 +79,7 @@ class AttributeResolver
7979 public function __construct (string $ schemaName , ComponentSchema $ schema , JunctionSchemas $ junctions , ?Config $ config = null )
8080 {
8181 $ this ->schemaName = $ schemaName ;
82- $ this ->schema = $ schema ;
82+ $ this ->componentSchema = $ schema ;
8383 $ this ->tableName = $ schema ->resolveTableName ($ schemaName );
8484 $ this ->junctions = $ junctions ;
8585 $ this ->isJunctionSchema = $ junctions ->isJunctionSchema ($ schemaName );
@@ -94,10 +94,10 @@ public function __construct(string $schemaName, ComponentSchema $schema, Junctio
9494 */
9595 public function resolve ():DbModel
9696 {
97- foreach ($ this ->schema ->getProperties () as $ property ) {
97+ foreach ($ this ->componentSchema ->getProperties () as $ property ) {
9898 /** @var $property \cebe\yii2openapi\lib\openapi\PropertySchema */
9999
100- $ isRequired = $ this ->schema ->isRequiredProperty ($ property ->getName ());
100+ $ isRequired = $ this ->componentSchema ->isRequiredProperty ($ property ->getName ());
101101 $ nullableValue = $ property ->getProperty ()->getSerializableData ()->nullable ?? null ;
102102 if ($ nullableValue === false ) { // see docs in README regarding NOT NULL, required and nullable
103103 $ isRequired = true ;
@@ -113,18 +113,20 @@ public function resolve():DbModel
113113 }
114114 return Yii::createObject (DbModel::class, [
115115 [
116- 'pkName ' => $ this ->schema ->getPkName (),
116+ /** @see \cebe\openapi\spec\Schema */
117+ 'openapiSchema ' => $ this ->componentSchema ->getSchema (),
118+ 'pkName ' => $ this ->componentSchema ->getPkName (),
117119 'name ' => $ this ->schemaName ,
118120 'tableName ' => $ this ->tableName ,
119- 'description ' => $ this ->schema ->getDescription (),
121+ 'description ' => $ this ->componentSchema ->getDescription (),
120122 'attributes ' => $ this ->attributes ,
121123 'relations ' => $ this ->relations ,
122124 'nonDbRelations ' => $ this ->nonDbRelations ,
123125 'many2many ' => $ this ->many2many ,
124- 'indexes ' => $ this ->prepareIndexes ($ this ->schema ->getIndexes ()),
126+ 'indexes ' => $ this ->prepareIndexes ($ this ->componentSchema ->getIndexes ()),
125127 //For valid primary keys for junction tables
126128 'junctionCols ' => $ this ->isJunctionSchema ? $ this ->junctions ->junctionCols ($ this ->schemaName ) : [],
127- 'isNotDb ' => $ this ->schema ->isNonDb (),
129+ 'isNotDb ' => $ this ->componentSchema ->isNonDb (),
128130 ],
129131 ]);
130132 }
@@ -185,7 +187,7 @@ protected function resolveHasMany2ManyTableProperty(PropertySchema $property, bo
185187 'relatedSchemaName ' => $ junkAttribute ['relatedClassName ' ],
186188 'tableName ' => $ this ->tableName ,
187189 'relatedTableName ' => $ junkAttribute ['relatedTableName ' ],
188- 'pkAttribute ' => $ this ->attributes [$ this ->schema ->getPkName ()],
190+ 'pkAttribute ' => $ this ->attributes [$ this ->componentSchema ->getPkName ()],
189191 'hasViaModel ' => true ,
190192 'viaModelName ' => $ viaModel ,
191193 'viaRelationName ' => Inflector::id2camel ($ junkRef , '_ ' ),
@@ -197,7 +199,7 @@ protected function resolveHasMany2ManyTableProperty(PropertySchema $property, bo
197199
198200 $ this ->relations [Inflector::pluralize ($ junkRef )] =
199201 Yii::createObject (AttributeRelation::class, [$ junkRef , $ junkAttribute ['junctionTable ' ], $ viaModel ])
200- ->asHasMany ([$ junkAttribute ['pairProperty ' ] . '_id ' => $ this ->schema ->getPkName ()]);
202+ ->asHasMany ([$ junkAttribute ['pairProperty ' ] . '_id ' => $ this ->componentSchema ->getPkName ()]);
201203 return ;
202204 }
203205
@@ -328,7 +330,7 @@ protected function resolveProperty(
328330 AttributeRelation::class,
329331 [$ property ->getName (), $ relatedTableName , $ relatedClassName ]
330332 )
331- ->asHasMany ([$ foreignPk => $ this ->schema ->getPkName ()]);
333+ ->asHasMany ([$ foreignPk => $ this ->componentSchema ->getPkName ()]);
332334 return ;
333335 }
334336 $ relatedClassName = $ property ->getRefClassName ();
@@ -347,10 +349,10 @@ protected function resolveProperty(
347349 AttributeRelation::class,
348350 [$ property ->getName (), $ relatedTableName , $ relatedClassName ]
349351 )
350- ->asHasMany ([Inflector::camel2id ($ this ->schemaName , '_ ' ) . '_id ' => $ this ->schema ->getPkName ()]);
352+ ->asHasMany ([Inflector::camel2id ($ this ->schemaName , '_ ' ) . '_id ' => $ this ->componentSchema ->getPkName ()]);
351353 return ;
352354 }
353- if ($ this ->schema ->isNonDb () && $ attribute ->isReference ()) {
355+ if ($ this ->componentSchema ->isNonDb () && $ attribute ->isReference ()) {
354356 $ this ->attributes [$ property ->getName ()] = $ attribute ;
355357 return ;
356358 }
@@ -398,7 +400,7 @@ protected function catchManyToMany(
398400 'relatedSchemaName ' => $ relatedSchemaName ,
399401 'tableName ' => $ this ->tableName ,
400402 'relatedTableName ' => $ relatedTableName ,
401- 'pkAttribute ' => $ this ->attributes [$ this ->schema ->getPkName ()],
403+ 'pkAttribute ' => $ this ->attributes [$ this ->componentSchema ->getPkName ()],
402404 ],
403405 ]);
404406 $ this ->many2many [$ propertyName ] = $ relation ;
@@ -480,7 +482,7 @@ protected function resolvePropertyRef(PropertySchema $property, Attribute $attri
480482 $ fkProperty = new PropertySchema (
481483 $ property ->getRefSchema ()->getSchema (),
482484 $ property ->getName (),
483- $ this ->schema
485+ $ this ->componentSchema
484486 );
485487 [$ min , $ max ] = $ fkProperty ->guessMinMax ();
486488 $ attribute ->setPhpType ($ fkProperty ->guessPhpType ())
0 commit comments