Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/openapi
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ foreach ($options["processor"] as $processor) {
}

$analyser = new ReflectionAnalyser([new DocBlockAnnotationFactory(), new AttributeAnnotationFactory()]);
$analyser->setGenerator($generator);

$openapi = $generator
->setVersion($options['version'])
Expand Down
6 changes: 2 additions & 4 deletions src/Analysers/AnalyserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

use OpenApi\Analysis;
use OpenApi\Context;
use OpenApi\Generator;
use OpenApi\GeneratorAwareInterface;

interface AnalyserInterface
interface AnalyserInterface extends GeneratorAwareInterface
{
public function setGenerator(Generator $generator): void;

public function fromFile(string $filename, Context $context): Analysis;
}
6 changes: 2 additions & 4 deletions src/Analysers/AnnotationFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@

use OpenApi\Annotations as OA;
use OpenApi\Context;
use OpenApi\Generator;
use OpenApi\GeneratorAwareInterface;

interface AnnotationFactoryInterface
interface AnnotationFactoryInterface extends GeneratorAwareInterface
{
/**
* Checks if this factory is supported by the current runtime.
*/
public function isSupported(): bool;

public function setGenerator(Generator $generator): void;

/**
* @return array<OA\AbstractAnnotation> top level annotations
*/
Expand Down
1 change: 1 addition & 0 deletions src/Analysers/AttributeAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OpenApi\Annotations as OA;
use OpenApi\Context;
use OpenApi\Generator;
use OpenApi\GeneratorAwareTrait;

class AttributeAnnotationFactory implements AnnotationFactoryInterface
{
Expand Down
5 changes: 4 additions & 1 deletion src/Analysers/DocBlockAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OpenApi\Annotations as OA;
use OpenApi\Context;
use OpenApi\Generator;
use OpenApi\GeneratorAwareTrait;

class DocBlockAnnotationFactory implements AnnotationFactoryInterface
{
Expand All @@ -26,11 +27,13 @@ public function isSupported(): bool
return DocBlockParser::isEnabled();
}

public function setGenerator(Generator $generator): void
public function setGenerator(Generator $generator)
{
$this->generator = $generator;

$this->docBlockParser->setAliases($generator->getAliases());

return $this;
}

public function build(\Reflector $reflector, Context $context): array
Expand Down
1 change: 1 addition & 0 deletions src/Analysers/ReflectionAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OpenApi\Annotations as OA;
use OpenApi\Context;
use OpenApi\Generator;
use OpenApi\GeneratorAwareTrait;
use OpenApi\OpenApiException;

/**
Expand Down
12 changes: 12 additions & 0 deletions src/GeneratorAwareInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi;

interface GeneratorAwareInterface
{
public function setGenerator(Generator $generator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* @license Apache 2.0
*/

namespace OpenApi\Analysers;

use OpenApi\Generator;
namespace OpenApi;

trait GeneratorAwareTrait
{
protected ?Generator $generator = null;

public function setGenerator(Generator $generator): void
public function setGenerator(Generator $generator)
{
$this->generator = $generator;

return $this;
}
}