Exporting specification
You can export the resulting documentation (OpenAPI 3.1.0) using the scramble:export command:
php artisan scramble:exportThis will create an api.json file containing the specification of the default API in the application’s root folder. You can customize the file path and name by providing the --path option. For example, to save the file in public/api.json:
php artisan scramble:export --path=public/api.jsonIf you have registered an API other than default, you can specify the API using the --api option:
php artisan scramble:export --api=v2Using the exported specification for docs UI
By default, Scramble generates the specification file every time you access the documentation.
You can opt out of this behavior by creating your own documentation UI route and passing the exported specification file to it.
use Dedoc\Scramble\Scramble;use Dedoc\Scramble\Http\Middleware\RestrictedDocsAccess;
Route::get('/documentation-api', function () { return view('scramble::docs', [ 'spec' => file_get_contents(base_path('api.json')), 'config' => Scramble::getGeneratorConfig('default'), ]);})->middleware(Scramble::getGeneratorConfig('default')->get('middleware', [RestrictedDocsAccess::class]));If the file exists, this will render the documentation using the specification from that file. If the file does not exist, an error will be thrown.