diff --git a/src/Analysers/AttributeAnnotationFactory.php b/src/Analysers/AttributeAnnotationFactory.php index 8c0968783..507f64e27 100644 --- a/src/Analysers/AttributeAnnotationFactory.php +++ b/src/Analysers/AttributeAnnotationFactory.php @@ -47,9 +47,14 @@ public function build(\Reflector $reflector, Context $context): array $instance = $attribute->newInstance(); if ($instance instanceof OA\AbstractAnnotation) { $annotations[] = $instance; + } else { + if ($context->is('other') === false) { + $context->other = []; + } + $context->other[] = $instance; } } else { - $context->logger->debug(sprintf('Could not instantiate attribute "%s", because class not found.', $attribute->getName())); + $context->logger->debug(sprintf('Could not instantiate attribute "%s"; class not found.', $attribute->getName())); } } diff --git a/src/Analysers/DocBlockAnnotationFactory.php b/src/Analysers/DocBlockAnnotationFactory.php index d55031584..435c47769 100644 --- a/src/Analysers/DocBlockAnnotationFactory.php +++ b/src/Analysers/DocBlockAnnotationFactory.php @@ -6,6 +6,7 @@ namespace OpenApi\Analysers; +use OpenApi\Annotations as OA; use OpenApi\Context; use OpenApi\Generator; @@ -55,7 +56,19 @@ public function build(\Reflector $reflector, Context $context): array $this->docBlockParser->setAliases($aliases); if (method_exists($reflector, 'getDocComment') && ($comment = $reflector->getDocComment())) { - return $this->docBlockParser->fromComment($comment, $context); + $annotations = []; + foreach ($this->docBlockParser->fromComment($comment, $context) as $instance) { + if ($instance instanceof OA\AbstractAnnotation) { + $annotations[] = $instance; + } else { + if ($context->is('other') === false) { + $context->other = []; + } + $context->other[] = $instance; + } + } + + return $annotations; } return []; diff --git a/src/Context.php b/src/Context.php index 6fcffcfd1..4282ad66b 100644 --- a/src/Context.php +++ b/src/Context.php @@ -37,6 +37,7 @@ * the serializer * @property OA\AbstractAnnotation|null $nested * @property OA\AbstractAnnotation[]|null $annotations + * @property OA\AbstractAnnotation[]|null $other Annotations not related to OpenApi * @property LoggerInterface|null $logger Guaranteed to be set when using the `Generator` * @property array|null $scanned Details of file scanner when using ReflectionAnalyser * @property string|null $version The OpenAPI version in use