[Formatter] Fixed MarkdownFormatter.

This commit is contained in:
Pierre-Yves LEBECQ 2013-03-21 12:15:44 +01:00
parent 5daf8ac5f6
commit 67db76990e
6 changed files with 54 additions and 4 deletions

View File

@ -123,13 +123,15 @@ class MarkdownFormatter extends AbstractFormatter
{
if ('_others' !== $section) {
$markdown = sprintf("# %s #\n\n", $section);
} else {
$markdown = '';
}
foreach ($resources as $resource => $methods) {
if ('_others' === $section && 'others' !== $resource) {
$markdown = sprintf("## %s ##\n\n", $resource);
$markdown .= sprintf("## %s ##\n\n", $resource);
} elseif ('others' !== $resource) {
$markdown = sprintf("## %s ##\n\n", $resource);
$markdown .= sprintf("## %s ##\n\n", $resource);
}
foreach ($methods as $method) {

View File

@ -24,7 +24,7 @@ class ApiDocExtractorTest extends WebTestCase
restore_error_handler();
$this->assertTrue(is_array($data));
$this->assertCount(15, $data);
$this->assertCount(16, $data);
foreach ($data as $d) {
$this->assertTrue(is_array($d));
@ -64,7 +64,7 @@ class ApiDocExtractorTest extends WebTestCase
$this->assertFalse(isset($array2['filters']));
$this->assertEquals('Nelmio\ApiDocBundle\Tests\Fixtures\Form\TestType', $a2->getInput());
$a3 = $data['11']['annotation'];
$a3 = $data['12']['annotation'];
$this->assertTrue($a3->getHttps());
}

View File

@ -43,6 +43,16 @@ class TestController
{
}
/**
* @ApiDoc(
* description="post test 2",
* resource=true
* )
*/
public function postTest2Action()
{
}
public function anotherAction()
{
}

View File

@ -91,3 +91,9 @@ test_service_route_4:
NelmioApiDocBundle:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
prefix: /
test_route_14:
pattern: /tests2.{_format}
defaults: { _controller: NelmioApiDocTestBundle:Test:postTest2, _format: json }
requirements:
_method: POST

View File

@ -126,6 +126,18 @@ c:
* required: true
## /tests2 ##
### `POST` /tests2.{_format} ###
_post test 2_
#### Requirements ####
**_format**
### `POST` /another-post ###
_create another test_

View File

@ -477,6 +477,26 @@ And, it supports multilines until the first \'@\' char.',
'authentication' => false,
),
),
'/tests2' =>
array (
0 =>
array (
'method' => 'POST',
'uri' => '/tests2.{_format}',
'description' => 'post test 2',
'requirements' =>
array (
'_format' =>
array (
'requirement' => '',
'dataType' => '',
'description' => '',
),
),
'https' => false,
'authentication' => false,
),
),
);
$this->assertEquals($expected, $result);