Skip to content

Commit bdcf2d8

Browse files
committed
fix: swagger post param item
1 parent 18f821f commit bdcf2d8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Core/Swagger/Serializer/DocumentationNormalizer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ private function updatePostOperation(bool $v3, \ArrayObject $pathOperation, arra
582582
$identifiers = (array) $resourceMetadata
583583
->getTypedOperationAttribute($operationType, $operationName, 'identifiers', [], false);
584584

585-
$operationType = $identifiers ? $operationType : OperationType::COLLECTION;
586585
$pathOperation = $this->addItemOperationParameters($v3, $pathOperation, $operationType, $operationName, $resourceMetadata, $resourceClass);
587586

588587
$successResponse = ['description' => sprintf('%s resource created', $resourceShortName)];
@@ -682,6 +681,12 @@ private function addItemOperationParameters(bool $v3, \ArrayObject $pathOperatio
682681
$identifiers = (array) $resourceMetadata
683682
->getTypedOperationAttribute($operationType, $operationName, 'identifiers', [], false);
684683

684+
// Auto-generated routes in API Platform < 2.7 are considered as collection, hotfix this as the OpenApi Factory supports new operations anyways.
685+
// this also fixes a bug where we could not create POST item operations in API P 2.6
686+
if (OperationType::ITEM === $operationType && 'post' === substr($operationName, -4)) {
687+
$operationType = OperationType::COLLECTION;
688+
}
689+
685690
if (!$identifiers && OperationType::COLLECTION !== $operationType) {
686691
try {
687692
$identifiers = $this->identifiersExtractor->getIdentifiersFromResourceClass($resourceClass);

0 commit comments

Comments
 (0)