Skip to content

Commit 1aa641f

Browse files
committed
fix(OpenApiType): Include default value even if null
Signed-off-by: provokateurin <[email protected]>
1 parent d4a05c1 commit 1aa641f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/OpenApiType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ enum: [0, 1],
104104
if ($this->deprecated) {
105105
$values['deprecated'] = true;
106106
}
107-
if ($this->hasDefaultValue && $this->defaultValue !== null) {
107+
if ($this->hasDefaultValue) {
108108
$values['default'] = $this->type === 'object' && empty($this->defaultValue) ? new stdClass() : $this->defaultValue;
109109
}
110110
if ($this->enum !== null) {

tests/openapi-administration.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5456,7 +5456,8 @@
54565456
"properties": {
54575457
"some-param": {
54585458
"type": "string",
5459-
"nullable": true
5459+
"nullable": true,
5460+
"default": null
54605461
},
54615462
"some-param-with-explicit-default-value": {
54625463
"type": "string",

tests/openapi-full.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5613,7 +5613,8 @@
56135613
"properties": {
56145614
"some-param": {
56155615
"type": "string",
5616-
"nullable": true
5616+
"nullable": true,
5617+
"default": null
56175618
},
56185619
"some-param-with-explicit-default-value": {
56195620
"type": "string",

0 commit comments

Comments
 (0)