mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Fix DunglasApi filters supports. Fix tests.
This commit is contained in:
parent
1d7b45e1e7
commit
9c465e37ca
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,13 +16,13 @@ use Nelmio\ApiDocBundle\Tests\WebTestCase;
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
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);
|
@ -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 {
|
||||
|
@ -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 = <<<MARKDOWN
|
||||
## /api/other-resources ##
|
||||
|
||||
@ -670,7 +670,7 @@ _This method is useful to test if the getDocComment works._
|
||||
- Description: The param id
|
||||
|
||||
|
||||
### `GET|HEAD` /popos ###
|
||||
### `GET` /popos ###
|
||||
|
||||
_Retrieves the collection of Popo resources._
|
||||
|
||||
@ -699,7 +699,7 @@ foo:
|
||||
* type: string
|
||||
|
||||
|
||||
### `GET|HEAD` /popos/{id} ###
|
||||
### `GET` /popos/{id} ###
|
||||
|
||||
_Retrieves Popo resource._
|
||||
|
||||
|
@ -26,7 +26,7 @@ class SimpleFormatterTest extends WebTestCase
|
||||
restore_error_handler();
|
||||
$result = $container->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 (
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user