Skip to content

Commit fe97ab4

Browse files
committed
Implement for FractalAction - WIP
1 parent db9a018 commit fe97ab4

File tree

4 files changed

+83
-3
lines changed

4 files changed

+83
-3
lines changed

src/lib/generators/ControllersGenerator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function __construct(Config $config, array $actions = [])
3838
{
3939
$this->config = $config;
4040
foreach ($actions as $action) {
41-
$this->controllers[$action->prefix . '/' . $action->controllerId][] = $action;
41+
$r = $action->getRoute();
42+
$r = explode('/', $r);
43+
array_pop($r);
44+
array_pop($r);
45+
$this->controllers[implode('/', $r) . '/' . $action->controllerId][] = $action;
4246
}
4347
$this->files = new CodeFiles([]);
4448
}

tests/specs/issue_fix/14_nested_module_in_x_route/index.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
'generateControllers' => true,
1212
'generateMigrations' => false,
1313
'generateModelFaker' => false,
14+
// 'urlPrefixes' => [
15+
// 'hi' => ['module' => 'greet', 'namespace' => 'app\greet'],
16+
// 'abc' => ['module' => 'abc', 'namespace' => 'app\abc'],
17+
// ]
1418
];

tests/specs/issue_fix/14_nested_module_in_x_route/index.yml

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,76 @@ paths:
1111
operationId: list
1212
responses:
1313
'200':
14-
description: The information
14+
$ref: '#/components/responses/Task'
15+
16+
'/task/{id}':
17+
parameters:
18+
- name: id
19+
in: path
20+
description: ID of the task.
21+
required: true
22+
schema:
23+
type: integer
24+
get:
25+
x-route: fruit2/mango/alphonso/view
26+
operationId: getTask
27+
summary: Get a Task by ID
28+
description: Returns a single task by its unique ID.
29+
responses:
30+
'200':
31+
$ref: '#/components/responses/Task'
32+
'403':
33+
description: Response if the currently authenticated user has no access to this task.
34+
'404':
35+
description: Response if the task does not exist.
36+
tags:
37+
- Tasks
38+
39+
components:
40+
schemas:
41+
_TaskResource:
42+
type: object
43+
properties:
44+
id:
45+
type: integer
46+
example: 1
47+
type:
48+
type: string
49+
enum:
50+
- tasks
51+
attributes:
52+
$ref: '#/components/schemas/Task'
53+
relationships:
54+
type: object
55+
JSONAPI_links:
56+
type: object
57+
example:
58+
self: 'https://api.example.com/...'
59+
additionalProperties:
60+
oneOf:
61+
- type: string
62+
- type: object
63+
properties:
64+
href:
65+
type: string
66+
meta:
67+
type: object
68+
Task:
69+
type: object
70+
properties:
71+
id:
72+
type: integer
73+
title:
74+
type: string
75+
responses:
76+
Task:
77+
description: Task
78+
content:
79+
application/vnd.api+json:
80+
schema:
81+
type: object
82+
properties:
83+
data:
84+
$ref: '#/components/schemas/_TaskResource'
85+
links:
86+
$ref: '#/components/schemas/JSONAPI_links'

tests/unit/issues/Issue14Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# https://github.com/php-openapi/yii2-openapi/issues/14
1010
class Issue14Test extends DbTestCase
1111
{
12-
public function testNestedModuleInXRoute()
12+
public function testNestedModuleInXRoute() # RestAction
1313
{
1414
$testFile = Yii::getAlias("@specs/issue_fix/14_nested_module_in_x_route/index.php");
1515
$this->runGenerator($testFile);

0 commit comments

Comments
 (0)