@@ -57,22 +57,7 @@ passing PHPUnit tests.
5757
5858### Basic usage
5959
60- 1. Create test for API endpoint:
61-
62- ```php
63- public function testUpdate()
64- {
65- $response = $this->json('put', '/users/1', [
66- 'name': 'Updated User',
67- 'is_active': true,
68- 'age': 22
69- ]);
70-
71- $response->assertStatus(Response::HTTP_NO_CONTENT);
72- }
73- ```
74-
75- 2. Create request class:
60+ 1. Create request class:
7661
7762 ```php
7863 <?php
@@ -119,7 +104,6 @@ passing PHPUnit tests.
119104 }
120105
121106 ```
122-
123107 > ***Note***
124108 >
125109 > For correct working of plugin you'll have to dispose all the validation rules
@@ -128,9 +112,49 @@ passing PHPUnit tests.
128112 > Plugin will take validation rules from the request class and generate fields description
129113 > of input parameter.
130114
131- 3. Run tests
132- 4. Go to route defined in the `auto-doc.route` config
133- 5. Profit!
115+ 2. Create a controller and a method for your route:
116+
117+ ```php
118+ <?php
119+
120+ namespace App\Http\Controllers;
121+
122+ use App\Http\Requests\Users\UpdateUserDataRequest;
123+
124+ class UserController extends Controller
125+ {
126+ public function update(UpdateUserDataRequest $request, UserService $service, $id)
127+ {
128+ // do something here...
129+
130+ return response('', Response::HTTP_NO_CONTENT);
131+ }
132+ }
133+ ```
134+
135+ > ***Note***
136+ >
137+ > Dependency injection of request class is optional but if it not presents,
138+ > the "Parameters" block in the API documentation will be empty.
139+
140+ 3. Create test for API endpoint:
141+
142+ ```php
143+ public function testUpdate()
144+ {
145+ $response = $this->json('put', '/users/1', [
146+ 'name': 'Updated User',
147+ 'is_active': true,
148+ 'age': 22
149+ ]);
150+
151+ $response->assertStatus(Response::HTTP_NO_CONTENT);
152+ }
153+ ```
154+
155+ 4. Run tests
156+ 5. Go to route defined in the `auto-doc.route` config
157+ 6. Profit!
134158
135159 
136160
0 commit comments