mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Added padlock icon for secure routes
This fixes #115 - Added an https property to the annotation - Added glyphicon padlock icon - Updated Templates - Updated Unit tests
This commit is contained in:
parent
63c19758aa
commit
ef5cbd9b73
@ -88,6 +88,11 @@ class ApiDoc
|
||||
*/
|
||||
private $route;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
private $https = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -244,6 +249,22 @@ class ApiDoc
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getHttps()
|
||||
{
|
||||
return $this->https;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $https
|
||||
*/
|
||||
public function setHttps($https)
|
||||
{
|
||||
$this->https = $https;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -282,6 +303,8 @@ class ApiDoc
|
||||
$data['statusCodes'] = $statusCodes;
|
||||
}
|
||||
|
||||
$data['https'] = $this->https;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -289,6 +289,10 @@ class ApiDocExtractor
|
||||
'description' => '',
|
||||
);
|
||||
}
|
||||
if ('_scheme' == $name) {
|
||||
$https = ('https' == $value);
|
||||
$annotation->setHttps($https);
|
||||
}
|
||||
}
|
||||
|
||||
$paramDocs = array();
|
||||
|
@ -537,3 +537,8 @@ form .request-content {
|
||||
margin-left: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.padlock {
|
||||
height: 12px;
|
||||
margin-left: 3px;
|
||||
}
|
BIN
Resources/public/image/lock.png
Normal file
BIN
Resources/public/image/lock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -4,6 +4,11 @@
|
||||
<span class="http_method">
|
||||
<a>{{ data.method|upper }}</a>
|
||||
</span>
|
||||
|
||||
{% if data.https %}
|
||||
<img src="{{ asset('bundles/nelmioapidoc/image/lock.png') }}" class="padlock" />
|
||||
{% endif %}
|
||||
|
||||
<span class="path">
|
||||
{{ data.uri }}
|
||||
</span>
|
||||
|
@ -22,7 +22,7 @@ class ApiDocExtractorTest extends WebTestCase
|
||||
$data = $extractor->all();
|
||||
|
||||
$this->assertTrue(is_array($data));
|
||||
$this->assertCount(13, $data);
|
||||
$this->assertCount(14, $data);
|
||||
|
||||
foreach ($data as $d) {
|
||||
$this->assertTrue(is_array($d));
|
||||
@ -61,6 +61,9 @@ class ApiDocExtractorTest extends WebTestCase
|
||||
$this->assertEquals('create test', $a2->getDescription());
|
||||
$this->assertFalse(isset($array2['filters']));
|
||||
$this->assertEquals('Nelmio\ApiDocBundle\Tests\Fixtures\Form\TestType', $a2->getInput());
|
||||
|
||||
$a3 = $data['10']['annotation'];
|
||||
$this->assertTrue($a3->getHttps());
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
|
@ -120,4 +120,11 @@ class TestController
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @ApiDoc()
|
||||
*/
|
||||
public function secureRouteAction()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,6 +58,12 @@ test_route_11:
|
||||
requirements:
|
||||
_method: POST
|
||||
|
||||
test_route_12:
|
||||
pattern: /secure-route
|
||||
defaults: { _controller: NelmioApiDocTestBundle:Test:secureRoute }
|
||||
requirements:
|
||||
_scheme: https
|
||||
|
||||
test_service_route_1:
|
||||
pattern: /tests.{_format}
|
||||
defaults: { _controller: nemlio.test.controller:indexAction, _format: json }
|
||||
|
@ -247,6 +247,16 @@ _This method is useful to test if the getDocComment works._
|
||||
- Type: int
|
||||
|
||||
|
||||
### `ANY` /secure-route ###
|
||||
|
||||
|
||||
#### Requirements ####
|
||||
|
||||
**_scheme**
|
||||
|
||||
- Requirement: https
|
||||
|
||||
|
||||
### `ANY` /yet-another/{id} ###
|
||||
|
||||
|
||||
|
@ -50,6 +50,7 @@ class SimpleFormatterTest extends WebTestCase
|
||||
'requirements' => array(
|
||||
'_format' => array('dataType' => '', 'description' => '', 'requirement' => ''),
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
@ -75,6 +76,7 @@ class SimpleFormatterTest extends WebTestCase
|
||||
'requirements' => array(
|
||||
'_format' => array('dataType' => '', 'description' => '', 'requirement' => ''),
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
@ -108,6 +110,7 @@ class SimpleFormatterTest extends WebTestCase
|
||||
'requirements' => array(
|
||||
'_format' => array('dataType' => '', 'description' => '', 'requirement' => ''),
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
@ -141,6 +144,7 @@ class SimpleFormatterTest extends WebTestCase
|
||||
'requirements' => array(
|
||||
'_format' => array('dataType' => '', 'description' => '', 'requirement' => ''),
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
),
|
||||
'others' =>
|
||||
@ -160,12 +164,14 @@ class SimpleFormatterTest extends WebTestCase
|
||||
),
|
||||
),
|
||||
'description' => 'create another test',
|
||||
'https' => false,
|
||||
),
|
||||
1 =>
|
||||
array(
|
||||
'method' => 'ANY',
|
||||
'uri' => '/any',
|
||||
'description' => 'Action without HTTP verb',
|
||||
'https' => false,
|
||||
),
|
||||
2 =>
|
||||
array(
|
||||
@ -176,6 +182,7 @@ class SimpleFormatterTest extends WebTestCase
|
||||
'foo' => array('dataType' => '', 'description' => '', 'requirement' => ''),
|
||||
),
|
||||
'description' => 'Action without HTTP verb',
|
||||
'https' => false,
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
@ -268,7 +275,8 @@ With multiple lines.',
|
||||
)
|
||||
),
|
||||
),
|
||||
'description' => 'Testing JMS'
|
||||
'description' => 'Testing JMS',
|
||||
'https' => false,
|
||||
),
|
||||
4 =>
|
||||
array(
|
||||
@ -282,7 +290,8 @@ With multiple lines.',
|
||||
'description' => 'A nice description',
|
||||
'readonly' => false
|
||||
)
|
||||
)
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
5 =>
|
||||
array(
|
||||
@ -293,10 +302,26 @@ With multiple lines.',
|
||||
'id' => array('dataType' => 'int', 'description' => 'A nice comment', 'requirement' => ''),
|
||||
'page' => array('dataType' => 'int', 'description' => '', 'requirement' => ''),
|
||||
),
|
||||
'https' => false,
|
||||
'description' => 'This method is useful to test if the getDocComment works.',
|
||||
'documentation' => "This method is useful to test if the getDocComment works.\nAnd, it supports multilines until the first '@' char."
|
||||
),
|
||||
6 =>
|
||||
array(
|
||||
'method' => 'ANY',
|
||||
'uri' => '/secure-route',
|
||||
// 'description' => '[secureRouteAction description]',
|
||||
// 'documentation' => '[secureRouteAction description]',
|
||||
'requirements' => array(
|
||||
'_scheme' => array(
|
||||
'requirement' => 'https',
|
||||
'dataType' => null,
|
||||
'description' => null,
|
||||
),
|
||||
),
|
||||
'https' => true,
|
||||
),
|
||||
7 =>
|
||||
array(
|
||||
'method' => 'ANY',
|
||||
'uri' => '/yet-another/{id}',
|
||||
@ -304,8 +329,9 @@ With multiple lines.',
|
||||
array(
|
||||
'id' => array('dataType' => '', 'description' => '', 'requirement' => '\d+')
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
7 =>
|
||||
8 =>
|
||||
array(
|
||||
'method' => 'GET',
|
||||
'uri' => '/z-action-with-query-param',
|
||||
@ -313,8 +339,9 @@ With multiple lines.',
|
||||
array(
|
||||
'page' => array('description' => 'Page of the overview.', 'requirement' => '\d+')
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
8 =>
|
||||
9 =>
|
||||
array(
|
||||
'method' => 'POST',
|
||||
'uri' => '/z-action-with-request-param',
|
||||
@ -322,6 +349,7 @@ With multiple lines.',
|
||||
array(
|
||||
'param1' => array('description' => 'Param1 description.', 'required' => true, 'dataType' => 'string', 'readonly' => false)
|
||||
),
|
||||
'https' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -356,6 +384,7 @@ With multiple lines.',
|
||||
'requirements' => array(
|
||||
'_format' => array('dataType' => '', 'description' => '', 'requirement' => ''),
|
||||
),
|
||||
'https' => false,
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
|
Loading…
x
Reference in New Issue
Block a user