@@ -3605,7 +3605,16 @@ private function setPath(String $tableName) /*: void*/
36053605 private function setComponentSchema (String $ tableName ) /*: void*/
36063606 {
36073607 $ table = $ this ->reflection ->getTable ($ tableName );
3608+ $ type = $ table ->getType ($ tableName );
3609+ $ pk = $ table ->getPk ();
3610+ $ pkName = $ pk ? $ pk ->getName () : '' ;
36083611 foreach ($ this ->operations as $ operation => $ method ) {
3612+ if (!$ pkName && $ operation != 'list ' ) {
3613+ continue ;
3614+ }
3615+ if ($ type != 'table ' && $ operation != 'list ' ) {
3616+ continue ;
3617+ }
36093618 if ($ operation == 'delete ' ) {
36103619 continue ;
36113620 }
@@ -3637,7 +3646,17 @@ private function setComponentSchema(String $tableName) /*: void*/
36373646
36383647 private function setComponentResponse (String $ tableName ) /*: void*/
36393648 {
3649+ $ table = $ this ->reflection ->getTable ($ tableName );
3650+ $ type = $ table ->getType ($ tableName );
3651+ $ pk = $ table ->getPk ();
3652+ $ pkName = $ pk ? $ pk ->getName () : '' ;
36403653 foreach (['list ' , 'read ' ] as $ operation ) {
3654+ if (!$ pkName && $ operation != 'list ' ) {
3655+ continue ;
3656+ }
3657+ if ($ type != 'table ' && $ operation != 'list ' ) {
3658+ continue ;
3659+ }
36413660 if (!$ this ->isOperationOnTableAllowed ($ operation , $ tableName )) {
36423661 continue ;
36433662 }
@@ -3652,12 +3671,18 @@ private function setComponentResponse(String $tableName) /*: void*/
36523671
36533672 private function setComponentRequestBody (String $ tableName ) /*: void*/
36543673 {
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 ));
36583685 }
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 ));
36613686 }
36623687 }
36633688
0 commit comments