Skip to content

Commit 07b2881

Browse files
committed
fix(metadata): allow to pass a string as RDF type for properties
1 parent 031e737 commit 07b2881

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Metadata/ApiProperty.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ final class ApiProperty
8383
private $securityPostDenormalize;
8484

8585
/**
86-
* The related schemas.
86+
* The RDF types of this property.
8787
*
8888
* @var string[]
8989
*/
@@ -122,6 +122,7 @@ final class ApiProperty
122122
* @param bool $push
123123
* @param string $security
124124
* @param string $securityPostDenormalize
125+
* @param string[]|string $types
125126
*/
126127
public function __construct(
127128
?string $description = null,
@@ -132,8 +133,8 @@ public function __construct(
132133
?bool $required = null,
133134
?bool $identifier = null,
134135

135-
$default = null,
136-
$example = null,
136+
$default = null,
137+
$example = null,
137138

138139
?string $deprecationReason = null,
139140
?bool $fetchable = null,
@@ -144,7 +145,7 @@ public function __construct(
144145
?string $security = null,
145146
?string $securityPostDenormalize = null,
146147

147-
?array $types = [],
148+
$types = [],
148149
?array $builtinTypes = [],
149150
?array $schema = [],
150151
?bool $initializable = null,
@@ -170,7 +171,7 @@ public function __construct(
170171
$this->security = $security;
171172
$this->openapiContext = $openapiContext;
172173
$this->securityPostDenormalize = $securityPostDenormalize;
173-
$this->types = $types;
174+
$this->types = (array) $types;
174175
$this->builtinTypes = $builtinTypes;
175176
$this->schema = $schema;
176177
$this->initializable = $initializable;
@@ -403,10 +404,13 @@ public function getTypes(): ?array
403404
return $this->types;
404405
}
405406

406-
public function withTypes(array $types = []): self
407+
/**
408+
* @param string[]|string $types
409+
*/
410+
public function withTypes($types = []): self
407411
{
408412
$self = clone $this;
409-
$self->types = $types;
413+
$self->types = (array) $types;
410414

411415
return $self;
412416
}

0 commit comments

Comments
 (0)