Skip to content

Commit 6a18b5c

Browse files
php-nextgen - Fix flatten() to support arrays of files in multipart/form-data
Previously, FormDataProcessor::flatten() unconditionally passed all values through ObjectSerializer::toString(), which caused an error when flattening arrays containing file resources (e.g. for OpenAPI multipart/form-data definitions with `type: array`, `items: type: string, format: binary`). This change adds a check for is_resource() to preserve stream handles without serialization, ensuring correct behavior when uploading multiple files in a single request.
1 parent 5eb083e commit 6a18b5c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

modules/openapi-generator/src/main/resources/php-nextgen/FormDataProcessor.mustache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ class FormDataProcessor
104104
$currentName .= $currentSuffix;
105105
}
106106

107-
$result[$currentName] = ObjectSerializer::toString($val);
107+
if (is_resource($val)) {
108+
$result[$currentName] = $val;
109+
} else {
110+
$result[$currentName] = ObjectSerializer::toString($val);
111+
}
108112
}
109113

110114
$currentName = $start;

0 commit comments

Comments
 (0)