Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat empty description same as Generator::UNDEFINED #1674

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions Examples/petstore.swagger.io/petstore.swagger.io.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ paths:
tags:
- pet
summary: 'Updates a pet in the store with form data'
description: ''
operationId: updatePetWithForm
parameters:
-
Expand Down Expand Up @@ -152,7 +151,6 @@ paths:
tags:
- pet
summary: 'Deletes a pet'
description: ''
operationId: deletePet
parameters:
-
Expand All @@ -178,7 +176,6 @@ paths:
tags:
- pet
summary: 'Update an existing pet.'
description: ''
operationId: updatePet
requestBody:
description: 'Pet object that needs to be added to the store'
Expand Down Expand Up @@ -206,7 +203,6 @@ paths:
tags:
- pet
summary: 'Add a new pet to the store'
description: ''
operationId: addPet
requestBody:
description: 'Pet object that needs to be added to the store'
Expand All @@ -231,7 +227,6 @@ paths:
tags:
- pet
summary: 'uploads an image'
description: ''
operationId: uploadFile
parameters:
-
Expand Down Expand Up @@ -285,7 +280,6 @@ paths:
tags:
- store
summary: 'Place an order for a pet'
description: ''
operationId: placeOrder
requestBody:
description: 'order placed for purchasing the pet'
Expand Down Expand Up @@ -367,7 +361,6 @@ paths:
tags:
- user
summary: 'Creates list of users with given input array'
description: ''
operationId: createUsersWithArrayInput
requestBody:
description: 'List of user object'
Expand All @@ -386,7 +379,6 @@ paths:
tags:
- user
summary: 'Creates list of users with given input array'
description: ''
operationId: createUsersWithListInput
requestBody:
description: 'List of user object'
Expand All @@ -405,7 +397,6 @@ paths:
tags:
- user
summary: 'Logs user into the system'
description: ''
operationId: loginUser
parameters:
-
Expand Down Expand Up @@ -442,7 +433,6 @@ paths:
tags:
- user
summary: 'Logs out current logged in user session'
description: ''
operationId: logoutUser
parameters: []
responses:
Expand All @@ -453,7 +443,6 @@ paths:
tags:
- user
summary: 'Get user by user name'
description: ''
operationId: getUserByName
parameters:
-
Expand Down
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
"symfony/finder": ">=2.2",
"symfony/yaml": ">=3.3"
},
"autoload": {
"psr-4": {
"OpenApi\\": "src"
}
},
"require-dev": {
"composer/package-versions-deprecated": "^1.11",
"doctrine/annotations": "^1.7 || ^2.0",
Expand All @@ -64,8 +59,10 @@
"phpunit/phpunit": ">=8",
"vimeo/psalm": "^4.23"
},
"suggest": {
"doctrine/annotations": "^1.7 || ^2.0"
"autoload": {
"psr-4": {
"OpenApi\\": "src"
}
},
"autoload-dev": {
"exclude-from-classmap": [
Expand All @@ -77,6 +74,12 @@
"AnotherNamespace\\": "tests/Fixtures/AnotherNamespace"
}
},
"conflict": {
"symfony/process": ">=6, <6.4.14"
},
"suggest": {
"doctrine/annotations": "^1.7 || ^2.0"
},
"scripts-descriptions": {
"cs": "Fix all codestyle issues",
"lint": "Test codestyle",
Expand Down
12 changes: 6 additions & 6 deletions src/Processors/DocBlockDescriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use OpenApi\Generator;

/**
* Checks if the annotation has a summary and/or description property
* and uses the text in the comment block (above the annotations) as summary and/or description.
* Checks if the annotation has a summary and/or description property and uses
* the text in the docblock (above the annotations) as summary and/or description.
*
* Use `null`, for example: `@Annotation(description=null)`, if you don't want the annotation to have a description.
* Use an empty string `''`, for example: `@Annotation(description="")`, if you don't want the annotation to have a description.
*/
class DocBlockDescriptions implements ProcessorInterface
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public function __invoke(Analysis $analysis)
protected function description(OA\AbstractAnnotation $annotation): void
{
if (!Generator::isDefault($annotation->description)) {
if ($annotation->description === null) {
if ($annotation->description === null || $annotation->description === '') {
$annotation->description = Generator::UNDEFINED;
}

Expand All @@ -69,8 +69,8 @@ protected function description(OA\AbstractAnnotation $annotation): void
*/
protected function summaryAndDescription(OA\AbstractAnnotation $annotation): void
{
$ignoreSummary = !Generator::isDefault($annotation->summary);
$ignoreDescription = !Generator::isDefault($annotation->description);
$ignoreSummary = !Generator::isDefault($annotation->summary) && $annotation->summary !== '';
$ignoreDescription = !Generator::isDefault($annotation->description) && $annotation->description !== '';
if ($annotation->summary === null) {
$ignoreSummary = true;
$annotation->summary = Generator::UNDEFINED;
Expand Down