From fbdb00717564f7f7e1ce7a716a84cb4cf626d14c Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Mon, 4 Jan 2021 17:04:22 +0100 Subject: [PATCH] Make sure both, description and summary are generated --- src/OpenApi/Factory/OpenApiFactory.php | 2 +- tests/OpenApi/Factory/OpenApiFactoryTest.php | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/OpenApi/Factory/OpenApiFactory.php b/src/OpenApi/Factory/OpenApiFactory.php index 48895c3574d..1385dc5fc03 100644 --- a/src/OpenApi/Factory/OpenApiFactory.php +++ b/src/OpenApi/Factory/OpenApiFactory.php @@ -232,7 +232,7 @@ private function collectPaths(ResourceMetadata $resourceMetadata, string $resour $operationId, $operation['openapi_context']['tags'] ?? (OperationType::SUBRESOURCE === $operationType ? $operation['shortNames'] : [$resourceShortName]), $responses, - $operation['openapi_context']['summary'] ?? '', + $operation['openapi_context']['summary'] ?? $this->getPathDescription($resourceShortName, $method, $operationType), $operation['openapi_context']['description'] ?? $this->getPathDescription($resourceShortName, $method, $operationType), isset($operation['openapi_context']['externalDocs']) ? new ExternalDocumentation($operation['openapi_context']['externalDocs']['description'] ?? null, $operation['openapi_context']['externalDocs']['url']) : null, $parameters, diff --git a/tests/OpenApi/Factory/OpenApiFactoryTest.php b/tests/OpenApi/Factory/OpenApiFactoryTest.php index b4a7dbc0f44..db962e82a99 100644 --- a/tests/OpenApi/Factory/OpenApiFactoryTest.php +++ b/tests/OpenApi/Factory/OpenApiFactoryTest.php @@ -256,7 +256,7 @@ public function testInvoke(): void ]))), ])), ], - '', + 'Retrieves the collection of Dummy resources.', 'Retrieves the collection of Dummy resources.', null, [ @@ -289,7 +289,7 @@ public function testInvoke(): void ), '400' => new Model\Response('Invalid input'), ], - '', + 'Creates a Dummy resource.', 'Creates a Dummy resource.', null, [], @@ -320,7 +320,7 @@ public function testInvoke(): void ), '404' => new Model\Response('Resource not found'), ], - '', + 'Retrieves a Dummy resource.', 'Retrieves a Dummy resource.', null, [new Model\Parameter('id', 'path', 'Resource identifier', true, false, false, ['type' => 'string'])] @@ -341,7 +341,7 @@ public function testInvoke(): void '400' => new Model\Response('Invalid input'), '404' => new Model\Response('Resource not found'), ], - '', + 'Replaces the Dummy resource.', 'Replaces the Dummy resource.', null, [new Model\Parameter('id', 'path', 'Resource identifier', true, false, false, ['type' => 'string'])], @@ -361,7 +361,7 @@ public function testInvoke(): void '204' => new Model\Response('Dummy resource deleted'), '404' => new Model\Response('Resource not found'), ], - '', + 'Removes the Dummy resource.', 'Removes the Dummy resource.', null, [new Model\Parameter('id', 'path', 'Resource identifier', true, false, false, ['type' => 'string'])] @@ -374,7 +374,7 @@ public function testInvoke(): void [ '404' => new Model\Response('Resource not found'), ], - '', + 'Dummy', 'Custom description', null, [new Model\Parameter('id', 'path', 'Resource identifier', true, false, false, ['type' => 'string'])] @@ -397,7 +397,7 @@ public function testInvoke(): void '400' => new Model\Response('Invalid input'), '404' => new Model\Response('Resource not found'), ], - '', + 'Replaces the Dummy resource.', 'Replaces the Dummy resource.', null, [new Model\Parameter('id', 'path', 'Resource identifier', true, false, false, ['type' => 'string'])], @@ -423,7 +423,7 @@ public function testInvoke(): void ])), ])), ], - '', + 'Retrieves the collection of Dummy resources.', 'Retrieves the collection of Dummy resources.', null, [ @@ -467,7 +467,7 @@ public function testInvoke(): void ])), ])), ], - '', + 'Retrieves the collection of Dummy resources.', 'Retrieves the collection of Dummy resources.', null, [ @@ -683,7 +683,7 @@ public function testSubresourceDocumentation() ]) ), ], - '', + 'Retrieves a Question resource.', 'Retrieves a Question resource.', null, [new Model\Parameter('id', 'path', 'Question identifier', true, false, false, ['type' => 'string'])]