@@ -3605,7 +3605,16 @@ private function setPath(String $tableName) /*: void*/
3605
3605
private function setComponentSchema (String $ tableName ) /*: void*/
3606
3606
{
3607
3607
$ table = $ this ->reflection ->getTable ($ tableName );
3608
+ $ type = $ table ->getType ($ tableName );
3609
+ $ pk = $ table ->getPk ();
3610
+ $ pkName = $ pk ? $ pk ->getName () : '' ;
3608
3611
foreach ($ this ->operations as $ operation => $ method ) {
3612
+ if (!$ pkName && $ operation != 'list ' ) {
3613
+ continue ;
3614
+ }
3615
+ if ($ type != 'table ' && $ operation != 'list ' ) {
3616
+ continue ;
3617
+ }
3609
3618
if ($ operation == 'delete ' ) {
3610
3619
continue ;
3611
3620
}
@@ -3637,7 +3646,17 @@ private function setComponentSchema(String $tableName) /*: void*/
3637
3646
3638
3647
private function setComponentResponse (String $ tableName ) /*: void*/
3639
3648
{
3649
+ $ table = $ this ->reflection ->getTable ($ tableName );
3650
+ $ type = $ table ->getType ($ tableName );
3651
+ $ pk = $ table ->getPk ();
3652
+ $ pkName = $ pk ? $ pk ->getName () : '' ;
3640
3653
foreach (['list ' , 'read ' ] as $ operation ) {
3654
+ if (!$ pkName && $ operation != 'list ' ) {
3655
+ continue ;
3656
+ }
3657
+ if ($ type != 'table ' && $ operation != 'list ' ) {
3658
+ continue ;
3659
+ }
3641
3660
if (!$ this ->isOperationOnTableAllowed ($ operation , $ tableName )) {
3642
3661
continue ;
3643
3662
}
@@ -3652,12 +3671,18 @@ private function setComponentResponse(String $tableName) /*: void*/
3652
3671
3653
3672
private function setComponentRequestBody (String $ tableName ) /*: void*/
3654
3673
{
3655
- foreach (['create ' , 'update ' , 'increment ' ] as $ operation ) {
3656
- if (!$ this ->isOperationOnTableAllowed ($ operation , $ tableName )) {
3657
- continue ;
3674
+ $ table = $ this ->reflection ->getTable ($ tableName );
3675
+ $ type = $ table ->getType ($ tableName );
3676
+ $ pk = $ table ->getPk ();
3677
+ $ pkName = $ pk ? $ pk ->getName () : '' ;
3678
+ if ($ pkName && $ type == 'table ' ) {
3679
+ foreach (['create ' , 'update ' , 'increment ' ] as $ operation ) {
3680
+ if (!$ this ->isOperationOnTableAllowed ($ operation , $ tableName )) {
3681
+ continue ;
3682
+ }
3683
+ $ this ->openapi ->set ("components|requestBodies| $ operation- $ tableName|description " , "single $ tableName record " );
3684
+ $ this ->openapi ->set ("components|requestBodies| $ operation- $ tableName|content|application/json|schema| \$ref " , "#/components/schemas/ $ operation- " . urlencode ($ tableName ));
3658
3685
}
3659
- $ this ->openapi ->set ("components|requestBodies| $ operation- $ tableName|description " , "single $ tableName record " );
3660
- $ this ->openapi ->set ("components|requestBodies| $ operation- $ tableName|content|application/json|schema| \$ref " , "#/components/schemas/ $ operation- " . urlencode ($ tableName ));
3661
3686
}
3662
3687
}
3663
3688
0 commit comments