diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php index c06eec7..f9fe6d2 100644 --- a/Annotation/ApiDoc.php +++ b/Annotation/ApiDoc.php @@ -78,6 +78,11 @@ class ApiDoc */ private $route; + /** + * @var array + */ + private $statusCodes = array(); + public function __construct(array $data) { if (isset($data['input'])) { @@ -103,6 +108,10 @@ class ApiDoc $this->return = $data['return']; } + if (isset($data['statusCodes'])) { + $this->statusCodes = $data['statusCodes']; + } + $this->isResource = isset($data['resource']) && $data['resource']; } @@ -238,6 +247,22 @@ class ApiDoc return $this->route; } + /** + * @return array + */ + public function getStatusCodes() + { + return $this->statusCodes; + } + + /** + * @param array $codes + */ + public function addStatusCodes($codes) + { + $this->statusCodes = array_merge($this->statusCodes, $codes); + } + /** * @return array */ @@ -272,6 +297,10 @@ class ApiDoc $data['response'] = $response; } + if ($statusCodes = $this->statusCodes) { + $data['statusCodes'] = $statusCodes; + } + return $data; } } diff --git a/README.md b/README.md index 451d7c6..808349f 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,30 @@ The following properties are available: * `input`: the input type associated to the method, currently this supports Form Types, and classes with JMS Serializer metadata, useful for POST|PUT methods, either as FQCN or as form type (if it is registered in the form factory in the container) - + * `return`: the return type associated with the response. Specified and parsed the same way as `input`. +* `statusCodes`: an array of HTTP status codes and a description of when that status is returned; Example: + +``` php + {% endif %} + + {% if data.statusCodes is defined and data.statusCodes is not empty %} +
Status Code | +Description | +
---|---|
{{ status_code }} | +{{ description }} | +