1. Go to this page and download the library: Download radebatz/openapi-extras 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/ */
radebatz / openapi-extras example snippets
use Radebatz\OpenApi\Extras\OpenApiBuilder;
$generator = (new OpenApiBuilder())->build();
// ...
use OpenApi\Generator;
use OpenApi\Processors\BuildPaths;
use Radebatz\OpenApi\Extras\Processors\MergeControllerDefaults;
$generator = new Generator();
$generator->getProcessorPipeline()
->insert(new MergeControllerDefaults(), BuildPaths::class);
// ...
use OpenApi\Generator;
use OpenApi\Processors\BuildPaths;
use Radebatz\OpenApi\Extras\Processors\MergeControllerDefaults;
$namespace = 'Radebatz\\OpenApi\\Extras\\Annotations';
$generator = new Generator();
$generator
->addNamespace($namespace . '\\')
->addAlias('oax', $namespace),
->getProcessorPipeline()
->insert(new MergeControllerDefaults(), BuildPaths::class);
// ...
declare(strict_types=1);
use OpenApi\Annotations as OA;
use Psr\Log\NullLogger;
use Radebatz\OpenApi\Extras\OpenApiBuilder;
$generator = (new OpenApiBuilder())
->addCustomizer(OA\Info::class, fn (OA\Info $info) => $info->description = 'Foo')
->tagsToMatch(['admin'])
->clearUnused(enabled: true)
->operationIdHashing(enabled: false)
->pathsToMatch(['/api'])
->enumDescription()
->build(new NullLogger());
declare(strict_types=1);
use OpenApi\Attributes as OAT;
use Radebatz\OpenApi\Extras\Attributes as OAX;
#[OAX\Controller(prefix: '/foo')]
#[OAT\Response(response: 403, description: 'Not allowed')]
class PrefixedController
{
#[OAT\Get(path: '/prefixed', operationId: 'prefixed')]
#[OAT\Response(response: 200, description: 'All good')]
public function prefixed(): mixed
{
return 'prefixed';
}
}
declare(strict_types=1);
namespace Radebatz\OpenApi\Extras\Tests\Fixtures\Controllers\Attributes;
use OpenApi\Attributes as OAT;
use Radebatz\OpenApi\Extras\Attributes as OAX;
#[OAX\Controller()]
#[OAX\Middleware([MyFooMiddleware::class])]
class MiddlewareController
{
#[OAT\Get(path: '/mw', operationId: 'mw')]
#[OAT\Response(response: 200, description: 'All good')]
#[OAX\Middleware(['BarMiddleware'])]
public function mw()
{
return 'mw';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.