You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge branch 'controller-namespace-issue-for-modules-in-urlprefixes' of github.com:php-openapi/yii2-openapi into 102-fractalaction-not-generated-for-root-path
Copy file name to clipboardExpand all lines: README.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -610,8 +610,8 @@ then the value for `comments` can be
610
610
611
611
### `x-route`
612
612
613
-
To customize route (controller ID/action ID) for a path, use custom key `x-route` with value `<controller ID>/<action ID>`. It can be used for non-crud paths. It must be used under HTTP method key but not
614
-
directly under the `paths` key of OpenAPI spec. Example:
613
+
To customize [route](https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing) (controller ID/action ID) for a path, use custom key `x-route` with value `[<module ID>/<child module ID>/...]<controller ID>/<action ID>`. It can be used for non-crud paths. It must be used under HTTP method key but not
614
+
directly under the `paths` key of OpenAPI spec. Providing `<controller ID>` and `<action ID>` is required. Example:
615
615
616
616
```yaml
617
617
paths:
@@ -681,7 +681,17 @@ Generated URL rules config for above is (in `urls.rest.php` or pertinent file):
681
681
'POST a1/b1' => 'abc/xyz',
682
682
'a1/b1' => 'abc/options',
683
683
```
684
-
`x-route`does not support [Yii Modules](https://www.yiiframework.com/doc/guide/2.0/en/structure-modules).
684
+
685
+
`x-route` must not start with slash `/`. For example `x-route: /user/posts` is incorrect. It must start with [module ID](https://www.yiiframework.com/doc/guide/2.0/en/structure-modules) or [controller ID](https://www.yiiframework.com/doc/guide/2.0/en/structure-controllers#controller-ids)
686
+
687
+
#### Route, path and namespace
688
+
689
+
Route, path and namespace for controller/action will be resolved in following manner (from highest priority to lowest):
- [`controllerNamespace`](https://github.com/php-openapi/yii2-openapi/blob/649743cf0a78743f550edcbd4e93fdffc55c76fd/src/lib/Config.php#L77) of this lib
694
+
- [`controllerNamespace`](https://github.com/yiisoft/yii2/blob/16f50626e1aa81200f109c1a455a5c9b18acfdda/framework/base/Application.php#L93) of Yii app
} elseif (isset($this->prefixSettings['namespace']) && str_contains($this->prefixSettings['namespace'], '\modules\\')) { # if `module` not present then check in namespace and then in path
} elseif (isset($this->prefixSettings['namespace']) && str_contains($this->prefixSettings['namespace'], '\modules\\')) { # if `module` not present then check in namespace and then in path
0 commit comments