diff --git a/src/Analysers/AttributeAnnotationFactory.php b/src/Analysers/AttributeAnnotationFactory.php index 0facdc09c..d9c8e32ef 100644 --- a/src/Analysers/AttributeAnnotationFactory.php +++ b/src/Analysers/AttributeAnnotationFactory.php @@ -71,7 +71,7 @@ public function build(\Reflector $reflector, Context $context): array foreach ($rp->getAttributes($attributeName, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) { /** @var OA\Property|OA\Parameter|OA\RequestBody $instance */ $instance = $attribute->newInstance(); - $instance->_context = new Context(['nested' => true], $context); + $instance->_context = new Context(['nested' => false], $context); $type = (($rnt = $rp->getType()) && $rnt instanceof \ReflectionNamedType) ? $rnt->getName() : Generator::UNDEFINED; $nullable = $rnt ? $rnt->allowsNull() : true; diff --git a/tests/Fixtures/Scratch/PromotedProperty.php b/tests/Fixtures/Scratch/PromotedProperty.php index 3740bb6da..08298826e 100644 --- a/tests/Fixtures/Scratch/PromotedProperty.php +++ b/tests/Fixtures/Scratch/PromotedProperty.php @@ -9,6 +9,12 @@ use OpenApi\Annotations as OA; use OpenApi\Attributes as OAT; +#[OAT\Schema(type: 'string')] +enum MyEnum: string +{ + case AA = 'AA'; +} + #[OAT\Schema] class PromotedPropertyDescription { @@ -52,6 +58,12 @@ public function __construct( * @OA\Property() */ public string $different = '', + + /* + * Intentionally not promoted! + */ + #[OAT\Property()] + MyEnum $myEnum, ) { } } diff --git a/tests/Fixtures/Scratch/PromotedProperty3.0.0.yaml b/tests/Fixtures/Scratch/PromotedProperty3.0.0.yaml index a0b4cc754..0fbee3b8d 100644 --- a/tests/Fixtures/Scratch/PromotedProperty3.0.0.yaml +++ b/tests/Fixtures/Scratch/PromotedProperty3.0.0.yaml @@ -12,6 +12,10 @@ paths: description: OK components: schemas: + MyEnum: + type: string + enum: + - AA PromotedPropertyDescription: properties: thevalue: @@ -20,6 +24,8 @@ components: other: description: 'Other value.' type: string + myEnum: + $ref: '#/components/schemas/MyEnum' thename: description: 'Property name.' type: string diff --git a/tests/Fixtures/Scratch/PromotedProperty3.1.0.yaml b/tests/Fixtures/Scratch/PromotedProperty3.1.0.yaml index 57e190143..74db3abf3 100644 --- a/tests/Fixtures/Scratch/PromotedProperty3.1.0.yaml +++ b/tests/Fixtures/Scratch/PromotedProperty3.1.0.yaml @@ -12,6 +12,10 @@ paths: description: OK components: schemas: + MyEnum: + type: string + enum: + - AA PromotedPropertyDescription: properties: thevalue: @@ -20,6 +24,8 @@ components: other: description: 'Other value.' type: string + myEnum: + $ref: '#/components/schemas/MyEnum' thename: description: 'Property name.' type: string