Skip to content

Commit 2816f28

Browse files
committed
Add more concrete tests
1 parent 8dd401b commit 2816f28

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/lib/generators/RestActionGenerator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ protected function resolvePath(string $path, PathItem $pathItem):array
8181
// TODO rename
8282
$actionHere = $this->prepareAction($method, $operation, $routeData, $customRoute);
8383
if ($customRoute !== null) {
84-
if (in_array($customRoute, $this->allCustomRoutes)) {
84+
if (in_array($customRoute, array_keys($this->allCustomRoutes))) {
8585
$actionHere->isDuplicate = true;
86+
if ($actionHere->params !== $this->allCustomRoutes[$customRoute]) {
87+
$this->allCustomRoutes[$customRoute]->isOriginalForCustomRoute = true;
88+
}
8689
} else {
8790
$actionHere->isDuplicate = false;
88-
$this->allCustomRoutes[] = $customRoute;
91+
$this->allCustomRoutes[$customRoute] = $actionHere;
8992
}
9093
}
9194
$actions[] = $actionHere;

tests/specs/issue_fix/84_how_to_generate_controller_code_with_distinct_method_names_in_case_of_prefix_in_paths/app/config/urls.rest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
return [
88
'GET calendar/domains' => 'calendar/domains',
99
'GET calendar/domains/<id:\d+>' => 'calendar/domains',
10+
'GET calendar/domains/<id:\d+>/<id2:\d+>' => 'calendar/domains',
1011
'calendar/domains' => 'calendar/options',
1112
'calendar/domains/<id:\d+>' => 'calendar/options',
13+
'calendar/domains/<id:\d+>/<id2:\d+>' => 'calendar/options',
1214
];

tests/specs/issue_fix/84_how_to_generate_controller_code_with_distinct_method_names_in_case_of_prefix_in_paths/index.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ paths:
3737
'200':
3838
description: The Response
3939

40+
/calendar/domains/{id}/{id2}:
41+
parameters:
42+
- name: id
43+
in: path
44+
description: lorem ipsum
45+
required: true
46+
schema:
47+
type: integer
48+
- name: id2
49+
in: path
50+
description: lorem ipsum
51+
required: true
52+
schema:
53+
type: integer
54+
get:
55+
x-route: calendar/domains
56+
summary: Lorem ipsum
57+
description: Lorem ipsum description
58+
responses:
59+
'200':
60+
description: The Response
61+
4062

4163

4264
components:

0 commit comments

Comments
 (0)