1616class AugmentTags
1717{
1818 /** @var array<string> */
19- protected array $ whitelist = [];
19+ protected array $ whitelist ;
20+ protected bool $ withDescription ;
2021
21- public function __construct (array $ whitelist = [])
22+ public function __construct (array $ whitelist = [], bool $ withDescription = true )
2223 {
2324 $ this ->whitelist = $ whitelist ;
25+ $ this ->withDescription = $ withDescription ;
2426 }
2527
2628 /**
@@ -33,6 +35,16 @@ public function setWhitelist(array $whitelist): AugmentTags
3335 return $ this ;
3436 }
3537
38+ /**
39+ * Enables/disables generation of default tag descriptions.
40+ */
41+ public function setWithDescription (bool $ withDescription ): AugmentTags
42+ {
43+ $ this ->withDescription = $ withDescription ;
44+
45+ return $ this ;
46+ }
47+
3648 public function __invoke (Analysis $ analysis ): void
3749 {
3850 /** @var OA\Operation[] $operations */
@@ -62,7 +74,12 @@ public function __invoke(Analysis $analysis): void
6274 $ declatedTagNames = array_keys ($ declaredTags );
6375 foreach ($ usedTagNames as $ tagName ) {
6476 if (!in_array ($ tagName , $ declatedTagNames )) {
65- $ analysis ->openapi ->merge ([new OA \Tag (['name ' => $ tagName , 'description ' => $ tagName ])]);
77+ $ analysis ->openapi ->merge ([new OA \Tag ([
78+ 'name ' => $ tagName ,
79+ 'description ' => $ this ->withDescription
80+ ? $ tagName
81+ : Generator::UNDEFINED ,
82+ ])]);
6683 }
6784 }
6885 }
0 commit comments