45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Docs\Strategies;
|
|
|
|
use Knuckles\Scribe\Extracting\Strategies\Strategy;
|
|
use Knuckles\Camel\Extraction\ExtractedEndpointData;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* Custom Scribe Strategy to add admin-ajax endpoints to documentation.
|
|
*
|
|
* This strategy scans the admin-ajax blade directory and adds
|
|
* each endpoint to the API documentation automatically.
|
|
*/
|
|
class AddEndpointsStrategy extends Strategy
|
|
{
|
|
/**
|
|
* The stage this strategy belongs to.
|
|
*/
|
|
public string $stage = 'responses';
|
|
|
|
/**
|
|
* Trait this strategy applies to.
|
|
*/
|
|
public static function routableIf(ExtractedEndpointData $endpoint): bool
|
|
{
|
|
// Only apply to the dynamic endpoint route
|
|
return Str::contains($endpoint->route->uri, 'endpoints/{endpoint}');
|
|
}
|
|
|
|
/**
|
|
* @param ExtractedEndpointData $endpointData
|
|
* @param array $routeRules
|
|
* @return array|null
|
|
*/
|
|
public function __invoke(ExtractedEndpointData $endpointData, array $routeRules = []): ?array
|
|
{
|
|
// This strategy doesn't modify responses directly
|
|
// The actual endpoint enumeration happens via the Artisan command
|
|
return null;
|
|
}
|
|
}
|
|
|