@@ -38,18 +38,18 @@ public function build(): OpenApiDefinition
3838 $ this ->openapi ->set ("openapi " , "3.0.0 " );
3939 $ tableNames = $ this ->reflection ->getTableNames ();
4040 foreach ($ tableNames as $ tableName ) {
41- $ this ->setPath (" paths " , $ tableName );
41+ $ this ->setPath ($ tableName );
4242 }
4343 foreach ($ tableNames as $ tableName ) {
44- $ this ->setComponentSchema (" components|schemas " , $ tableName );
44+ $ this ->setComponentSchema ($ tableName );
4545 }
4646 foreach ($ tableNames as $ index => $ tableName ) {
47- $ this ->setTag (" tags " , $ index , $ tableName );
47+ $ this ->setTag ($ index , $ tableName );
4848 }
4949 return $ this ->openapi ;
5050 }
5151
52- private function setPath (String $ prefix , String $ tableName ) /*: void*/
52+ private function setPath (String $ tableName ) /*: void*/
5353 {
5454 $ table = $ this ->reflection ->getTable ($ tableName );
5555 $ pk = $ table ->getPk ();
@@ -62,31 +62,31 @@ private function setPath(String $prefix, String $tableName) /*: void*/
6262 continue ;
6363 }
6464 $ path = sprintf ('/records/%s/{%s} ' , $ tableName , $ pkName );
65- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|name " , "id " );
66- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|in " , "path " );
67- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|schema|type " , "string " );
68- $ this ->openapi ->set ("$ prefix | $ path| $ method|parameters|0|required " , true );
65+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|name " , "id " );
66+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|in " , "path " );
67+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|schema|type " , "string " );
68+ $ this ->openapi ->set ("paths |$ path| $ method|parameters|0|required " , true );
6969 }
70- $ this ->openapi ->set ("$ prefix | $ path| $ method|tags|0 " , "$ tableName " );
71- $ this ->openapi ->set ("$ prefix | $ path| $ method|description " , "$ operation $ tableName " );
72- $ this ->openapi ->set ("$ prefix | $ path| $ method|responses|200|description " , "$ operation $ tableName succeeded " );
70+ $ this ->openapi ->set ("paths |$ path| $ method|tags|0 " , "$ tableName " );
71+ $ this ->openapi ->set ("paths |$ path| $ method|description " , "$ operation $ tableName " );
72+ $ this ->openapi ->set ("paths |$ path| $ method|responses|200|description " , "$ operation $ tableName succeeded " );
7373 }
7474 }
7575
76- private function setComponentSchema (String $ prefix , String $ tableName ) /*: void*/
76+ private function setComponentSchema (String $ tableName ) /*: void*/
7777 {
7878 $ this ->openapi ->set ("$ prefix| $ tableName|type " , "object " );
7979 $ table = $ this ->reflection ->getTable ($ tableName );
8080 foreach ($ table ->columnNames () as $ columnName ) {
8181 $ column = $ table ->get ($ columnName );
8282 $ type = $ this ->types [$ column ->getType ()];
83- $ this ->openapi ->set ("$ prefix | $ tableName|properties| $ columnName|type " , $ type );
83+ $ this ->openapi ->set ("components|schemas |$ tableName|properties| $ columnName|type " , $ type );
8484 }
8585 }
8686
87- private function setTag (String $ prefix , int $ index , String $ tableName ) /*: void*/
87+ private function setTag (int $ index , String $ tableName ) /*: void*/
8888 {
89- $ this ->openapi ->set ("$ prefix | $ index|name " , "$ tableName " );
90- $ this ->openapi ->set ("$ prefix | $ index|description " , "$ tableName operations " );
89+ $ this ->openapi ->set ("tags |$ index|name " , "$ tableName " );
90+ $ this ->openapi ->set ("tags |$ index|description " , "$ tableName operations " );
9191 }
9292}
0 commit comments