Skip to content

Commit 7d66378

Browse files
MrSrsensoyuka
authored andcommitted
fix(openapi): nullable default values in operation openapi definition
1 parent 347c27e commit 7d66378

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Metadata/Extractor/XmlResourceExtractor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ private function buildOpenapi(\SimpleXMLElement $resource): bool|OpenApiOperatio
224224
in: $this->phpize($parameter, 'in', 'string'),
225225
description: $this->phpize($parameter, 'description', 'string'),
226226
required: $this->phpize($parameter, 'required', 'bool'),
227-
deprecated: $this->phpize($parameter, 'deprecated', 'bool'),
228-
allowEmptyValue: $this->phpize($parameter, 'allowEmptyValue', 'bool'),
229-
schema: isset($parameter->schema->values) ? $this->buildValues($parameter->schema->values) : null,
227+
deprecated: $this->phpize($parameter, 'deprecated', 'bool', false),
228+
allowEmptyValue: $this->phpize($parameter, 'allowEmptyValue', 'bool', null),
229+
schema: isset($parameter->schema->values) ? $this->buildValues($parameter->schema->values) : [],
230230
style: $this->phpize($parameter, 'style', 'string'),
231-
explode: $this->phpize($parameter, 'explode', 'bool'),
232-
allowReserved: $this->phpize($parameter, 'allowReserved', 'bool'),
231+
explode: $this->phpize($parameter, 'explode', 'bool', false),
232+
allowReserved: $this->phpize($parameter, 'allowReserved', 'bool', null),
233233
example: $this->phpize($parameter, 'example', 'string'),
234234
examples: isset($parameter->examples->values) ? new \ArrayObject($this->buildValues($parameter->examples->values)) : null,
235235
content: isset($parameter->content->values) ? new \ArrayObject($this->buildValues($parameter->content->values)) : null,

src/OpenApi/Model/Parameter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class Parameter
1717
{
1818
use ExtensionTrait;
1919

20-
public function __construct(private string $name, private string $in, private string $description = '', private bool $required = false, private bool $deprecated = false, private bool $allowEmptyValue = false, private array $schema = [], private ?string $style = null, private bool $explode = false, private bool $allowReserved = false, private $example = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $content = null)
20+
public function __construct(private string $name, private string $in, private string $description = '', private bool $required = false, private bool $deprecated = false, private ?bool $allowEmptyValue = false, private array $schema = [], private ?string $style = null, private bool $explode = false, private ?bool $allowReserved = false, private $example = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $content = null)
2121
{
2222
if (null === $style) {
2323
if ('query' === $in || 'cookie' === $in) {
@@ -148,7 +148,7 @@ public function withDeprecated(bool $deprecated): self
148148
return $clone;
149149
}
150150

151-
public function withAllowEmptyValue(bool $allowEmptyValue): self
151+
public function withAllowEmptyValue(?bool $allowEmptyValue): self
152152
{
153153
$clone = clone $this;
154154
$clone->allowEmptyValue = $allowEmptyValue;
@@ -180,7 +180,7 @@ public function withExplode(bool $explode): self
180180
return $clone;
181181
}
182182

183-
public function withAllowReserved(bool $allowReserved): self
183+
public function withAllowReserved(?bool $allowReserved): self
184184
{
185185
$clone = clone $this;
186186
$clone->allowReserved = $allowReserved;

0 commit comments

Comments
 (0)