Skip to content

Commit 3c4e507

Browse files
authored
Merge pull request #15 from danielxheld/main
fix: add example support for array type parameters in request body schema
2 parents 7796f5a + 28d6113 commit 3c4e507

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Services/OpenApi.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,11 +879,17 @@ private function buildRequestBodySchema(array $parameters): Schema
879879

880880
// CRITICAL: Pass items as ARRAY in constructor, NOT as Schema object
881881
// The Schema constructor will automatically convert it to a Schema object
882-
$properties[$name] = new Schema([
882+
$arraySchemaData = [
883883
'type' => 'array',
884884
'description' => $param['description'] ?? '',
885885
'items' => $itemsSchemaData, // Pass as array, not Schema object
886-
]);
886+
];
887+
888+
if (!empty($param['example'])) {
889+
$arraySchemaData['example'] = $param['example'];
890+
}
891+
892+
$properties[$name] = new Schema($arraySchemaData);
887893
}
888894
// Handle simple properties
889895
else {

0 commit comments

Comments
 (0)