-
-
Notifications
You must be signed in to change notification settings - Fork 920
fix(openapi): Prevent allowReserved and allowEmptyValue being returned on a path parameter #7220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
robjenman
commented
Jun 16, 2025
Q | A |
---|---|
Branch? | main |
Tickets | Closes #7212 |
…d on a path parameter
@@ -17,7 +17,7 @@ final class Parameter | |||
{ | |||
use ExtensionTrait; | |||
|
|||
public function __construct(private string $name, private string $in, private string $description = '', private bool $required = false, private bool $deprecated = false, private ?bool $allowEmptyValue = null, private array $schema = [], private ?string $style = null, private bool $explode = false, private ?bool $allowReserved = null, private $example = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $content = null) | |||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep the default values to null so that they're not shown during serialization
@@ -55,12 +55,12 @@ public function getDeprecated(): bool | |||
|
|||
public function canAllowEmptyValue(): ?bool | |||
{ | |||
return $this->allowEmptyValue; | |||
return 'query' === $this->in ? $this->allowEmptyValue : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually in the constructor if it's not a path
parameter we set $this->allowEmptyValue don't change in the getters/setters
} | ||
|
||
public function getAllowEmptyValue(): ?bool | ||
{ | ||
return $this->allowEmptyValue; | ||
return 'query' === $this->in ? $this->allowEmptyValue : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed if set in the cosntructor
@@ -85,12 +85,12 @@ public function getExplode(): bool | |||
|
|||
public function canAllowReserved(): ?bool | |||
{ | |||
return $this->allowReserved; | |||
return 'query' === $this->in ? $this->allowReserved : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to constructor
@@ -151,7 +151,9 @@ public function withDeprecated(bool $deprecated): self | |||
public function withAllowEmptyValue(bool $allowEmptyValue): self | |||
{ | |||
$clone = clone $this; | |||
$clone->allowEmptyValue = $allowEmptyValue; | |||
if ('query' === $clone->in) { | |||
$clone->allowEmptyValue = $allowEmptyValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
@@ -183,7 +185,9 @@ public function withExplode(bool $explode): self | |||
public function withAllowReserved(bool $allowReserved): self | |||
{ | |||
$clone = clone $this; | |||
$clone->allowReserved = $allowReserved; | |||
if ('query' === $clone->in) { | |||
$clone->allowReserved = $allowReserved; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this