-
-
Notifications
You must be signed in to change notification settings - Fork 922
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
{ | ||
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) | ||
{ | ||
if (null === $style) { | ||
if ('query' === $in || 'cookie' === $in) { | ||
|
@@ -55,12 +55,12 @@ | |
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. actually in the constructor if it's not a |
||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. can be removed if set in the cosntructor |
||
} | ||
|
||
public function getSchema(): array | ||
|
@@ -85,12 +85,12 @@ | |
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. move this to constructor |
||
} | ||
|
||
public function getAllowReserved(): ?bool | ||
{ | ||
return $this->allowReserved; | ||
return 'query' === $this->in ? $this->allowReserved : null; | ||
} | ||
|
||
public function getExample() | ||
|
@@ -151,7 +151,9 @@ | |
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 commentThe reason will be displayed to describe this comment to others. Learn more. remove this |
||
} | ||
|
||
return $clone; | ||
} | ||
|
@@ -183,7 +185,9 @@ | |
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 commentThe reason will be displayed to describe this comment to others. Learn more. remove this |
||
} | ||
|
||
return $clone; | ||
} | ||
|
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