Skip to content

Commit 7d64bc0

Browse files
committed
Fix bug
1 parent b73b899 commit 7d64bc0

File tree

5 files changed

+56
-10
lines changed

5 files changed

+56
-10
lines changed

src/lib/generators/JsonActionGenerator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ class JsonActionGenerator extends RestActionGenerator
2626
* @throws \yii\base\InvalidConfigException
2727
* @throws \cebe\openapi\exceptions\UnresolvableReferenceException
2828
*/
29-
protected function prepareAction(string $method, Operation $operation, RouteData $routeData, $customRoute = null):BaseObject
30-
{
29+
protected function prepareAction(
30+
string $method,
31+
Operation $operation,
32+
RouteData $routeData,
33+
?string $customRoute = null
34+
): BaseObject {
3135
$actionType = $this->resolveActionType($routeData, $method);
3236
$modelClass = ResponseSchema::guessModelClass($operation, $actionType);
3337
$expectedRelations = in_array($actionType, ['list', 'view'])

src/lib/generators/RestActionGenerator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ protected function resolvePath(string $path, PathItem $pathItem):array
8989
* @throws \cebe\openapi\exceptions\UnresolvableReferenceException
9090
* @throws \yii\base\InvalidConfigException
9191
*/
92-
protected function prepareAction(string $method, Operation $operation, RouteData $routeData, $customRoute = null):BaseObject
93-
{
92+
protected function prepareAction(
93+
string $method,
94+
Operation $operation,
95+
RouteData $routeData,
96+
?string $customRoute = null
97+
): BaseObject {
9498
$actionType = $this->resolveActionType($routeData, $method);
9599
$modelClass = ResponseSchema::guessModelClass($operation, $actionType);
96100
$responseWrapper = ResponseSchema::findResponseWrapper($operation, $modelClass);

src/lib/items/RouteData.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ final class RouteData extends BaseObject
166166

167167
public function __construct(PathItem $pathItem, string $path, array $urlPrefixes = [], $config = [])
168168
{
169-
// TODO url rules config php file should have path but not the x-route
170169
$this->path = $this->unprefixedPath = $path;
171170
$this->parts = explode('/', trim($path, '/'));
172171
$this->pathItem = $pathItem;

tests/specs/issue_fix/144_methods_naming_for_non_crud_actions/index.yaml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,49 @@ tags:
1111
description: Find out more
1212
url: https://developer.adiuta.com/book/payments
1313
paths:
14+
/fruit/mango:
15+
get:
16+
x-route: fruits/mango
17+
operationId: opnid9
18+
summary: Lorem ipsum
19+
description: Lorem ipsum description
20+
responses:
21+
'200':
22+
description: The Response
23+
24+
25+
/fruits/mango:
26+
get:
27+
operationId: opnid8
28+
summary: Lorem ipsum
29+
description: Lorem ipsum description
30+
responses:
31+
'200':
32+
description: The Response
33+
post:
34+
operationId: opnid9
35+
summary: Lorem ipsum
36+
description: Lorem ipsum description
37+
responses:
38+
'200':
39+
description: The Response
40+
41+
/animal/goat:
42+
get:
43+
operationId: opnid8
44+
summary: Lorem ipsum
45+
description: Lorem ipsum description
46+
responses:
47+
'200':
48+
description: The Response
49+
post:
50+
operationId: opnid9
51+
summary: Lorem ipsum
52+
description: Lorem ipsum description
53+
responses:
54+
'200':
55+
description: The Response
56+
1457
/payments/invoice/{invoice}:
1558
parameters:
1659
- name: invoice
@@ -66,8 +109,8 @@ paths:
66109
description: The Response
67110

68111
/aa2/bb2:
69-
# x-route: 'payment/xyz2'
70112
get:
113+
x-route: 'payments/xyz2'
71114
operationId: opnid7
72115
summary: List
73116
description: Lists

tests/unit/IssueFixTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,6 @@ public function test159BugGiiapiGeneratedRulesEmailid()
349349
// https://github.com/cebe/yii2-openapi/issues/158
350350
public function test158BugGiiapiGeneratedRulesEnumWithTrim()
351351
{
352-
// TODO add more test case
353-
// one new controller new action
354-
// one new action in exiting controller
355-
356352
$this->changeDbToMariadb();
357353
$testFile = Yii::getAlias("@specs/issue_fix/158_bug_giiapi_generated_rules_enum_with_trim/index.php");
358354
$this->runGenerator($testFile, 'maria');

0 commit comments

Comments
 (0)