|
@@ -144,14 +144,7 @@ class PostmanCollectionWriter
|
|
|
|
|
|
switch ($inputMode) {
|
|
|
case 'formdata':
|
|
|
- foreach ($endpoint['cleanBodyParameters'] as $key => $value) {
|
|
|
- $params = [
|
|
|
- 'key' => $key,
|
|
|
- 'value' => $value,
|
|
|
- 'type' => 'text',
|
|
|
- ];
|
|
|
- $body[$inputMode][] = $params;
|
|
|
- }
|
|
|
+ $body[$inputMode] = $this->getFormDataParams($endpoint['cleanBodyParameters']);
|
|
|
foreach ($endpoint['fileParameters'] as $key => $value) {
|
|
|
while (is_array($value)) { // For arrays of files, just send the first one
|
|
|
$key .= '[]';
|
|
@@ -172,6 +165,35 @@ class PostmanCollectionWriter
|
|
|
return $body;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * This formats the Form Paramaters correctly for Arrays eg. data[item][index] = value
|
|
|
+ * @param array $array
|
|
|
+ * @param string|null $key
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ protected function getFormDataParams(array $array, ?string $key = null): array
|
|
|
+ {
|
|
|
+ $body = [];
|
|
|
+
|
|
|
+ foreach ($array as $index => $value) {
|
|
|
+ $index = $key ? ($key . '[' . $index . ']') : $index;
|
|
|
+
|
|
|
+ if (!is_array($value)) {
|
|
|
+ $body[] = [
|
|
|
+ 'key' => $index,
|
|
|
+ 'value' => $value,
|
|
|
+ 'type' => 'text',
|
|
|
+ ];
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $body = array_merge($body, $this->getFormDataParams($value, $index));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $body;
|
|
|
+ }
|
|
|
+
|
|
|
protected function resolveHeadersForEndpoint($route)
|
|
|
{
|
|
|
[$where, $authParam] = $this->getAuthParamToExclude();
|