Skip to content

Commit bcf6ba3

Browse files
author
Daniel Held
committed
feat: improve query parameter schema handling for array types
1 parent 36d1927 commit bcf6ba3

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/Services/OpenApi.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,30 @@ private function processOperationParameters(Operation $operation, array $route,
325325
// Add query parameters from pre-processed route data (includes both attribute and smart detection)
326326
if (! empty($route['query_parameters'])) {
327327
foreach ($route['query_parameters'] as $name => $param) {
328-
$schema = $this->createSchema([
328+
$schemaData = [
329329
'type' => $param['type'] ?? 'string',
330330
'format' => $param['format'] ?? null,
331331
'enum' => $param['enum'] ?? null,
332-
]);
332+
];
333+
334+
// For array types, ensure items schema is present
335+
if ($schemaData['type'] === 'array') {
336+
$itemsData = $param['items'] ?? ['type' => 'string'];
337+
// Clean up items schema (remove null values)
338+
$cleanItems = ['type' => $itemsData['type'] ?? 'string'];
339+
if (isset($itemsData['format']) && $itemsData['format'] !== null) {
340+
$cleanItems['format'] = $itemsData['format'];
341+
}
342+
if (isset($itemsData['description'])) {
343+
$cleanItems['description'] = $itemsData['description'];
344+
}
345+
if (isset($itemsData['enum']) && !empty($itemsData['enum'])) {
346+
$cleanItems['enum'] = $itemsData['enum'];
347+
}
348+
$schemaData['items'] = $cleanItems;
349+
}
350+
351+
$schema = $this->createSchema($schemaData);
333352

334353
$parameters[] = $this->createParameter([
335354
'name' => $name,

0 commit comments

Comments
 (0)