1616class AugmentTags
1717{
1818 /** @var array<string> */
19- protected array $ whitelist = [] ;
19+ protected array $ whitelist ;
2020
21- public function __construct (array $ whitelist = [])
21+ protected bool $ withDescription ;
22+
23+ public function __construct (array $ whitelist = [], bool $ withDescription = true )
2224 {
2325 $ this ->whitelist = $ whitelist ;
26+ $ this ->withDescription = $ withDescription ;
2427 }
2528
2629 /**
@@ -33,6 +36,16 @@ public function setWhitelist(array $whitelist): AugmentTags
3336 return $ this ;
3437 }
3538
39+ /**
40+ * Enables/disables generation of default tag descriptions.
41+ */
42+ public function setWithDescription (bool $ withDescription ): AugmentTags
43+ {
44+ $ this ->withDescription = $ withDescription ;
45+
46+ return $ this ;
47+ }
48+
3649 public function __invoke (Analysis $ analysis ): void
3750 {
3851 $ operations = $ analysis ->getAnnotationsOfType (OA \Operation::class);
@@ -61,7 +74,12 @@ public function __invoke(Analysis $analysis): void
6174 $ declatedTagNames = array_keys ($ declaredTags );
6275 foreach ($ usedTagNames as $ tagName ) {
6376 if (!in_array ($ tagName , $ declatedTagNames )) {
64- $ 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+ ])]);
6583 }
6684 }
6785 }
0 commit comments