Final Class Yiisoft\Yii\Swagger\Action\SwaggerJson
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Psr\ |
Public Methods
Method Details
| public mixed __construct ( \ | ||
| $cache | \ |
|
| $responseFactory | \ |
|
| $swaggerService | Yiisoft\ |
|
public function __construct(
private readonly CacheInterface $cache,
private readonly DataResponseFactoryInterface $responseFactory,
private readonly SwaggerService $swaggerService,
) {}
| public \ | ||
| $request | \ |
|
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);
}
| public self withCache ( DateInterval|integer|null $cacheTTL = null ) | ||
| $cacheTTL | DateInterval|integer|null | |
public function withCache(DateInterval|int|null $cacheTTL = null): self
{
$new = clone $this;
$new->enableCache = true;
$new->cacheTTL = $cacheTTL;
return $new;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.