PHP code example of alexkramse / filament-openapi-docs

1. Go to this page and download the library: Download alexkramse/filament-openapi-docs 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/ */

    

alexkramse / filament-openapi-docs example snippets




namespace App\Providers\Filament;

use Alexkramse\FilamentOpenapiDocs\FilamentOpenApiDocsPlugin;
use Filament\Panel;
use Filament\PanelProvider;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(FilamentOpenApiDocsPlugin::make());
    }
}

use Alexkramse\FilamentOpenapiDocs\FilamentOpenApiDocsPlugin;

FilamentOpenApiDocsPlugin::make()
    ->slug('developer/api-docs')
    ->navigationLabel('OpenAPI')
    ->navigationIcon('heroicon-o-document-text')
    ->navigationGroup('Developer')
    ->navigationSort(100)
    ->navigationBadge('count')
    ->navigationBadgePrefix('')
    ->navigationBadgeSuffix(' endpoints')
    ->subNavigationPosition('right')
    ->title('API Documentation')
    ->description('Browse and test available API endpoints.')
    ->enabledInProduction()
    ->fullWidth()
    ->requestSamples()
    ->developerOptions()
    ->defaultServer('https://api.example.com')
    ->versions(['v1', 'v2']);

FilamentOpenApiDocsPlugin::make('api-v2')
    ->slug('developer/api-docs-v2')
    ->navigationLabel('OpenAPI v2')
    ->version('v2');

use Alexkramse\FilamentOpenapiDocs\Support\SpecProvider;
use Dedoc\Scramble\GeneratorConfig;

class CustomSpecProvider implements SpecProvider
{
    public function config(): GeneratorConfig
    {
        // Return the generator config used by the docs renderer.
    }

    public function view(): string
    {
        // Return the renderer view name used by the spec provider.
    }

    public function spec(): array
    {
        // Return the OpenAPI document as an array.
    }
}

'provider' => CustomSpecProvider::class,

FilamentOpenApiDocsPlugin::make()
    ->requestSamples(false);
bash
php artisan filament:assets
bash
php artisan vendor:publish --tag=filament-openapi-docs-config
bash
php artisan vendor:publish --tag=filament-openapi-docs-translations
text
lang/vendor/filament-openapi-docs/{locale}/ui.php
bash
php artisan filament:assets