Final Class Yiisoft\Yii\Swagger\Service\SwaggerService
| Inheritance | Yiisoft\Yii\Swagger\Service\SwaggerService |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\Swagger\Service\SwaggerService | |
| fetch() | Yiisoft\Yii\Swagger\Service\SwaggerService | |
| getViewName() | Yiisoft\Yii\Swagger\Service\SwaggerService | |
| getViewPath() | Yiisoft\Yii\Swagger\Service\SwaggerService | |
| withOptions() | Returns a new instance with the specified options for {@see OpenApi} generation. | Yiisoft\Yii\Swagger\Service\SwaggerService |
Method Details
| public mixed __construct ( \Yiisoft\Aliases\Aliases $aliases, \OpenApi\Generator|null $generator = null, \Psr\Log\LoggerInterface|null $logger = null ) | ||
| $aliases | \Yiisoft\Aliases\Aliases | |
| $generator | \OpenApi\Generator|null | |
| $logger | \Psr\Log\LoggerInterface|null | |
public function __construct(
private readonly Aliases $aliases,
private readonly ?Generator $generator = null,
private readonly ?LoggerInterface $logger = null,
) {
$this->viewPath = dirname(__DIR__, 2) . '/views';
}
| public \OpenApi\Annotations\OpenApi fetch ( array $paths ) | ||
| $paths | array | |
public function fetch(array $paths): OpenApi
{
if ($paths === []) {
throw new InvalidArgumentException('Source paths cannot be empty array.');
}
$directories = array_map($this->aliases->get(...), $paths);
$analysis = isset($this->options['analysis']) && $this->options['analysis'] instanceof Analysis
? $this->options['analysis']
: null;
$validate = !isset($this->options['validate']) || (bool) $this->options['validate'];
$generator = $this->generator ?? $this->createGenerator();
$openApi = $generator->generate($directories, $analysis, $validate);
if ($openApi === null) {
throw new RuntimeException(
sprintf(
'No OpenApi target set. Run the "%s" processor before "%s::fetch()".',
MergeIntoOpenApi::class,
self::class,
),
);
}
return $openApi;
}
| public string getViewPath ( ) |
public function getViewPath(): string
{
return $this->aliases->get($this->viewPath);
}
Returns a new instance with the specified options for {@see OpenApi} generation.
| public self withOptions ( array $options ) | ||
| $options | array |
For {@see \OpenApi\Generator}. |
public function withOptions(array $options): self
{
$new = clone $this;
$new->options = $options;
return $new;
}
Signup or Login in order to comment.