Skip to content

Commit 11ed656

Browse files
committed
Add readme for tests and controllers
1 parent 1be86de commit 11ed656

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

README.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ You can also adjust file templates according to your needs.
3333

3434
## Existing entities and generators
3535

36-
### 'enums' => EnumsGenerator::class
37-
38-
Generates Enum class only for enums listed in `oas3->components->schemas`.
39-
Your need to specify `x-enum-varnames` field in each enum schema. The values are used as enum constants' names.
40-
Destination directory is cleared before generation to make sure all unused enum classes are deleted.
41-
Enums generator does NOT support `allOf`, `anyOf` and `oneOf` at the moment.
42-
4336
### 'routes' => RoutesGenerator::class
4437

4538
Generates laravel route file (`route.php`) for each endpoint in `oas3->paths`
@@ -61,6 +54,14 @@ if (file_exists($generatedRoutes)) { // prevents your app and artisan from break
6154
}
6255
```
6356

57+
### 'controllers' => ControllersGenerator::class
58+
59+
Generates Controller class for each non-existing class specified in `x-lg-handler`
60+
Supports invocable Controllers.
61+
If several openapi paths point to several methods in one Controller/Handler then the genereted class includes all of them.
62+
If a class already exists it is NOT overriden.
63+
Controller class IS meant to be modified after generation.
64+
6465
### 'requests' => RequestsGenerator::class
6566

6667
Generates Laravel Form Requests for DELETE, PATCH, POST, PUT paths
@@ -69,14 +70,27 @@ E.g
6970

7071
```php
7172
'requests' => ["Controllers" => "Requests"],
72-
```
73+
```
74+
75+
This means "Get handler (x-lg-handler) namespace and replace Controllers with Requests in it"
76+
Form Request class IS meant to be modified after generation. You can treat it as a template generated with `php artisan make:request FooRequest`
77+
If the file already exists it IS NOT overriden with each generation.
78+
79+
Form Request class name is `ucFirst(operationId)`. You can override it with `x-lg-request-class-name`
80+
You can skip generating form request for a give route with `x-lg-skip-request-generation: true` directive.
81+
82+
### 'enums' => EnumsGenerator::class
83+
84+
Generates Enum class only for enums listed in `oas3->components->schemas`.
85+
Your need to specify `x-enum-varnames` field in each enum schema. The values are used as enum constants' names.
86+
Destination directory is cleared before generation to make sure all unused enum classes are deleted.
87+
Enums generator does NOT support `allOf`, `anyOf` and `oneOf` at the moment.
7388

74-
This means "Get handler (x-lg-handler) namespace and replace Controllers with Requests in it"
75-
Form Request class IS meant to be modified after generation. You can treat it as a template generated with `php artisan make:request FooRequest`
76-
If the file already exists it IS NOT overriden with each generation.
89+
### 'pest_tests' => PestTestsGenerator::class
7790

78-
Form Request class name is `ucFirst(operationId)`. You can override it with `x-lg-request-class-name`
79-
You can skip generating form request for a give route with `x-lg-skip-request-generation: true` directive.
91+
Generates Pest test file for each `x-lg-handler`
92+
If a test file already exists it is NOT overriden.
93+
Controller class IS meant to be modified after generation.
8094

8195
## Contributing
8296

0 commit comments

Comments
 (0)