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
2 changes: 1 addition & 1 deletion src/Analysers/AttributeAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions tests/Fixtures/Scratch/PromotedProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -52,6 +58,12 @@ public function __construct(
* @OA\Property()
*/
public string $different = '',

/*
* Intentionally not promoted!
*/
#[OAT\Property()]
MyEnum $myEnum,
) {
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/Fixtures/Scratch/PromotedProperty3.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ paths:
description: OK
components:
schemas:
MyEnum:
type: string
enum:
- AA
PromotedPropertyDescription:
properties:
thevalue:
Expand All @@ -20,6 +24,8 @@ components:
other:
description: 'Other value.'
type: string
myEnum:
$ref: '#/components/schemas/MyEnum'
thename:
description: 'Property name.'
type: string
Expand Down
6 changes: 6 additions & 0 deletions tests/Fixtures/Scratch/PromotedProperty3.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ paths:
description: OK
components:
schemas:
MyEnum:
type: string
enum:
- AA
PromotedPropertyDescription:
properties:
thevalue:
Expand All @@ -20,6 +24,8 @@ components:
other:
description: 'Other value.'
type: string
myEnum:
$ref: '#/components/schemas/MyEnum'
thename:
description: 'Property name.'
type: string
Expand Down