diff --git a/Extractor/AnnotationsProvider/DunglasApiProvider.php b/Extractor/AnnotationsProvider/DunglasApiProvider.php index c5d2d87..43a5990 100644 --- a/Extractor/AnnotationsProvider/DunglasApiProvider.php +++ b/Extractor/AnnotationsProvider/DunglasApiProvider.php @@ -127,7 +127,9 @@ class DunglasApiProvider implements AnnotationsProviderInterface $data['filters'] = []; foreach ($resource->getFilters() as $filter) { - $data['filters'][] = ['name' => $filter->getName()]; + foreach ($filter->getDescription($resource) as $name => $data) { + $data['filters'][] = ['name' => $name] + $data; + } } $apiDoc = new ApiDoc($data); diff --git a/Parser/DunglasApiParser.php b/Parser/DunglasApiParser.php index 640fbdd..3a0f51a 100644 --- a/Parser/DunglasApiParser.php +++ b/Parser/DunglasApiParser.php @@ -58,9 +58,12 @@ class DunglasApiParser implements ParserInterface */ public function supports(array $item) { - list(, $class) = explode(':', $item['class'], 2); + $data = explode(':', $item['class'], 2); + if (isset($data[1])) { + return null !== $this->resourceCollection->getResourceForEntity($data[1]); + } - return null !== $this->resourceCollection->getResourceForEntity($class); + return false; } /** diff --git a/Tests/Extractor/AnnotationsProvider/DunglasJsonLdApiProviderTest.php b/Tests/Extractor/AnnotationsProvider/DunglasApiProviderTest.php similarity index 81% rename from Tests/Extractor/AnnotationsProvider/DunglasJsonLdApiProviderTest.php rename to Tests/Extractor/AnnotationsProvider/DunglasApiProviderTest.php index dad2127..d28a586 100644 --- a/Tests/Extractor/AnnotationsProvider/DunglasJsonLdApiProviderTest.php +++ b/Tests/Extractor/AnnotationsProvider/DunglasApiProviderTest.php @@ -16,13 +16,13 @@ use Nelmio\ApiDocBundle\Tests\WebTestCase; /** * @author Kévin Dunglas */ -class DunglasJsonLdApiProviderTest extends WebTestCase +class DunglasApiProviderTest extends WebTestCase { protected function setUp() { - if (!class_exists('Dunglas\JsonLdApiBundle\DunglasJsonLdApiBundle')) { + if (!class_exists('Dunglas\ApiBundle\DunglasApiBundle')) { $this->markTestSkipped( - 'DunglasJsonLdApiBundle is not available.' + 'DunglasApiBundle is not available.' ); } } @@ -30,7 +30,7 @@ class DunglasJsonLdApiProviderTest extends WebTestCase public function testGetAnnotations() { $container = $this->getContainer(); - $provider = $container->get('nelmio_api_doc.annotations_provider.dunglas_json_ld_api_annotation_provider'); + $provider = $container->get('nelmio_api_doc.annotations_provider.dunglas_api_annotation_provider'); $annotations = $provider->getAnnotations(); $this->assertCount(5, $annotations); diff --git a/Tests/Extractor/ApiDocExtractorTest.php b/Tests/Extractor/ApiDocExtractorTest.php index b12a0d2..bc23e26 100644 --- a/Tests/Extractor/ApiDocExtractorTest.php +++ b/Tests/Extractor/ApiDocExtractorTest.php @@ -25,7 +25,7 @@ class ApiDocExtractorTest extends WebTestCase $data = $extractor->all(); restore_error_handler(); - if(class_exists('Dunglas\JsonLdApiBundle\DunglasJsonLdApiBundle')) { + if(class_exists('Dunglas\ApiBundle\DunglasApiBundle')) { $routesQuantity = 38; $httpsKey = 25; } else { diff --git a/Tests/Formatter/MarkdownFormatterTest.php b/Tests/Formatter/MarkdownFormatterTest.php index 28d9564..cbb12e2 100644 --- a/Tests/Formatter/MarkdownFormatterTest.php +++ b/Tests/Formatter/MarkdownFormatterTest.php @@ -25,7 +25,7 @@ class MarkdownFormatterTest extends WebTestCase restore_error_handler(); $result = $container->get('nelmio_api_doc.formatter.markdown_formatter')->format($data); - if(class_exists('Dunglas\JsonLdApiBundle\DunglasJsonLdApiBundle')) { + if(class_exists('Dunglas\ApiBundle\DunglasApiBundle')) { $expected = <<get('nelmio_api_doc.formatter.simple_formatter')->format($data); - if (class_exists('Dunglas\JsonLdApiBundle\DunglasJsonLdApiBundle')) { + if (class_exists('Dunglas\ApiBundle\DunglasApiBundle')) { $expected = array ( '/api/other-resources' => array ( @@ -1581,7 +1581,7 @@ And, it supports multilines until the first \'@\' char.', ), 7 => array ( - 'method' => 'GET|HEAD', + 'method' => 'GET', 'uri' => '/popos', 'description' => 'Retrieves the collection of Popo resources.', 'documentation' => 'Gets the collection.', @@ -1601,6 +1601,7 @@ And, it supports multilines until the first \'@\' char.', array ( ), 'deprecated' => false, + 'resourceDescription' => 'Popo', ), 8 => array ( @@ -1634,10 +1635,11 @@ And, it supports multilines until the first \'@\' char.', array ( ), 'deprecated' => false, + 'resourceDescription' => 'Popo', ), 9 => array ( - 'method' => 'GET|HEAD', + 'method' => 'GET', 'uri' => '/popos/{id}', 'description' => 'Retrieves Popo resource.', 'documentation' => 'Gets an element of the collection.', @@ -1666,6 +1668,7 @@ And, it supports multilines until the first \'@\' char.', array ( ), 'deprecated' => false, + 'resourceDescription' => 'Popo', ), 10 => array ( @@ -1708,6 +1711,7 @@ And, it supports multilines until the first \'@\' char.', array ( ), 'deprecated' => false, + 'resourceDescription' => 'Popo', ), 11 => array ( @@ -1730,6 +1734,7 @@ And, it supports multilines until the first \'@\' char.', array ( ), 'deprecated' => false, + 'resourceDescription' => 'Popo', ), 12 => array ( diff --git a/Tests/Formatter/SwaggerFormatterTest.php b/Tests/Formatter/SwaggerFormatterTest.php index 18c793f..1a8f935 100644 --- a/Tests/Formatter/SwaggerFormatterTest.php +++ b/Tests/Formatter/SwaggerFormatterTest.php @@ -45,7 +45,7 @@ class SwaggerFormatterTest extends WebTestCase $actual = $this->formatter->format($data, null); - if (class_exists('Dunglas\JsonLdApiBundle\DunglasJsonLdApiBundle')) { + if (class_exists('Dunglas\ApiBundle\DunglasApiBundle')) { $expected = array ( 'swaggerVersion' => '1.2', 'apis' => @@ -83,27 +83,27 @@ class SwaggerFormatterTest extends WebTestCase 6 => array ( 'path' => '/others', - 'description' => '', + 'description' => 'Popo', ), 7 => array ( 'path' => '/others', - 'description' => '', + 'description' => 'Popo', ), 8 => array ( 'path' => '/others', - 'description' => '', + 'description' => 'Popo', ), 9 => array ( 'path' => '/others', - 'description' => '', + 'description' => 'Popo', ), 10 => array ( 'path' => '/others', - 'description' => '', + 'description' => 'Popo', ), ), 'apiVersion' => '3.14',