Browse Source

Also show empty array query parameters in Postman (#691)

laudaikinhdi 1 year ago
parent
commit
974225c616
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/Writing/PostmanCollectionWriter.php

+ 10 - 0
src/Writing/PostmanCollectionWriter.php

@@ -300,6 +300,16 @@ class PostmanCollectionWriter
                         'disabled' => !$parameterData->required && empty($parameterData->example),
                     ];
                 }
+                // If there are no values, add one entry so the parameter shows up in the Postman UI.
+                if (empty($values)) {
+                    $query[] = [
+                        'key' => "{$name}[]",
+                        'value' => '',
+                        'description' => strip_tags($parameterData->description),
+                        // Default query params to disabled if they aren't required and have empty values
+                        'disabled' => true,
+                    ];
+                }
             } else {
                 $query[] = [
                     'key' => urlencode($name),