1. Go to this page and download the library: Download johnylemon/laravel-apidocs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
johnylemon / laravel-apidocs example snippets
namespaceApp\Apidocs\Endpoints;
useJohnylemon\Apidocs\Endpoints\Endpoint;
useJohnylemon\Apidocs\Facades\Param;
classSampleEndpointextendsEndpoint{
publicfunctiondescribe(): void{
$this->title('List users')
->desc('Returns paginated list of users');
}
}
$this->uri('/users');
$this->method('POST');
$this->group('some-group-slug');
$this->deprecated();
$this->title('Create user resource');
$this->description('This endpoint contains logic for creating user resources based on provided data');
namespaceApp\Apidocs\Endpoints;
useJohnylemon\Apidocs\Endpoints\Endpoint;
useJohnylemon\Apidocs\Facades\Param;
classSampleEndpointextendsEndpoint{
publicfunctiondescribe(): void{
$this->title('List users')
->desc('Returns paginated list of users')
->query([
Param::int('page')->example(1)->default(1)->optional()
])
}
}
useJohnylemon\Apidocs\Facades\Param;
$this->query([
// parameter name will be `page`
Param::int('page')->example(1)->default(1)->optional()
// same effect:'page' => Param::int('page')->example(1)->default(1)->optional()
// same effect:'page' => Param::type('int')->example(1)->default(1)->optional()
// this parameter will be named `page_number`'page_number' => Param::int('page')->example(1)->default(1)->optional()
])
Param::type('int');
Param::name('username');
Param::description('Unique username');
Param::
Param::optional();
Param::possible([10, 100, 1000]);
Param::enum([10, 100, 1000]);
Param::default(42);
Param::example(42);
useJohnylemon\Apidocs\Facades\Param;
$this->query([
Param::string('slug'), // `slug` property, that should have `string` type
Param::int('id'), // id `property`, that should have `int` type
Param::array('roles'), // `roles` property, that should have `array` type
])