diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php index 5876601..cd49bdc 100644 --- a/Annotation/ApiDoc.php +++ b/Annotation/ApiDoc.php @@ -105,6 +105,11 @@ class ApiDoc */ private $authentication = false; + /** + * @var int + */ + private $cache; + /** * @var array */ @@ -328,6 +333,22 @@ class ApiDoc $this->authentication = $authentication; } + /** + * @return int + */ + public function getCache() + { + return $this->cache; + } + + /** + * @param int $cache + */ + public function setCache($cache) + { + $this->cache = (int) $cache; + } + /** * @return array */ @@ -370,6 +391,10 @@ class ApiDoc $data['section'] = $section; } + if ($cache = $this->cache) { + $data['cache'] = $cache; + } + $data['https'] = $this->https; $data['authentication'] = $this->authentication; diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index 8f7631a..50e647d 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -22,14 +22,16 @@ use Nelmio\ApiDocBundle\Util\DocCommentExtractor; class ApiDocExtractor { - const ANNOTATION_CLASS = 'Nelmio\\ApiDocBundle\\Annotation\\ApiDoc'; + const ANNOTATION_CLASS = 'Nelmio\\ApiDocBundle\\Annotation\\ApiDoc'; - const FOS_REST_QUERY_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\QueryParam'; + const FOS_REST_QUERY_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\QueryParam'; - const FOS_REST_REQUEST_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\RequestParam'; + const FOS_REST_REQUEST_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\RequestParam'; const JMS_SECURITY_EXTRA_SECURE_CLASS = 'JMS\\SecurityExtraBundle\\Annotation\\Secure'; + const CACHE_ANNOTATION_CLASS = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache'; + /** * @var ContainerInterface */ @@ -364,6 +366,8 @@ class ApiDocExtractor )); } elseif (is_a($annot, self::JMS_SECURITY_EXTRA_SECURE_CLASS)) { $annotation->setAuthentication(true); + } elseif (is_a($annot, self::CACHE_ANNOTATION_CLASS)) { + $annotation->setCache($annot->getMaxAge()); } } } diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index 49272f3..f6fdba5 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -165,6 +165,11 @@ {% endif %} + {% if data.cache is defined and data.cache is not empty %} +

Cache

+
{{ data.cache }}s
+ {% endif %} + {% if enableSandbox %}