Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

robjenman
Copy link

Q A
Branch? main
Tickets Closes #7212

@@ -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)
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allowEmptyValue and allowReserved are specified for path parameters
2 participants