diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php index dd3973d..08dc2e8 100644 --- a/Annotation/ApiDoc.php +++ b/Annotation/ApiDoc.php @@ -135,6 +135,11 @@ class ApiDoc */ private $statusCodes = array(); + /** + * @var array + */ + private $tags = array(); + public function __construct(array $data) { $this->resource = !empty($data['resource']) ? $data['resource'] : false; @@ -223,6 +228,16 @@ class ApiDoc $this->deprecated = $data['deprecated']; } + if (isset($data['tags'])) { + $tags = $data['tags']; + + if (!is_array($tags)) { + $tags = array($tags); + } + + $this->tags = $tags; + } + if (isset($data['https'])) { $this->https = $data['https']; } @@ -507,6 +522,14 @@ class ApiDoc return $this->requirements; } + /** + * @return array + */ + public function getTags() + { + return $this->tags; + } + /** * @param boolean $deprecated */ @@ -571,6 +594,10 @@ class ApiDoc $data['cache'] = $cache; } + if ($tags = $this->tags) { + $data['tags'] = $tags; + } + $data['https'] = $this->https; $data['authentication'] = $this->authentication; $data['authenticationRoles'] = $this->authenticationRoles; diff --git a/Resources/doc/index.md b/Resources/doc/index.md index b763562..b9572a2 100644 --- a/Resources/doc/index.md +++ b/Resources/doc/index.md @@ -127,6 +127,8 @@ The following properties are available: * `deprecated`: allow to set method as deprecated (default: `false`); +* `tags`: allow to tag a method (e.g. `beta` or `in-development`). Either a single tag or an array of tags. + * `filters`: an array of filters; * `requirements`: an array of requirements; diff --git a/Resources/public/css/screen.css b/Resources/public/css/screen.css index 5ef8389..6f35974 100644 --- a/Resources/public/css/screen.css +++ b/Resources/public/css/screen.css @@ -296,6 +296,18 @@ li.operation a.heading h3 span.path { padding-left: 5px; } +li.operation a.heading h3 span.tag { + color: #FFFFFF; + font-size: 0.7em; + vertical-align: baseline; + background-color: #d9534f; + padding-bottom: 3px; + padding-left: 6px; + padding-right: 6px; + padding-top: 2px; + border-radius: 4px; +} + li.operation div.content { border: 1px solid #ddd; padding: 10px; diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index 53cf9ba..b4b4ac2 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -25,6 +25,11 @@ {% endif -%} {{ data.uri }} + {% if data.tags is defined %} + {% for tag in data.tags %} + {{ tag }} + {% endfor %} + {% endif %}