1. Go to this page and download the library: Download ronasit/laravel-swagger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
/**
* @summary Update user
*
* @deprecated
*
* @description
* This request should be used for updating the user data
*
* @_204 Successful
*
* @is_active will indicate whether the user is active or not
*/
class UpdateUserDataRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Validation Rules
*
* @return array
*/
public function rules()
{
return [
'name' => 'string',
'is_active' => 'boolean',
'age' => 'integer|nullable'
];
}
}
namespace App\Http\Controllers;
use App\Http\Requests\Users\UpdateUserDataRequest;
class UserController extends Controller
{
public function update(UpdateUserDataRequest $request, UserService $service, $id)
{
// do something here...
return response('', Response::HTTP_NO_CONTENT);
}
}
public function testUpdate()
{
$response = $this->json('put', '/users/1', [
'name': 'Updated User',
'is_active': true,
'age': 22
]);
$response->assertStatus(Response::HTTP_NO_CONTENT);
}