mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Implement Tags for functions.
This commit is contained in:
parent
dfb089f993
commit
dfd094371d
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -25,6 +25,11 @@
|
||||
{% endif -%}
|
||||
{{ data.uri }}
|
||||
</span>
|
||||
{% if data.tags is defined %}
|
||||
{% for tag in data.tags %}
|
||||
<span class="tag">{{ tag }}</span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</h3>
|
||||
<ul class="options">
|
||||
{% if data.description is defined %}
|
||||
|
@ -288,4 +288,35 @@ class ApiDocTest extends TestCase
|
||||
$this->assertTrue(isset($array['parameters']['fooId']));
|
||||
$this->assertTrue(isset($array['parameters']['fooId']['dataType']));
|
||||
}
|
||||
|
||||
public function testConstructWithOneTag()
|
||||
{
|
||||
$data = array(
|
||||
'tags' => 'beta'
|
||||
);
|
||||
|
||||
$annot = new ApiDoc($data);
|
||||
$array = $annot->toArray();
|
||||
|
||||
$this->assertTrue(is_array($array));
|
||||
$this->assertTrue(is_array($array['tags']), 'Single tag should be put in array');
|
||||
$this->assertEquals(array('beta'), $array['tags']);
|
||||
}
|
||||
|
||||
public function testConstructWithMultipleTags()
|
||||
{
|
||||
$data = array(
|
||||
'tags' => array(
|
||||
'experimental',
|
||||
'alpha'
|
||||
)
|
||||
);
|
||||
|
||||
$annot = new ApiDoc($data);
|
||||
$array = $annot->toArray();
|
||||
|
||||
$this->assertTrue(is_array($array));
|
||||
$this->assertTrue(is_array($array['tags']), 'Tags should be in array');
|
||||
$this->assertEquals($data['tags'], $array['tags']);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user