Skip to content

Commit

Permalink
Support defining descriptions for @SwagHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
cnizzardini committed May 1, 2020
1 parent cf88d28 commit 09b979f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Lib/Annotation/SwagHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @Attributes({
* @Attribute("name", type = "string"),
* @Attribute("type", type = "string"),
* @Attribute("description", type = "string"),
* @Attribute("required", type = "bool"),
* })
*/
Expand All @@ -21,6 +22,9 @@ class SwagHeader
/** @var string */
public $type;

/** @var string */
public $description;

/** @var bool */
public $required;

Expand All @@ -30,10 +34,11 @@ public function __construct(array $values)
throw new InvalidArgumentException('Name parameter is required');
}

$values = array_merge(['type' => 'string', 'required' => false], $values);
$values = array_merge(['type' => 'string', 'description' => '', 'required' => false], $values);

$this->name = $values['name'];
$this->type = $values['type'];
$this->description = $values['description'];
$this->required = (bool) $values['required'];
}
}
1 change: 1 addition & 0 deletions src/Lib/Annotation/SwagHeaderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function getHeaderParameters(SwagHeader $annotation) : Parameter
$parameter = new Parameter();
$parameter
->setName($annotation->name)
->setDescription($annotation->description)
->setAllowEmptyValue(false)
->setDeprecated(false)
->setRequired($annotation->required)
Expand Down

0 comments on commit 09b979f

Please sign in to comment.