mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Merge pull request #63 from asm89/fix-grouping
Remove .{_format} from routes used for resource grouping
This commit is contained in:
commit
ed39180c6b
@ -68,7 +68,8 @@ class ApiDocExtractor
|
|||||||
if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) {
|
if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) {
|
||||||
if ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS)) {
|
if ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS)) {
|
||||||
if ($annotation->isResource()) {
|
if ($annotation->isResource()) {
|
||||||
$resources[] = $route->getPattern();
|
// remove format from routes used for resource grouping
|
||||||
|
$resources[] = str_replace('.{_format}', '', $route->getPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
$array[] = array('annotation' => $this->extractData($annotation, $route, $method));
|
$array[] = array('annotation' => $this->extractData($annotation, $route, $method));
|
||||||
|
@ -20,7 +20,7 @@ class RequestListenerTest extends WebTestCase
|
|||||||
$client = $this->createClient();
|
$client = $this->createClient();
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/tests?_doc=1');
|
$crawler = $client->request('GET', '/tests?_doc=1');
|
||||||
$this->assertEquals('/tests', trim($crawler->filter(".operation .path:contains('/tests')")->text()), 'Event listener should capture ?_doc=1 requests');
|
$this->assertEquals('/tests.{_format}', trim($crawler->filter(".operation .path:contains('/tests')")->text()), 'Event listener should capture ?_doc=1 requests');
|
||||||
|
|
||||||
$client->request('GET', '/tests');
|
$client->request('GET', '/tests');
|
||||||
$this->assertEquals('tests', $client->getResponse()->getContent(), 'Event listener should let normal requests through');
|
$this->assertEquals('tests', $client->getResponse()->getContent(), 'Event listener should let normal requests through');
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
test_route_1:
|
test_route_1:
|
||||||
pattern: /tests
|
pattern: /tests.{_format}
|
||||||
defaults: { _controller: NelmioApiDocTestBundle:Test:index, _format: json }
|
defaults: { _controller: NelmioApiDocTestBundle:Test:index, _format: json }
|
||||||
requirements:
|
requirements:
|
||||||
_method: GET
|
_method: GET
|
||||||
|
|
||||||
test_route_2:
|
test_route_2:
|
||||||
pattern: /tests
|
pattern: /tests.{_format}
|
||||||
defaults: { _controller: NelmioApiDocTestBundle:Test:postTest, _format: json }
|
defaults: { _controller: NelmioApiDocTestBundle:Test:postTest, _format: json }
|
||||||
requirements:
|
requirements:
|
||||||
_method: POST
|
_method: POST
|
||||||
@ -41,13 +41,13 @@ test_route_8:
|
|||||||
_method: GET
|
_method: GET
|
||||||
|
|
||||||
test_service_route_1:
|
test_service_route_1:
|
||||||
pattern: /tests
|
pattern: /tests.{_format}
|
||||||
defaults: { _controller: nemlio.test.controller:indexAction, _format: json }
|
defaults: { _controller: nemlio.test.controller:indexAction, _format: json }
|
||||||
requirements:
|
requirements:
|
||||||
_method: GET
|
_method: GET
|
||||||
|
|
||||||
test_service_route_2:
|
test_service_route_2:
|
||||||
pattern: /tests
|
pattern: /tests.{_format}
|
||||||
defaults: { _controller: nemlio.test.controller:postTestAction, _format: json }
|
defaults: { _controller: nemlio.test.controller:postTestAction, _format: json }
|
||||||
requirements:
|
requirements:
|
||||||
_method: POST
|
_method: POST
|
||||||
|
@ -26,10 +26,15 @@ class MarkdownFormatterTest extends WebTestCase
|
|||||||
$expected = <<<MARKDOWN
|
$expected = <<<MARKDOWN
|
||||||
# /tests #
|
# /tests #
|
||||||
|
|
||||||
### `GET` /tests ###
|
### `GET` /tests.{_format} ###
|
||||||
|
|
||||||
_index action_
|
_index action_
|
||||||
|
|
||||||
|
#### Requirements ####
|
||||||
|
|
||||||
|
**_format**
|
||||||
|
|
||||||
|
|
||||||
#### Filters ####
|
#### Filters ####
|
||||||
|
|
||||||
a:
|
a:
|
||||||
@ -42,10 +47,15 @@ b:
|
|||||||
* Arbitrary: ["arg1","arg2"]
|
* Arbitrary: ["arg1","arg2"]
|
||||||
|
|
||||||
|
|
||||||
### `GET` /tests ###
|
### `GET` /tests.{_format} ###
|
||||||
|
|
||||||
_index action_
|
_index action_
|
||||||
|
|
||||||
|
#### Requirements ####
|
||||||
|
|
||||||
|
**_format**
|
||||||
|
|
||||||
|
|
||||||
#### Filters ####
|
#### Filters ####
|
||||||
|
|
||||||
a:
|
a:
|
||||||
@ -58,10 +68,15 @@ b:
|
|||||||
* Arbitrary: ["arg1","arg2"]
|
* Arbitrary: ["arg1","arg2"]
|
||||||
|
|
||||||
|
|
||||||
### `POST` /tests ###
|
### `POST` /tests.{_format} ###
|
||||||
|
|
||||||
_create test_
|
_create test_
|
||||||
|
|
||||||
|
#### Requirements ####
|
||||||
|
|
||||||
|
**_format**
|
||||||
|
|
||||||
|
|
||||||
#### Parameters ####
|
#### Parameters ####
|
||||||
|
|
||||||
a:
|
a:
|
||||||
@ -81,10 +96,15 @@ c:
|
|||||||
* required: true
|
* required: true
|
||||||
|
|
||||||
|
|
||||||
### `POST` /tests ###
|
### `POST` /tests.{_format} ###
|
||||||
|
|
||||||
_create test_
|
_create test_
|
||||||
|
|
||||||
|
#### Requirements ####
|
||||||
|
|
||||||
|
**_format**
|
||||||
|
|
||||||
|
|
||||||
#### Parameters ####
|
#### Parameters ####
|
||||||
|
|
||||||
a:
|
a:
|
||||||
@ -183,10 +203,15 @@ MARKDOWN;
|
|||||||
$result = $container->get('nelmio_api_doc.formatter.markdown_formatter')->formatOne($annotation);
|
$result = $container->get('nelmio_api_doc.formatter.markdown_formatter')->formatOne($annotation);
|
||||||
|
|
||||||
$expected = <<<MARKDOWN
|
$expected = <<<MARKDOWN
|
||||||
### `GET` /tests ###
|
### `GET` /tests.{_format} ###
|
||||||
|
|
||||||
_index action_
|
_index action_
|
||||||
|
|
||||||
|
#### Requirements ####
|
||||||
|
|
||||||
|
**_format**
|
||||||
|
|
||||||
|
|
||||||
#### Filters ####
|
#### Filters ####
|
||||||
|
|
||||||
a:
|
a:
|
||||||
|
@ -29,7 +29,7 @@ class SimpleFormatterTest extends WebTestCase
|
|||||||
0 =>
|
0 =>
|
||||||
array(
|
array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/tests',
|
'uri' => '/tests.{_format}',
|
||||||
'filters' =>
|
'filters' =>
|
||||||
array(
|
array(
|
||||||
'a' =>
|
'a' =>
|
||||||
@ -47,11 +47,14 @@ class SimpleFormatterTest extends WebTestCase
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
'description' => 'index action',
|
'description' => 'index action',
|
||||||
|
'requirements' => array(
|
||||||
|
'_format' => array('type' => '', 'description' => '', 'requirement' => ''),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
1 =>
|
1 =>
|
||||||
array(
|
array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/tests',
|
'uri' => '/tests.{_format}',
|
||||||
'filters' =>
|
'filters' =>
|
||||||
array(
|
array(
|
||||||
'a' =>
|
'a' =>
|
||||||
@ -69,11 +72,14 @@ class SimpleFormatterTest extends WebTestCase
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
'description' => 'index action',
|
'description' => 'index action',
|
||||||
|
'requirements' => array(
|
||||||
|
'_format' => array('type' => '', 'description' => '', 'requirement' => ''),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
2 =>
|
2 =>
|
||||||
array(
|
array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'uri' => '/tests',
|
'uri' => '/tests.{_format}',
|
||||||
'parameters' =>
|
'parameters' =>
|
||||||
array(
|
array(
|
||||||
'a' =>
|
'a' =>
|
||||||
@ -99,11 +105,14 @@ class SimpleFormatterTest extends WebTestCase
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
'description' => 'create test',
|
'description' => 'create test',
|
||||||
|
'requirements' => array(
|
||||||
|
'_format' => array('type' => '', 'description' => '', 'requirement' => ''),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
3 =>
|
3 =>
|
||||||
array(
|
array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'uri' => '/tests',
|
'uri' => '/tests.{_format}',
|
||||||
'parameters' =>
|
'parameters' =>
|
||||||
array(
|
array(
|
||||||
'a' =>
|
'a' =>
|
||||||
@ -129,6 +138,9 @@ class SimpleFormatterTest extends WebTestCase
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
'description' => 'create test',
|
'description' => 'create test',
|
||||||
|
'requirements' => array(
|
||||||
|
'_format' => array('type' => '', 'description' => '', 'requirement' => ''),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'others' =>
|
'others' =>
|
||||||
@ -211,7 +223,7 @@ class SimpleFormatterTest extends WebTestCase
|
|||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/tests',
|
'uri' => '/tests.{_format}',
|
||||||
'filters' => array(
|
'filters' => array(
|
||||||
'a' => array(
|
'a' => array(
|
||||||
'dataType' => 'integer',
|
'dataType' => 'integer',
|
||||||
@ -224,7 +236,10 @@ class SimpleFormatterTest extends WebTestCase
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'description' => 'index action'
|
'description' => 'index action',
|
||||||
|
'requirements' => array(
|
||||||
|
'_format' => array('type' => '', 'description' => '', 'requirement' => ''),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user