PHP code example of spatie / laravel-openapi-cli
1. Go to this page and download the library: Download spatie/laravel-openapi-cli 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/ */
spatie / laravel-openapi-cli example snippets
use Spatie\OpenApiCli\Facades\OpenApiCli;
OpenApiCli::register('https://api.bookstore.io/openapi.yaml', 'bookstore')
->baseUrl('https://api.bookstore.io')
->auth(fn () => app(OAuthTokenManager::class)->token())
->banner('Bookstore API v2')
->cache(ttl: 600)
->followRedirects()
->yamlOutput()
->showHtmlBody()
->useOperationIds()
->onError(function (Response $response, Command $command) {
return match ($response->status()) {
429 => $command->warn('Rate limited. Retry after '.$response->header('Retry-After').'s.'),
default => false,
};
})
->retryOn(function (Response $response, Command $command) {
if ($response->status() !== 401) {
return false;
}
return app(OAuthTokenManager::class)->refresh();
}, maxRetries: 1);