Merge pull request #153 from pylebecq/fix-markdown-formatter

[Formatter] Fixed MarkdownFormatter.
This commit is contained in:
William Durand 2013-03-22 17:12:31 -07:00
commit a9087994da
6 changed files with 54 additions and 4 deletions

View File

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

View File

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

View File

@ -91,3 +91,9 @@ test_service_route_4:
NelmioApiDocBundle: NelmioApiDocBundle:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml" resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
prefix: / 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 * required: true
## /tests2 ##
### `POST` /tests2.{_format} ###
_post test 2_
#### Requirements ####
**_format**
### `POST` /another-post ### ### `POST` /another-post ###
_create another test_ _create another test_

View File

@ -477,6 +477,26 @@ And, it supports multilines until the first \'@\' char.',
'authentication' => false, '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); $this->assertEquals($expected, $result);