PHP code example of andrii-hrechyn / auto-documentation
1. Go to this page and download the library: Download andrii-hrechyn/auto-documentation 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/ */
andrii-hrechyn / auto-documentation example snippets
Route::post('users.store')
->summary('Create user')
->fromFormRequest() // request body from validation rules, adds a 422 preset
->jsonResponse(UserSchema::make(), 201);
// docs/info.php
return AutoDoc::make()
->info(Info::make('My API', '1.0.0'))
->servers([Server::make('https://api.example.com')])
->security(SanctumAuth::make())
->defaultSecurity(SanctumAuth::make()); // applied to every ->secure() operation
// e.g. in a service provider
ValidationRuleParser::extend(PhoneNumber::class,
fn () => StringSchema::make()->pattern('^\+\d{10,15}$'));
ValidationRuleParser::extend('currency',
fn (string $rule) => StringSchema::make()->enum(explode(',', Str::after($rule, ':'))));
use AutoDocumentation\Testing\AssertsApiDoc;
$response = $this->getJson('/api/users/1');
$this->assertResponseMatchesApiDoc($response, '/api/users/{user}', 'get');