-
-
Notifications
You must be signed in to change notification settings - Fork 869
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
feat(openapi): allow optional request body content #6374
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,16 +17,16 @@ final class RequestBody | |
{ | ||
use ExtensionTrait; | ||
|
||
public function __construct(private string $description = '', private ?\ArrayObject $content = null, private bool $required = false) | ||
public function __construct(private ?string $description = null, private ?\ArrayObject $content = null, private bool $required = false) | ||
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. funny enough 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. The PR's originated where I wanted to edit the description of an endpoint, but by doing so, I needed to rewrite the whole The PR code make the |
||
{ | ||
} | ||
|
||
public function getDescription(): string | ||
public function getDescription(): ?string | ||
{ | ||
return $this->description; | ||
} | ||
|
||
public function getContent(): \ArrayObject | ||
public function getContent(): ?\ArrayObject | ||
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. see my previous comment this was correct but the constructor is not |
||
{ | ||
return $this->content; | ||
} | ||
|
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.
to understand this correctly the main change is that
true
is now the default value when there's a request body ?I think that early on we used
false
as a default value to comply with: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#request-body-object I agree that this is better thanks!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.
In the current code, the constructor set
Model\RequestBody
'srequired
tofalse
by default. But theOpenFactory
force therequired
to betrue
if there were noRequestBody
and if this was a write operation.Here the PR allow the developer to fine-tune the values as he/she wants.
So it's even possible now to set a
required
tofalse
even in a write operation.