@@ -3328,14 +3328,14 @@ class OpenApiBuilder
33283328 'increment ' => 'patch ' ,
33293329 ];
33303330 private $ types = [
3331- 'integer ' => ' integer ' ,
3332- 'varchar ' => ' string ' ,
3333- 'blob ' => ' string ' ,
3334- 'clob ' => ' string ' ,
3335- 'decimal ' => ' string ' ,
3336- 'timestamp ' => ' string ' ,
3337- 'geometry ' => ' string ' ,
3338- 'boolean ' => ' boolean ' ,
3331+ 'integer ' => [ ' type ' => ' integer ', ' format ' => ' int64 ' ] ,
3332+ 'varchar ' => [ ' type ' => ' string '] ,
3333+ 'blob ' => [ ' type ' => ' string '] ,
3334+ 'clob ' => [ ' type ' => ' string '] ,
3335+ 'decimal ' => [ ' type ' => ' string '] ,
3336+ 'timestamp ' => [ ' type ' => ' string '] ,
3337+ 'geometry ' => [ ' type ' => ' string '] ,
3338+ 'boolean ' => [ ' type ' => ' boolean '] ,
33393339 ];
33403340
33413341 public function __construct (ReflectionService $ reflection , $ base )
@@ -3349,18 +3349,18 @@ public function build(): OpenApiDefinition
33493349 $ this ->openapi ->set ("openapi " , "3.0.0 " );
33503350 $ tableNames = $ this ->reflection ->getTableNames ();
33513351 foreach ($ tableNames as $ tableName ) {
3352- $ this ->setPath (" paths " , $ tableName );
3352+ $ this ->setPath ($ tableName );
33533353 }
33543354 foreach ($ tableNames as $ tableName ) {
3355- $ this ->setComponentSchema (" components|schemas " , $ tableName );
3355+ $ this ->setComponentSchema ($ tableName );
33563356 }
33573357 foreach ($ tableNames as $ index => $ tableName ) {
3358- $ this ->setTag (" tags " , $ index , $ tableName );
3358+ $ this ->setTag ($ index , $ tableName );
33593359 }
33603360 return $ this ->openapi ;
33613361 }
33623362
3363- private function setPath (String $ prefix , String $ tableName ) /*: void*/
3363+ private function setPath (String $ tableName ) /*: void*/
33643364 {
33653365 $ table = $ this ->reflection ->getTable ($ tableName );
33663366 $ pk = $ table ->getPk ();
@@ -3373,32 +3373,35 @@ private function setPath(String $prefix, String $tableName) /*: void*/
33733373 continue ;
33743374 }
33753375 $ path = sprintf ('/records/%s/{%s} ' , $ tableName , $ pkName );
3376- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|name " , "id " );
3377- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|in " , "path " );
3378- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|schema|type " , "string " );
3379- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|required " , true );
3376+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|name " , "id " );
3377+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|in " , "path " );
3378+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|schema|type " , "string " );
3379+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|required " , true );
33803380 }
3381- $ this ->openapi ->set ("$ prefix | $ path| $ method|tags|0 " , "$ tableName " );
3382- $ this ->openapi ->set ("$ prefix | $ path| $ method|description " , "$ operation $ tableName " );
3383- $ this ->openapi ->set ("$ prefix | $ path| $ method|responses|200|description " , "$ operation $ tableName succeeded " );
3381+ $ this ->openapi ->set ("paths |$ path| $ method|tags|0 " , "$ tableName " );
3382+ $ this ->openapi ->set ("paths |$ path| $ method|description " , "$ operation $ tableName " );
3383+ $ this ->openapi ->set ("paths |$ path| $ method|responses|200|description " , "$ operation $ tableName succeeded " );
33843384 }
33853385 }
33863386
3387- private function setComponentSchema (String $ prefix , String $ tableName ) /*: void*/
3387+ private function setComponentSchema (String $ tableName ) /*: void*/
33883388 {
3389- $ this ->openapi ->set ("$ prefix | $ tableName|type " , "object " );
3389+ $ this ->openapi ->set ("components|schemas |$ tableName|type " , "object " );
33903390 $ table = $ this ->reflection ->getTable ($ tableName );
33913391 foreach ($ table ->columnNames () as $ columnName ) {
33923392 $ column = $ table ->get ($ columnName );
3393- $ type = $ this ->types [$ column ->getType ()];
3394- $ this ->openapi ->set ("$ prefix| $ tableName|properties| $ columnName|type " , $ type );
3393+ $ properties = $ this ->types [$ column ->getType ()];
3394+ foreach ($ properties as $ key => $ value ) {
3395+ $ this ->openapi ->set ("components|schemas| $ tableName|properties| $ columnName| $ key " , $ type );
3396+ }
3397+
33953398 }
33963399 }
33973400
3398- private function setTag (String $ prefix , int $ index , String $ tableName ) /*: void*/
3401+ private function setTag (int $ index , String $ tableName ) /*: void*/
33993402 {
3400- $ this ->openapi ->set ("$ prefix | $ index|name " , "$ tableName " );
3401- $ this ->openapi ->set ("$ prefix | $ index|description " , "$ tableName operations " );
3403+ $ this ->openapi ->set ("tags |$ index|name " , "$ tableName " );
3404+ $ this ->openapi ->set ("tags |$ index|description " , "$ tableName operations " );
34023405 }
34033406}
34043407
0 commit comments