diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php
index 004f4bb..0d681b1 100644
--- a/Annotation/ApiDoc.php
+++ b/Annotation/ApiDoc.php
@@ -93,6 +93,11 @@ class ApiDoc
*/
private $https = false;
+ /**
+ * @var boolean
+ */
+ private $authentication = false;
+
/**
* @var array
*/
@@ -130,6 +135,10 @@ class ApiDoc
$this->addStatusCode($statusCode, $description);
}
}
+
+ if (isset($data['authentication'])) {
+ $this->setAuthentication((bool) $data['authentication']);
+ }
}
/**
@@ -276,6 +285,22 @@ class ApiDoc
$this->https = $https;
}
+ /**
+ * @return boolean
+ */
+ public function getAuthentication()
+ {
+ return $this->authentication;
+ }
+
+ /**
+ * @param boolean $secured
+ */
+ public function setAuthentication($authentication)
+ {
+ $this->authentication = $authentication;
+ }
+
/**
* @return array
*/
@@ -315,6 +340,7 @@ class ApiDoc
}
$data['https'] = $this->https;
+ $data['authentication'] = $this->authentication;
return $data;
}
diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php
index bcbfc2f..8f7631a 100644
--- a/Extractor/ApiDocExtractor.php
+++ b/Extractor/ApiDocExtractor.php
@@ -28,6 +28,8 @@ class ApiDocExtractor
const FOS_REST_REQUEST_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\RequestParam';
+ const JMS_SECURITY_EXTRA_SECURE_CLASS = 'JMS\\SecurityExtraBundle\\Annotation\\Secure';
+
/**
* @var ContainerInterface
*/
@@ -360,6 +362,8 @@ class ApiDocExtractor
'description' => $annot->description,
'readonly' => false
));
+ } elseif (is_a($annot, self::JMS_SECURITY_EXTRA_SECURE_CLASS)) {
+ $annotation->setAuthentication(true);
}
}
}
diff --git a/Resources/public/css/screen.css b/Resources/public/css/screen.css
index 47843ca..fcf1848 100644
--- a/Resources/public/css/screen.css
+++ b/Resources/public/css/screen.css
@@ -538,7 +538,7 @@ form .request-content {
margin-bottom: 10px;
}
-.padlock {
+.icon {
height: 12px;
margin-left: 3px;
}
\ No newline at end of file
diff --git a/Resources/public/image/keys.png b/Resources/public/image/keys.png
new file mode 100644
index 0000000..031fa39
Binary files /dev/null and b/Resources/public/image/keys.png differ
diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig
index 1b93832..0930e7c 100644
--- a/Resources/views/method.html.twig
+++ b/Resources/views/method.html.twig
@@ -6,7 +6,10 @@
{% if data.https %}
-
+
+ {% endif %}
+ {% if data.authentication %}
+
{% endif %}
diff --git a/Tests/Annotation/ApiDocTest.php b/Tests/Annotation/ApiDocTest.php
index a285e68..f1fece7 100644
--- a/Tests/Annotation/ApiDocTest.php
+++ b/Tests/Annotation/ApiDocTest.php
@@ -28,6 +28,7 @@ class ApiDocTest extends TestCase
$this->assertFalse($annot->isResource());
$this->assertFalse(isset($array['description']));
$this->assertNull($annot->getInput());
+ $this->assertFalse($array['authentication']);
}
public function testConstructWithInvalidData()
@@ -197,4 +198,16 @@ class ApiDocTest extends TestCase
$this->assertEquals($array['statusCodes'][$code], !is_array($message) ? array($message) : $message);
}
}
+
+ public function testConstructWithAuthentication()
+ {
+ $data = array(
+ 'authentication' => true
+ );
+
+ $annot = new ApiDoc($data);
+ $array = $annot->toArray();
+
+ $this->assertTrue($array['authentication']);
+ }
}
diff --git a/Tests/Extractor/ApiDocExtratorTest.php b/Tests/Extractor/ApiDocExtratorTest.php
index 524c689..100bc8e 100644
--- a/Tests/Extractor/ApiDocExtratorTest.php
+++ b/Tests/Extractor/ApiDocExtratorTest.php
@@ -155,4 +155,16 @@ class ApiDocExtractorTest extends WebTestCase
$annotation->getDescription()
);
}
+
+ public function testGetWithAuthentication()
+ {
+ $container = $this->getContainer();
+ $extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
+ $annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::AuthenticatedAction', 'test_route_13');
+
+ $this->assertNotNull($annotation);
+ $this->assertTrue(
+ $annotation->getAuthentication()
+ );
+ }
}
diff --git a/Tests/Fixtures/Controller/TestController.php b/Tests/Fixtures/Controller/TestController.php
index de1f0b1..2402c8a 100644
--- a/Tests/Fixtures/Controller/TestController.php
+++ b/Tests/Fixtures/Controller/TestController.php
@@ -127,4 +127,12 @@ class TestController
{
}
+ /**
+ * @ApiDoc(
+ * authentication=true
+ * )
+ */
+ public function authenticatedAction()
+ {
+ }
}
diff --git a/Tests/Fixtures/app/config/routing.yml b/Tests/Fixtures/app/config/routing.yml
index d72aaa6..d128ce0 100644
--- a/Tests/Fixtures/app/config/routing.yml
+++ b/Tests/Fixtures/app/config/routing.yml
@@ -64,6 +64,10 @@ test_route_12:
requirements:
_scheme: https
+test_route_13:
+ pattern: /authenticated
+ defaults: { _controller: NelmioApiDocTestBundle:Test:authenticated }
+
test_service_route_1:
pattern: /tests.{_format}
defaults: { _controller: nemlio.test.controller:indexAction, _format: json }
diff --git a/Tests/Formatter/SimpleFormatterTest.php b/Tests/Formatter/SimpleFormatterTest.php
index 5b5aae1..eefef72 100644
--- a/Tests/Formatter/SimpleFormatterTest.php
+++ b/Tests/Formatter/SimpleFormatterTest.php
@@ -387,6 +387,7 @@ With multiple lines.',
'_format' => array('dataType' => '', 'description' => '', 'requirement' => ''),
),
'https' => false,
+ 'authentication' => false,
);
$this->assertEquals($expected, $result);