@@ -390,13 +390,7 @@ private function updateGetOperation(bool $v3, \ArrayObject $pathOperation, array
390390
391391 $ pathOperation ['summary ' ] ?? $ pathOperation ['summary ' ] = sprintf ('Retrieves a %s resource. ' , $ resourceShortName );
392392
393- $ parameter = [
394- 'name ' => 'id ' ,
395- 'in ' => 'path ' ,
396- 'required ' => true ,
397- ];
398- $ v3 ? $ parameter ['schema ' ] = ['type ' => 'string ' ] : $ parameter ['type ' ] = 'string ' ;
399- $ pathOperation ['parameters ' ] ?? $ pathOperation ['parameters ' ] = [$ parameter ];
393+ $ pathOperation = $ this ->addItemOperationParameters ($ v3 , $ pathOperation );
400394
401395 $ successResponse = ['description ' => sprintf ('%s resource response ' , $ resourceShortName )];
402396 if ($ responseDefinitionKey ) {
@@ -424,6 +418,11 @@ private function updatePostOperation(bool $v3, \ArrayObject $pathOperation, arra
424418
425419 $ pathOperation ['summary ' ] ?? $ pathOperation ['summary ' ] = sprintf ('Creates a %s resource. ' , $ resourceShortName );
426420
421+ $ userDefinedParameters = $ pathOperation ['parameters ' ] ?? null ;
422+ if (OperationType::ITEM === $ operationType ) {
423+ $ pathOperation = $ this ->addItemOperationParameters ($ v3 , $ pathOperation );
424+ }
425+
427426 $ responseDefinitionKey = false ;
428427 $ outputMetadata = $ resourceMetadata ->getTypedOperationAttribute ($ operationType , $ operationName , 'output ' , ['class ' => $ resourceClass ], true );
429428 if (null !== $ outputClass = $ outputMetadata ['class ' ] ?? null ) {
@@ -460,12 +459,12 @@ private function updatePostOperation(bool $v3, \ArrayObject $pathOperation, arra
460459 'description ' => sprintf ('The new %s resource ' , $ resourceShortName ),
461460 ];
462461 } else {
463- $ pathOperation [ ' parameters ' ] ?? $ pathOperation ['parameters ' ] = [ [
462+ $ userDefinedParameters ?? $ pathOperation ['parameters ' ][] = [
464463 'name ' => lcfirst ($ resourceShortName ),
465464 'in ' => 'body ' ,
466465 'description ' => sprintf ('The new %s resource ' , $ resourceShortName ),
467466 'schema ' => ['$ref ' => sprintf ('#/definitions/%s ' , $ requestDefinitionKey )],
468- ]] ;
467+ ];
469468 }
470469
471470 return $ pathOperation ;
@@ -480,13 +479,7 @@ private function updatePutOperation(bool $v3, \ArrayObject $pathOperation, array
480479
481480 $ pathOperation ['summary ' ] ?? $ pathOperation ['summary ' ] = sprintf ('Replaces the %s resource. ' , $ resourceShortName );
482481
483- $ parameter = [
484- 'name ' => 'id ' ,
485- 'in ' => 'path ' ,
486- 'required ' => true ,
487- ];
488- $ v3 ? $ parameter ['schema ' ] = ['type ' => 'string ' ] : $ parameter ['type ' ] = 'string ' ;
489- $ pathOperation ['parameters ' ] ?? $ pathOperation ['parameters ' ] = [$ parameter ];
482+ $ pathOperation = $ this ->addItemOperationParameters ($ v3 , $ pathOperation );
490483
491484 $ responseDefinitionKey = false ;
492485 $ outputMetadata = $ resourceMetadata ->getTypedOperationAttribute ($ operationType , $ operationName , 'output ' , ['class ' => $ resourceClass ], true );
@@ -540,13 +533,17 @@ private function updateDeleteOperation(bool $v3, \ArrayObject $pathOperation, st
540533 '404 ' => ['description ' => 'Resource not found ' ],
541534 ];
542535
536+ return $ this ->addItemOperationParameters ($ v3 , $ pathOperation );
537+ }
538+
539+ private function addItemOperationParameters (bool $ v3 , \ArrayObject $ pathOperation ): \ArrayObject
540+ {
543541 $ parameter = [
544542 'name ' => 'id ' ,
545543 'in ' => 'path ' ,
546544 'required ' => true ,
547545 ];
548546 $ v3 ? $ parameter ['schema ' ] = ['type ' => 'string ' ] : $ parameter ['type ' ] = 'string ' ;
549-
550547 $ pathOperation ['parameters ' ] ?? $ pathOperation ['parameters ' ] = [$ parameter ];
551548
552549 return $ pathOperation ;
0 commit comments