Skip to content

Commit 0b50ed5

Browse files
fix(Model): ensure empty OAS properties are always object, not list
1 parent b42d25c commit 0b50ed5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core

‎pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Model.inc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use RESTAPI\Responses\NotFoundError;
2424
use RESTAPI\Responses\ServerError;
2525
use RESTAPI\Responses\ServiceUnavailableError;
2626
use RESTAPI\Responses\ValidationError;
27+
use stdClass;
2728
use function RESTAPI\Core\Tools\get_classes_from_namespace;
2829

2930
# Constants
@@ -1213,6 +1214,11 @@ class Model {
12131214
$openapi_schema['properties'][$field] = $this->$field->to_openapi_property();
12141215
}
12151216

1217+
# Convert properties to object if it's empty. Required for proper JSON conversion.
1218+
if ($openapi_schema["properties"] === []) {
1219+
$openapi_schema["properties"] = new stdClass();
1220+
}
1221+
12161222
return $openapi_schema;
12171223
}
12181224

0 commit comments

Comments
 (0)