diff --git a/Tests/Extractor/ApiDocExtratorTest.php b/Tests/Extractor/ApiDocExtratorTest.php index 8e912ab..8990184 100644 --- a/Tests/Extractor/ApiDocExtratorTest.php +++ b/Tests/Extractor/ApiDocExtratorTest.php @@ -22,7 +22,7 @@ class ApiDocExtractorTest extends WebTestCase $data = $extractor->all(); $this->assertTrue(is_array($data)); - $this->assertCount(8, $data); + $this->assertCount(9, $data); foreach ($data as $d) { $this->assertTrue(is_array($d)); diff --git a/Tests/Fixtures/Controller/TestController.php b/Tests/Fixtures/Controller/TestController.php index def145b..57907eb 100644 --- a/Tests/Fixtures/Controller/TestController.php +++ b/Tests/Fixtures/Controller/TestController.php @@ -71,4 +71,14 @@ class TestController public function yetAnotherAction() { } + + /** + * @ApiDoc( + * description="create another test", + * formType="dependency_type" + * ) + */ + public function anotherPostAction() + { + } } diff --git a/Tests/Fixtures/Form/DependencyType.php b/Tests/Fixtures/Form/DependencyType.php new file mode 100644 index 0000000..9f7731b --- /dev/null +++ b/Tests/Fixtures/Form/DependencyType.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Nelmio\ApiDocBundle\Tests\Fixtures\Form; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + +class DependencyType extends AbstractType +{ + public function __construct(array $mandatoryArgument) + { + } + + /** + * {@inheritdoc} + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('a', null, array('description' => 'A nice description')) + ; + } + + /** + * {@inheritdoc} + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Nelmio\ApiDocBundle\Tests\Fixtures\Model\Test', + )); + + return; + } + + public function getName() + { + return 'dependency_type'; + } +} diff --git a/Tests/Fixtures/app/config/default.yml b/Tests/Fixtures/app/config/default.yml index 6b4401c..d159f8d 100644 --- a/Tests/Fixtures/app/config/default.yml +++ b/Tests/Fixtures/app/config/default.yml @@ -22,3 +22,9 @@ twig: services: nemlio.test.controller: class: Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestServiceController + nelmio.test.type: + class: Nelmio\ApiDocBundle\Tests\Fixtures\Form\DependencyType + arguments: + - [foo, bar] + tags: + - { name: form.type, alias: dependency_type } diff --git a/Tests/Fixtures/app/config/routing.yml b/Tests/Fixtures/app/config/routing.yml index 7e7b090..6e04d20 100644 --- a/Tests/Fixtures/app/config/routing.yml +++ b/Tests/Fixtures/app/config/routing.yml @@ -28,6 +28,12 @@ test_route_6: requirements: id: \d+ +test_route_7: + pattern: /another-post + defaults: { _controller: NelmioApiDocTestBundle:Test:anotherPost, _format: json } + requirements: + _method: POST + test_service_route_1: pattern: /tests defaults: { _controller: nemlio.test.controller:indexAction, _format: json } diff --git a/Tests/Formatter/MarkdownFormatterTest.php b/Tests/Formatter/MarkdownFormatterTest.php index ddb986d..11223b5 100644 --- a/Tests/Formatter/MarkdownFormatterTest.php +++ b/Tests/Formatter/MarkdownFormatterTest.php @@ -107,6 +107,19 @@ b: # others # +### `POST` /another-post ### + +_create another test_ + +#### Parameters #### + +a: + + * type: string + * required: true + * description: A nice description + + ### `ANY` /any ### _Action without HTTP verb_ diff --git a/Tests/Formatter/SimpleFormatterTest.php b/Tests/Formatter/SimpleFormatterTest.php index 216e899..1b6e975 100644 --- a/Tests/Formatter/SimpleFormatterTest.php +++ b/Tests/Formatter/SimpleFormatterTest.php @@ -140,6 +140,24 @@ class SimpleFormatterTest extends WebTestCase 'others' => array( 0 => + array( + 'method' => 'POST', + 'uri' => '/another-post', + 'requirements' => + array( + ), + 'parameters' => + array( + 'a' => + array( + 'dataType' => 'string', + 'required' => true, + 'description' => 'A nice description', + ), + ), + 'description' => 'create another test', + ), + 1 => array( 'method' => 'ANY', 'uri' => '/any', @@ -148,7 +166,7 @@ class SimpleFormatterTest extends WebTestCase ), 'description' => 'Action without HTTP verb', ), - 1 => + 2 => array( 'method' => 'ANY', 'uri' => '/any/{foo}', @@ -158,7 +176,7 @@ class SimpleFormatterTest extends WebTestCase ), 'description' => 'Action without HTTP verb', ), - 2 => + 3 => array( 'method' => 'ANY', 'uri' => '/my-commented/{id}/{page}', @@ -169,7 +187,7 @@ class SimpleFormatterTest extends WebTestCase ), 'description' => 'This method is useful to test if the getDocComment works. And, it supports multilines until the first \'@\' char.', ), - 3 => + 4 => array( 'method' => 'ANY', 'uri' => '/yet-another/{id}',