0 follower

Final Class Yiisoft\Yii\Swagger\Action\SwaggerJson

InheritanceYiisoft\Yii\Swagger\Action\SwaggerJson
ImplementsPsr\Http\Server\RequestHandlerInterface

Method Details

Hide inherited methods

__construct() public method

public __construct( \Yiisoft\Cache\CacheInterface $cache, \Yiisoft\DataResponse\DataResponseFactoryInterface $responseFactory, Yiisoft\Yii\Swagger\Service\SwaggerService $swaggerService ): mixed
$cache \Yiisoft\Cache\CacheInterface
$responseFactory \Yiisoft\DataResponse\DataResponseFactoryInterface
$swaggerService Yiisoft\Yii\Swagger\Service\SwaggerService

                public function __construct(
    private readonly CacheInterface $cache,
    private readonly DataResponseFactoryInterface $responseFactory,
    private readonly SwaggerService $swaggerService,
) {}

            
handle() public method

public handle( \Psr\Http\Message\ServerRequestInterface $request ): \Psr\Http\Message\ResponseInterface
$request \Psr\Http\Message\ServerRequestInterface

                public function handle(ServerRequestInterface $request): ResponseInterface
{
    if (!$this->enableCache) {
        $openApi = $this->swaggerService->fetch($this->paths);
    } else {
        /** @var OpenApi $openApi */
        $openApi = $this->cache->getOrSet(
            [self::class, $this->paths],
            fn() => $this->swaggerService->fetch($this->paths),
            $this->cacheTTL,
        );
    }
    return $this->responseFactory->createResponse($openApi);
}

            
withCache() public method

public withCache( DateInterval|integer|null $cacheTTL null ): self
$cacheTTL DateInterval|integer|null

                public function withCache(DateInterval|int $cacheTTL = null): self
{
    $new = clone $this;
    $new->enableCache = true;
    $new->cacheTTL = $cacheTTL;
    return $new;
}

            
withPaths() public method

public withPaths( string $paths ): self
$paths string

                public function withPaths(string ...$paths): self
{
    $new = clone $this;
    $new->paths = $paths;
    return $new;
}