Repository: postmanlabs/postman-code-generators
Pull request #128 (2019-11-19 10:18:32)

No file fix for form-data 


Patch:
diff --git a/codegens/csharp-restsharp/lib/restsharp.js b/codegens/csharp-restsharp/lib/restsharp.js
index e55dde5..b190224 100644
--- a/codegens/csharp-restsharp/lib/restsharp.js
+++ b/codegens/csharp-restsharp/lib/restsharp.js
@@ -3,6 +3,7 @@ var _ = require('./lodash'),
   parseRequest = require('./parseRequest'),
   sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
   self;
 
 /**
@@ -38,7 +39,8 @@ function makeSnippet (request, options) {
   snippet += parseRequest.parseHeader(request.toJSON(), options.trimRequestBody);
   if (request.body && request.body.mode === 'formdata') {
     let isFile = false,
-      formdata = request.body.formdata;
+      formdata = request.body.formdata,
+      formdataArray = [];
     request.body.toJSON().formdata.forEach((data) => {
       if (!data.disabled && data.type === 'file') {
         isFile = true;
@@ -53,19 +55,39 @@ function makeSnippet (request, options) {
     // The following code handles multiple files in the same formdata param.
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+      // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   snippet += parseRequest.parseBody(request, options.trimRequestBody);
diff --git a/codegens/csharp-restsharp/lib/util.js b/codegens/csharp-restsharp/lib/util.js
index 5026b3c..75d0ed3 100644
--- a/codegens/csharp-restsharp/lib/util.js
+++ b/codegens/csharp-restsharp/lib/util.js
@@ -81,7 +81,40 @@ function sanitizeOptions (options, optionsArray) {
   return result;
 }
 
+/**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+
+ * Appends a single param to form data array
+ */
+function addFormParam (array, key, type, val, disabled, contentType) {
+  if (type === 'file') {
+    array.push({
+      key: key,
+      type: type,
+      src: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+  else {
+    array.push({
+      key: key,
+      type: type,
+      value: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+}
+
 module.exports = {
   sanitize: sanitize,
-  sanitizeOptions: sanitizeOptions
+  sanitizeOptions: sanitizeOptions,
+  addFormParam: addFormParam
 };
diff --git a/codegens/curl/lib/index.js b/codegens/curl/lib/index.js
index c669e60..f59eb43 100644
--- a/codegens/curl/lib/index.js
+++ b/codegens/curl/lib/index.js
@@ -1,6 +1,7 @@
 var sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
   getUrlStringfromUrlObject = require('./util').getUrlStringfromUrlObject,
+  addFormParam = require('./util').addFormParam,
   form = require('./util').form,
   _ = require('./lodash'),
   self;
@@ -71,20 +72,35 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        if (type === 'file') {
+          if (typeof param.src !== 'string') {
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     if (request.body) {
diff --git a/codegens/curl/lib/util.js b/codegens/curl/lib/util.js
index 0b5ba56..20dcc05 100644
--- a/codegens/curl/lib/util.js
+++ b/codegens/curl/lib/util.js
@@ -150,5 +150,37 @@ module.exports = {
     }
 
     return url;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/golang/lib/index.js b/codegens/golang/lib/index.js
index 1666fec..e57457a 100644
--- a/codegens/golang/lib/index.js
+++ b/codegens/golang/lib/index.js
@@ -1,6 +1,7 @@
 var _ = require('./lodash'),
   sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
   isFile = false,
   self;
 
@@ -175,20 +176,35 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        if (type === 'file') {
+          if (typeof param.src !== 'string') {
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     if (request.body) {
diff --git a/codegens/golang/lib/util.js b/codegens/golang/lib/util.js
index 338452c..ad86149 100644
--- a/codegens/golang/lib/util.js
+++ b/codegens/golang/lib/util.js
@@ -82,5 +82,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/http/lib/code-http-converter.js b/codegens/http/lib/code-http-converter.js
index c903c77..22fbdb6 100644
--- a/codegens/http/lib/code-http-converter.js
+++ b/codegens/http/lib/code-http-converter.js
@@ -49,20 +49,41 @@ function convert (request, options, callback) {
   // It removes the form data params where the src property is an array of filepath strings
   // Splits that array into different form data params with src set as a single filepath string
   if (request.body && request.body.mode === 'formdata') {
-    let formdata = request.body.formdata;
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    let formdata = request.body.formdata,
+      formdataArray = [];
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+      // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              utils.addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            utils.addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          utils.addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        utils.addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   snippet += `${utils.getHeaders(request)}\n`;
diff --git a/codegens/http/lib/util.js b/codegens/http/lib/util.js
index 8773698..1a45a59 100644
--- a/codegens/http/lib/util.js
+++ b/codegens/http/lib/util.js
@@ -333,10 +333,43 @@ function sanitizeOptions (options, optionsArray) {
   return result;
 }
 
+/**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+function addFormParam (array, key, type, val, disabled, contentType) {
+  if (type === 'file') {
+    array.push({
+      key: key,
+      type: type,
+      src: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+  else {
+    array.push({
+      key: key,
+      type: type,
+      value: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+}
+
 module.exports = {
   getEndPoint: getEndPoint,
   getHost: getHost,
   getHeaders: getHeaders,
   getBody: getBody,
-  sanitizeOptions: sanitizeOptions
+  sanitizeOptions: sanitizeOptions,
+  addFormParam: addFormParam
 };
diff --git a/codegens/java-okhttp/lib/okhttp.js b/codegens/java-okhttp/lib/okhttp.js
index 1bf11b6..d7e927a 100644
--- a/codegens/java-okhttp/lib/okhttp.js
+++ b/codegens/java-okhttp/lib/okhttp.js
@@ -2,6 +2,7 @@ var _ = require('./lodash'),
 
   parseRequest = require('./parseRequest'),
   sanitize = require('./util').sanitize,
+  addFormParam = require('./util').addFormParam,
   sanitizeOptions = require('./util').sanitizeOptions;
 
 //  Since Java OkHttp requires to add extralines of code to handle methods with body
@@ -36,20 +37,35 @@ function makeSnippet (request, indentString, options) {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        if (type === 'file') {
+          if (typeof param.src !== 'string') {
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     requestBody = (request.body ? request.body.toJSON() : {});
diff --git a/codegens/java-okhttp/lib/util.js b/codegens/java-okhttp/lib/util.js
index 4f89599..4ed8cd8 100644
--- a/codegens/java-okhttp/lib/util.js
+++ b/codegens/java-okhttp/lib/util.js
@@ -82,5 +82,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/java-unirest/lib/unirest.js b/codegens/java-unirest/lib/unirest.js
index 7a7381d..8a3b0b3 100644
--- a/codegens/java-unirest/lib/unirest.js
+++ b/codegens/java-unirest/lib/unirest.js
@@ -1,5 +1,6 @@
 var _ = require('./lodash'),
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
 
   parseRequest = require('./parseRequest');
 
@@ -53,20 +54,41 @@ function makeSnippet (request, indentString, options) {
   // It removes the form data params where the src property is an array of filepath strings
   // Splits that array into different form data params with src set as a single filepath string
   if (request.body && request.body.mode === 'formdata') {
-    let formdata = request.body.formdata;
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    let formdata = request.body.formdata,
+      formdataArray = [];
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+      // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   snippet += parseRequest.parseBody(request, indentString, options.trimRequestBody);
diff --git a/codegens/java-unirest/lib/util.js b/codegens/java-unirest/lib/util.js
index 30b698d..121a935 100644
--- a/codegens/java-unirest/lib/util.js
+++ b/codegens/java-unirest/lib/util.js
@@ -82,7 +82,40 @@ function sanitizeOptions (options, optionsArray) {
   }
   return result;
 }
+
+/**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+function addFormParam (array, key, type, val, disabled, contentType) {
+  if (type === 'file') {
+    array.push({
+      key: key,
+      type: type,
+      src: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+  else {
+    array.push({
+      key: key,
+      type: type,
+      value: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+}
 module.exports = {
   sanitize: sanitize,
-  sanitizeOptions: sanitizeOptions
+  sanitizeOptions: sanitizeOptions,
+  addFormParam: addFormParam
 };
diff --git a/codegens/js-fetch/lib/index.js b/codegens/js-fetch/lib/index.js
index 2cfb469..8ae0e5d 100644
--- a/codegens/js-fetch/lib/index.js
+++ b/codegens/js-fetch/lib/index.js
@@ -1,6 +1,7 @@
 var _ = require('./lodash'),
   sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
   path = require('path');
 const VALID_BODY_MODES = ['urlencoded', 'raw', 'graphql', 'file', 'formdata'];
 
@@ -249,20 +250,41 @@ function convert (request, options, callback) {
   // It removes the form data params where the src property is an array of filepath strings
   // Splits that array into different form data params with src set as a single filepath string
   if (request.body && request.body.mode === 'formdata') {
-    let formdata = request.body.formdata;
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    let formdata = request.body.formdata,
+      formdataArray = [];
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+      // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   body = request.body && request.body.toJSON();
diff --git a/codegens/js-fetch/lib/util.js b/codegens/js-fetch/lib/util.js
index 616432a..15fb111 100644
--- a/codegens/js-fetch/lib/util.js
+++ b/codegens/js-fetch/lib/util.js
@@ -82,7 +82,39 @@ function sanitizeOptions (options, optionsArray) {
   return result;
 }
 
+/**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+function addFormParam (array, key, type, val, disabled, contentType) {
+  if (type === 'file') {
+    array.push({
+      key: key,
+      type: type,
+      src: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+  else {
+    array.push({
+      key: key,
+      type: type,
+      value: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+}
 module.exports = {
   sanitize: sanitize,
-  sanitizeOptions: sanitizeOptions
+  sanitizeOptions: sanitizeOptions,
+  addFormParam: addFormParam
 };
diff --git a/codegens/js-jquery/lib/js-jquery.js b/codegens/js-jquery/lib/js-jquery.js
index 7ff5a06..1253388 100644
--- a/codegens/js-jquery/lib/js-jquery.js
+++ b/codegens/js-jquery/lib/js-jquery.js
@@ -2,6 +2,7 @@ var _ = require('./lodash'),
   parseBody = require('./util/parseBody'),
   sanitize = require('./util/sanitize').sanitize,
   sanitizeOptions = require('./util/sanitize').sanitizeOptions,
+  addFormParam = require('./util/sanitize').addFormParam,
   path = require('path'),
   self;
 
@@ -130,20 +131,35 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        if (type === 'file') {
+          if (typeof param.src !== 'string') {
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
       jQueryCode = createForm(request.toJSON(), options.trimRequestBody);
     }
diff --git a/codegens/js-jquery/lib/util/sanitize.js b/codegens/js-jquery/lib/util/sanitize.js
index 3cb3a57..a94c1cb 100644
--- a/codegens/js-jquery/lib/util/sanitize.js
+++ b/codegens/js-jquery/lib/util/sanitize.js
@@ -98,5 +98,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/js-xhr/lib/index.js b/codegens/js-xhr/lib/index.js
index 4031186..b56a10c 100644
--- a/codegens/js-xhr/lib/index.js
+++ b/codegens/js-xhr/lib/index.js
@@ -1,6 +1,7 @@
 var _ = require('./lodash'),
   sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
   path = require('path');
 
 /**
@@ -218,20 +219,41 @@ function convert (request, options, callback) {
   // It removes the form data params where the src property is an array of filepath strings
   // Splits that array into different form data params with src set as a single filepath string
   if (request.body && request.body.mode === 'formdata') {
-    let formdata = request.body.formdata;
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    let formdata = request.body.formdata,
+      formdataArray = [];
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+      // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   bodySnippet = request.body && !_.isEmpty(request.body.toJSON()) ? parseBody(request.body.toJSON(), trim,
diff --git a/codegens/js-xhr/lib/util.js b/codegens/js-xhr/lib/util.js
index 338452c..ad86149 100644
--- a/codegens/js-xhr/lib/util.js
+++ b/codegens/js-xhr/lib/util.js
@@ -82,5 +82,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/libcurl/lib/index.js b/codegens/libcurl/lib/index.js
index 649cc3e..c810315 100644
--- a/codegens/libcurl/lib/index.js
+++ b/codegens/libcurl/lib/index.js
@@ -1,5 +1,6 @@
 var sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
   _ = require('./lodash'),
   self;
 
@@ -73,20 +74,35 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        if (type === 'file') {
+          if (typeof param.src !== 'string') {
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
 
diff --git a/codegens/libcurl/lib/util.js b/codegens/libcurl/lib/util.js
index fd0b82a..7f44cc8 100644
--- a/codegens/libcurl/lib/util.js
+++ b/codegens/libcurl/lib/util.js
@@ -84,5 +84,37 @@ module.exports = {
     }
 
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/nodejs-native/lib/request.js b/codegens/nodejs-native/lib/request.js
index b3555cf..e7a2bed 100644
--- a/codegens/nodejs-native/lib/request.js
+++ b/codegens/nodejs-native/lib/request.js
@@ -1,5 +1,6 @@
 const _ = require('./lodash'),
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
 
   parseRequest = require('./parseRequest');
 var self;
@@ -45,20 +46,41 @@ function makeSnippet (request, indentString, options) {
   // It removes the form data params where the src property is an array of filepath strings
   // Splits that array into different form data params with src set as a single filepath string
   if (request.body && request.body.mode === 'formdata') {
-    let formdata = request.body.formdata;
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    let formdata = request.body.formdata,
+      formdataArray = [];
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+      // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   if (request.body && request.body[request.body.mode]) {
diff --git a/codegens/nodejs-native/lib/util.js b/codegens/nodejs-native/lib/util.js
index 582a6b2..59e2575 100644
--- a/codegens/nodejs-native/lib/util.js
+++ b/codegens/nodejs-native/lib/util.js
@@ -81,5 +81,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/nodejs-request/lib/parseRequest.js b/codegens/nodejs-request/lib/parseRequest.js
index 19c201b..75c99fd 100644
--- a/codegens/nodejs-request/lib/parseRequest.js
+++ b/codegens/nodejs-request/lib/parseRequest.js
@@ -33,7 +33,7 @@ function extractFormData (dataArray, indentString, trimBody) {
              *      }
              *  }
              */
-      if (Array.isArray(item.src)) {
+      if (Array.isArray(item.src) && item.src.length) {
         let fileSnippet = '',
           fileArray = [];
         _.forEach(item.src, (filePath) => {
@@ -48,6 +48,17 @@ function extractFormData (dataArray, indentString, trimBody) {
           return accumalator;
         }
       }
+      else if (typeof item.src !== 'string') {
+        accumalator.push([
+          indentString.repeat(2) + `'${sanitize(item.key, trimBody)}': {`,
+          indentString.repeat(3) + '\'value\': fs.createReadStream(\'/path/to/file\'),',
+          indentString.repeat(3) + '\'options\': {',
+          indentString.repeat(4) + '\'filename\': \'filename\'',
+          indentString.repeat(4) + '\'contentType\': null',
+          indentString.repeat(3) + '}',
+          indentString.repeat(2) + '}'
+        ].join('\n'));
+      }
       else {
         var pathArray = item.src.split(path.sep),
           fileName = pathArray[pathArray.length - 1];
diff --git a/codegens/nodejs-unirest/lib/unirest.js b/codegens/nodejs-unirest/lib/unirest.js
index cb4fa70..7ae18c0 100644
--- a/codegens/nodejs-unirest/lib/unirest.js
+++ b/codegens/nodejs-unirest/lib/unirest.js
@@ -1,5 +1,6 @@
 var _ = require('./lodash'),
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
 
   parseRequest = require('./parseRequest');
 
@@ -36,20 +37,41 @@ function makeSnippet (request, indentString, options) {
   // It removes the form data params where the src property is an array of filepath strings
   // Splits that array into different form data params with src set as a single filepath string
   if (request.body && request.body.mode === 'formdata') {
-    let formdata = request.body.formdata;
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    let formdata = request.body.formdata,
+      formdataArray = [];
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+      // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   if (request.body) {
diff --git a/codegens/nodejs-unirest/lib/util.js b/codegens/nodejs-unirest/lib/util.js
index 632d112..c21cff8 100644
--- a/codegens/nodejs-unirest/lib/util.js
+++ b/codegens/nodejs-unirest/lib/util.js
@@ -82,7 +82,40 @@ function sanitizeOptions (options, optionsArray) {
   return result;
 }
 
+/**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+function addFormParam (array, key, type, val, disabled, contentType) {
+  if (type === 'file') {
+    array.push({
+      key: key,
+      type: type,
+      src: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+  else {
+    array.push({
+      key: key,
+      type: type,
+      value: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+}
+
 module.exports = {
   sanitize: sanitize,
-  sanitizeOptions: sanitizeOptions
+  sanitizeOptions: sanitizeOptions,
+  addFormParam: addFormParam
 };
diff --git a/codegens/ocaml-cohttp/lib/ocaml.js b/codegens/ocaml-cohttp/lib/ocaml.js
index bbc33c8..3f670a4 100644
--- a/codegens/ocaml-cohttp/lib/ocaml.js
+++ b/codegens/ocaml-cohttp/lib/ocaml.js
@@ -1,6 +1,7 @@
 var _ = require('./lodash'),
   sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
   self;
 
 /**
@@ -299,7 +300,7 @@ self = module.exports = {
     var codeSnippet, indent, trim, finalUrl, methodArg, // timeout, followRedirect,
       bodySnippet = '',
       headerSnippet = '',
-      requestBody = (request.body ? request.body.toJSON() : {}),
+      requestBody,
       requestBodyMode = (request.body ? request.body.mode : 'raw');
 
     indent = options.indentType === 'Tab' ? '\t' : ' ';
@@ -329,22 +330,45 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        // check if type is file or text
+        if (type === 'file') {
+          // if src is not of type string we check for array(multiple files)
+          if (typeof param.src !== 'string') {
+            // if src is an array(not empty), iterate over it and add files as separate form fields
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          // if src is string, directly add the param with src as filepath
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        // if type is text, directly add it to formdata array
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
+
+    requestBody = (request.body ? request.body.toJSON() : {});
     bodySnippet = parseBody(requestBody, trim, indent);
 
     // Starting to add in codeSnippet
diff --git a/codegens/ocaml-cohttp/lib/util.js b/codegens/ocaml-cohttp/lib/util.js
index aee73c2..8754fd5 100644
--- a/codegens/ocaml-cohttp/lib/util.js
+++ b/codegens/ocaml-cohttp/lib/util.js
@@ -100,5 +100,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/php-curl/lib/php-curl.js b/codegens/php-curl/lib/php-curl.js
index 01b0f85..1ed0598 100644
--- a/codegens/php-curl/lib/php-curl.js
+++ b/codegens/php-curl/lib/php-curl.js
@@ -2,6 +2,7 @@ var _ = require('./lodash'),
   parseBody = require('./util/parseBody'),
   sanitize = require('./util/sanitize').sanitize,
   sanitizeOptions = require('./util/sanitize').sanitizeOptions,
+  addFormParam = require('./util/sanitize').addFormParam,
   self;
 
 /**
@@ -124,20 +125,41 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        // check if type is file or text
+        if (type === 'file') {
+          // if src is not of type string we check for array(multiple files)
+          if (typeof param.src !== 'string') {
+            // if src is an array(not empty), iterate over it and add files as separate form fields
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          // if src is string, directly add the param with src as filepath
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        // if type is text, directly add it to formdata array
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     snippet += `${parseBody(request.toJSON(), options.trimRequestBody, indentation)}`;
diff --git a/codegens/php-curl/lib/util/sanitize.js b/codegens/php-curl/lib/util/sanitize.js
index 5d48b52..7cb9438 100644
--- a/codegens/php-curl/lib/util/sanitize.js
+++ b/codegens/php-curl/lib/util/sanitize.js
@@ -98,5 +98,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/php-pecl-http/lib/phpPecl.js b/codegens/php-pecl-http/lib/phpPecl.js
index 5cef6b8..5ad1ff0 100644
--- a/codegens/php-pecl-http/lib/phpPecl.js
+++ b/codegens/php-pecl-http/lib/phpPecl.js
@@ -2,6 +2,7 @@ var _ = require('./lodash'),
   parseBody = require('./util/parseBody'),
   sanitize = require('./util/sanitize').sanitize,
   sanitizeOptions = require('./util/sanitize').sanitizeOptions,
+  addFormParam = require('./util/sanitize').addFormParam,
   self;
 
 /**
@@ -112,20 +113,41 @@ self = module.exports = {
       // It removes the form data params where the src property is an array of filepath strings
       // Splits that array into different form data params with src set as a single filepath string
       if (request.body.mode === 'formdata') {
-        let formdata = request.body.formdata;
-        formdata.members.forEach((item) => {
-          if (item.type === 'file' && Array.isArray(item.src)) {
-            item.src.forEach((filePath) => {
-              formdata.add({
-                key: item.key,
-                src: filePath,
-                type: 'file'
-              });
-            });
+        let formdata = request.body.formdata,
+          formdataArray = [];
+        formdata.members.forEach((param) => {
+          let key = param.key,
+            type = param.type,
+            disabled = param.disabled,
+            contentType = param.contentType;
+            // check if type is file or text
+          if (type === 'file') {
+            // if src is not of type string we check for array(multiple files)
+            if (typeof param.src !== 'string') {
+              // if src is an array(not empty), iterate over it and add files as separate form fields
+              if (Array.isArray(param.src) && param.src.length) {
+                param.src.forEach((filePath) => {
+                  addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+                });
+              }
+              // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+              else {
+                addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+              }
+            }
+            // if src is string, directly add the param with src as filepath
+            else {
+              addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+            }
+          }
+          // if type is text, directly add it to formdata array
+          else {
+            addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
           }
         });
-        formdata.remove((item) => {
-          return (item.type === 'file' && Array.isArray(item.src));
+        request.body.update({
+          mode: 'formdata',
+          formdata: formdataArray
         });
       }
       snippet += '$body = new http\\Message\\Body;\n';
diff --git a/codegens/php-pecl-http/lib/util/sanitize.js b/codegens/php-pecl-http/lib/util/sanitize.js
index ddb4b0e..7f31654 100644
--- a/codegens/php-pecl-http/lib/util/sanitize.js
+++ b/codegens/php-pecl-http/lib/util/sanitize.js
@@ -81,5 +81,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/powershell-restmethod/lib/index.js b/codegens/powershell-restmethod/lib/index.js
index ce3cbbf..ccb9d6c 100644
--- a/codegens/powershell-restmethod/lib/index.js
+++ b/codegens/powershell-restmethod/lib/index.js
@@ -1,6 +1,7 @@
 var _ = require('./lodash'),
   sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
+  addFormParam = require('./util').addFormParam,
   path = require('path');
 const VALID_METHODS = ['DEFAULT',
   'DELETE',
@@ -232,20 +233,41 @@ function convert (request, options, callback) {
   // It removes the form data params where the src property is an array of filepath strings
   // Splits that array into different form data params with src set as a single filepath string
   if (request.body && request.body.mode === 'formdata') {
-    let formdata = request.body.formdata;
-    formdata.members.forEach((item) => {
-      if (item.type === 'file' && Array.isArray(item.src)) {
-        item.src.forEach((filePath) => {
-          formdata.add({
-            key: item.key,
-            src: filePath,
-            type: 'file'
-          });
-        });
+    let formdata = request.body.formdata,
+      formdataArray = [];
+    formdata.members.forEach((param) => {
+      let key = param.key,
+        type = param.type,
+        disabled = param.disabled,
+        contentType = param.contentType;
+        // check if type is file or text
+      if (type === 'file') {
+        // if src is not of type string we check for array(multiple files)
+        if (typeof param.src !== 'string') {
+          // if src is an array(not empty), iterate over it and add files as separate form fields
+          if (Array.isArray(param.src) && param.src.length) {
+            param.src.forEach((filePath) => {
+              addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+            });
+          }
+          // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+          else {
+            addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+          }
+        }
+        // if src is string, directly add the param with src as filepath
+        else {
+          addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+        }
+      }
+      // if type is text, directly add it to formdata array
+      else {
+        addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
       }
     });
-    formdata.remove((item) => {
-      return (item.type === 'file' && Array.isArray(item.src));
+    request.body.update({
+      mode: 'formdata',
+      formdata: formdataArray
     });
   }
   body = request.body ? request.body.toJSON() : {};
diff --git a/codegens/powershell-restmethod/lib/util.js b/codegens/powershell-restmethod/lib/util.js
index 7e9d716..65a4e0f 100644
--- a/codegens/powershell-restmethod/lib/util.js
+++ b/codegens/powershell-restmethod/lib/util.js
@@ -83,7 +83,40 @@ function sanitizeOptions (options, optionsArray) {
   return result;
 }
 
+/**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+function addFormParam (array, key, type, val, disabled, contentType) {
+  if (type === 'file') {
+    array.push({
+      key: key,
+      type: type,
+      src: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+  else {
+    array.push({
+      key: key,
+      type: type,
+      value: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+}
+
 module.exports = {
   sanitize: sanitize,
-  sanitizeOptions: sanitizeOptions
+  sanitizeOptions: sanitizeOptions,
+  addFormParam: addFormParam
 };
diff --git a/codegens/python-http.client/lib/python-httpclient.js b/codegens/python-http.client/lib/python-httpclient.js
index e0444fa..5db35f5 100644
--- a/codegens/python-http.client/lib/python-httpclient.js
+++ b/codegens/python-http.client/lib/python-httpclient.js
@@ -1,6 +1,7 @@
 var _ = require('./lodash'),
   sanitize = require('./util/sanitize').sanitize,
   sanitizeOptions = require('./util/sanitize').sanitizeOptions,
+  addFormParam = require('./util/sanitize').addFormParam,
   parseBody = require('./util/parseBody'),
   self;
 
@@ -138,20 +139,41 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        // check if type is file or text
+        if (type === 'file') {
+          // if src is not of type string we check for array(multiple files)
+          if (typeof param.src !== 'string') {
+            // if src is an array(not empty), iterate over it and add files as separate form fields
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          // if src is string, directly add the param with src as filepath
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        // if type is text, directly add it to formdata array
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     snippet += parseBody(request.toJSON(), indentation, options.requestBodyTrim);
diff --git a/codegens/python-http.client/lib/util/sanitize.js b/codegens/python-http.client/lib/util/sanitize.js
index d2e033e..54bba27 100644
--- a/codegens/python-http.client/lib/util/sanitize.js
+++ b/codegens/python-http.client/lib/util/sanitize.js
@@ -100,5 +100,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/python-requests/lib/python-requests.js b/codegens/python-requests/lib/python-requests.js
index c59e127..6427c6b 100644
--- a/codegens/python-requests/lib/python-requests.js
+++ b/codegens/python-requests/lib/python-requests.js
@@ -2,6 +2,7 @@ var _ = require('./lodash'),
   parseBody = require('./util/parseBody'),
   sanitize = require('./util/sanitize').sanitize,
   sanitizeOptions = require('./util/sanitize').sanitizeOptions,
+  addFormParam = require('./util/sanitize').addFormParam,
   self;
 
 /**
@@ -109,20 +110,41 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        // check if type is file or text
+        if (type === 'file') {
+          // if src is not of type string we check for array(multiple files)
+          if (typeof param.src !== 'string') {
+            // if src is an array(not empty), iterate over it and add files as separate form fields
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          // if src is string, directly add the param with src as filepath
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        // if type is text, directly add it to formdata array
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     snippet += `${parseBody(request.toJSON(), indentation, options.trimRequestBody)}`;
diff --git a/codegens/python-requests/lib/util/sanitize.js b/codegens/python-requests/lib/util/sanitize.js
index de06d84..9f36810 100644
--- a/codegens/python-requests/lib/util/sanitize.js
+++ b/codegens/python-requests/lib/util/sanitize.js
@@ -98,5 +98,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/ruby/lib/ruby.js b/codegens/ruby/lib/ruby.js
index 4ce0de2..e68a096 100644
--- a/codegens/ruby/lib/ruby.js
+++ b/codegens/ruby/lib/ruby.js
@@ -2,6 +2,7 @@ var _ = require('./lodash'),
   parseBody = require('./util/parseBody'),
   sanitize = require('./util/sanitize').sanitize,
   sanitizeOptions = require('./util/sanitize').sanitizeOptions,
+  addFormParam = require('./util/sanitize').addFormParam,
   self;
 
 /**
@@ -135,20 +136,41 @@ self = module.exports = {
       // It removes the form data params where the src property is an array of filepath strings
       // Splits that array into different form data params with src set as a single filepath string
       if (request.body && request.body.mode === 'formdata') {
-        let formdata = request.body.formdata;
-        formdata.members.forEach((item) => {
-          if (item.type === 'file' && Array.isArray(item.src)) {
-            item.src.forEach((filePath) => {
-              formdata.add({
-                key: item.key,
-                src: filePath,
-                type: 'file'
-              });
-            });
+        let formdata = request.body.formdata,
+          formdataArray = [];
+        formdata.members.forEach((param) => {
+          let key = param.key,
+            type = param.type,
+            disabled = param.disabled,
+            contentType = param.contentType;
+            // check if type is file or text
+          if (type === 'file') {
+            // if src is not of type string we check for array(multiple files)
+            if (typeof param.src !== 'string') {
+              // if src is an array(not empty), iterate over it and add files as separate form fields
+              if (Array.isArray(param.src) && param.src.length) {
+                param.src.forEach((filePath) => {
+                  addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+                });
+              }
+              // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+              else {
+                addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+              }
+            }
+            // if src is string, directly add the param with src as filepath
+            else {
+              addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+            }
+          }
+          // if type is text, directly add it to formdata array
+          else {
+            addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
           }
         });
-        formdata.remove((item) => {
-          return (item.type === 'file' && Array.isArray(item.src));
+        request.body.update({
+          mode: 'formdata',
+          formdata: formdataArray
         });
       }
       snippet += `${parseBody(request.toJSON(), options.trimRequestBody)}\n`;
diff --git a/codegens/ruby/lib/util/sanitize.js b/codegens/ruby/lib/util/sanitize.js
index 5d48b52..7cb9438 100644
--- a/codegens/ruby/lib/util/sanitize.js
+++ b/codegens/ruby/lib/util/sanitize.js
@@ -98,5 +98,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/shell-httpie/lib/shell-httpie.js b/codegens/shell-httpie/lib/shell-httpie.js
index 0406711..d4bf615 100644
--- a/codegens/shell-httpie/lib/shell-httpie.js
+++ b/codegens/shell-httpie/lib/shell-httpie.js
@@ -1,6 +1,7 @@
 var _ = require('./lodash'),
   Helpers = require('./util/helpers'),
   sanitizeOptions = require('./util/sanitize').sanitizeOptions,
+  addFormParam = require('./util/sanitize').addFormParam,
   self;
 
 const GAP = ' ',
@@ -87,20 +88,41 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        // check if type is file or text
+        if (type === 'file') {
+          // if src is not of type string we check for array(multiple files)
+          if (typeof param.src !== 'string') {
+            // if src is an array(not empty), iterate over it and add files as separate form fields
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          // if src is string, directly add the param with src as filepath
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        // if type is text, directly add it to formdata array
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     // snippet construction based on the request body
diff --git a/codegens/shell-httpie/lib/util/sanitize.js b/codegens/shell-httpie/lib/util/sanitize.js
index ca55a36..e3f303b 100644
--- a/codegens/shell-httpie/lib/util/sanitize.js
+++ b/codegens/shell-httpie/lib/util/sanitize.js
@@ -77,5 +77,37 @@ module.exports = {
       }
     }
     return result;
+  },
+
+  /**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+  addFormParam: function (array, key, type, val, disabled, contentType) {
+    if (type === 'file') {
+      array.push({
+        key: key,
+        type: type,
+        src: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
+    else {
+      array.push({
+        key: key,
+        type: type,
+        value: val,
+        disabled: disabled,
+        contentType: contentType
+      });
+    }
   }
 };
diff --git a/codegens/shell-wget/lib/shell-wget.js b/codegens/shell-wget/lib/shell-wget.js
index 5104b5c..78b1632 100644
--- a/codegens/shell-wget/lib/shell-wget.js
+++ b/codegens/shell-wget/lib/shell-wget.js
@@ -121,23 +121,9 @@ self = module.exports = {
         }
       });
 
-      // The following code handles multiple files in the same formdata param.
-      // It removes the form data params where the src property is an array of filepath strings
-      // Splits that array into different form data params with src set as a single filepath string
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
-        }
-      });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     if (isFormDataFile) {
diff --git a/codegens/swift/lib/swift.js b/codegens/swift/lib/swift.js
index 4bc501b..bb21458 100644
--- a/codegens/swift/lib/swift.js
+++ b/codegens/swift/lib/swift.js
@@ -2,6 +2,7 @@ var _ = require('./lodash'),
   sanitize = require('./util').sanitize,
   sanitizeOptions = require('./util').sanitizeOptions,
   getUrlStringfromUrlObject = require('./util').getUrlStringfromUrlObject,
+  addFormParam = require('./util').addFormParam,
   self;
 
 /**
@@ -285,20 +286,41 @@ self = module.exports = {
     // It removes the form data params where the src property is an array of filepath strings
     // Splits that array into different form data params with src set as a single filepath string
     if (request.body && request.body.mode === 'formdata') {
-      let formdata = request.body.formdata;
-      formdata.members.forEach((item) => {
-        if (item.type === 'file' && Array.isArray(item.src)) {
-          item.src.forEach((filePath) => {
-            formdata.add({
-              key: item.key,
-              src: filePath,
-              type: 'file'
-            });
-          });
+      let formdata = request.body.formdata,
+        formdataArray = [];
+      formdata.members.forEach((param) => {
+        let key = param.key,
+          type = param.type,
+          disabled = param.disabled,
+          contentType = param.contentType;
+        // check if type is file or text
+        if (type === 'file') {
+          // if src is not of type string we check for array(multiple files)
+          if (typeof param.src !== 'string') {
+            // if src is an array(not empty), iterate over it and add files as separate form fields
+            if (Array.isArray(param.src) && param.src.length) {
+              param.src.forEach((filePath) => {
+                addFormParam(formdataArray, key, param.type, filePath, disabled, contentType);
+              });
+            }
+            // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
+            else {
+              addFormParam(formdataArray, key, param.type, '/path/to/file', disabled, contentType);
+            }
+          }
+          // if src is string, directly add the param with src as filepath
+          else {
+            addFormParam(formdataArray, key, param.type, param.src, disabled, contentType);
+          }
+        }
+        // if type is text, directly add it to formdata array
+        else {
+          addFormParam(formdataArray, key, param.type, param.value, disabled, contentType);
         }
       });
-      formdata.remove((item) => {
-        return (item.type === 'file' && Array.isArray(item.src));
+      request.body.update({
+        mode: 'formdata',
+        formdata: formdataArray
       });
     }
     requestBody = (request.body ? request.body.toJSON() : {});
diff --git a/codegens/swift/lib/util.js b/codegens/swift/lib/util.js
index 8068741..7ef16e2 100644
--- a/codegens/swift/lib/util.js
+++ b/codegens/swift/lib/util.js
@@ -142,8 +142,41 @@ function getUrlStringfromUrlObject (urlObject) {
   return url;
 }
 
+/**
+ *
+ * @param {Array} array - form data array
+ * @param {String} key - key of form data param
+ * @param {String} type - type of form data param(file/text)
+ * @param {String} val - value/src property of form data param
+ * @param {String} disabled - Boolean denoting whether the param is disabled or not
+ * @param {String} contentType - content type header of the param
+ *
+ * Appends a single param to form data array
+ */
+function addFormParam (array, key, type, val, disabled, contentType) {
+  if (type === 'file') {
+    array.push({
+      key: key,
+      type: type,
+      src: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+  else {
+    array.push({
+      key: key,
+      type: type,
+      value: val,
+      disabled: disabled,
+      contentType: contentType
+    });
+  }
+}
+
 module.exports = {
   sanitize: sanitize,
   sanitizeOptions: sanitizeOptions,
-  getUrlStringfromUrlObject: getUrlStringfromUrlObject
+  getUrlStringfromUrlObject: getUrlStringfromUrlObject,
+  addFormParam: addFormParam
 };
diff --git a/npm/addPathToFormdataFile.js b/npm/addPathToFormdataFile.js
index 5a74d97..6094657 100644
--- a/npm/addPathToFormdataFile.js
+++ b/npm/addPathToFormdataFile.js
@@ -3,9 +3,9 @@ var path = require('path'),
 let collectionPath = path.resolve(__dirname, '../test/codegen/newman/fixtures/formdataFileCollection.json'),
   collection = require(collectionPath),
   formdata = collection.item[0].request.body.formdata;
-formdata[1].src = path.resolve(__dirname, '../test1.txt');
-formdata[2].src[0] = path.resolve(__dirname, '../test2.txt');
-formdata[2].src[1] = path.resolve(__dirname, '../test3.txt');
+formdata[0].src = path.resolve(__dirname, '../test1.txt');
+formdata[1].src[0] = path.resolve(__dirname, '../test2.txt');
+formdata[1].src[1] = path.resolve(__dirname, '../test3.txt');
 
 fs.writeFileSync(collectionPath, JSON.stringify(collection, null, 2), function (error) {
   if (error) {
diff --git a/package-lock.json b/package-lock.json
index ac73aa4..9a2e894 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "postman-code-generators",
-  "version": "0.1.0-beta.0",
+  "version": "0.1.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
diff --git a/package.json b/package.json
index 45361f7..a56e542 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "postman-code-generators",
-  "version": "0.1.0-beta.0",
+  "version": "0.1.0",
   "description": "Generates code snippets for a postman collection",
   "main": "index.js",
   "directories": {


Test patch:
diff --git a/codegens/csharp-restsharp/test/unit/convert.test.js b/codegens/csharp-restsharp/test/unit/convert.test.js
index f06f302..7641474 100644
--- a/codegens/csharp-restsharp/test/unit/convert.test.js
+++ b/codegens/csharp-restsharp/test/unit/convert.test.js
@@ -114,6 +114,54 @@ describe('csharp restsharp function', function () {
       });
     });
 
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('request.AddFile("no file", "/path/to/file"');
+        expect(snippet).to.include('request.AddFile("no src", "/path/to/file"');
+        expect(snippet).to.include('request.AddFile("invalid src", "/path/to/file"');
+      });
+    });
   });
 
   describe('getOptions function', function () {
diff --git a/codegens/curl/test/unit/convert.test.js b/codegens/curl/test/unit/convert.test.js
index 46210e3..e7f7494 100644
--- a/codegens/curl/test/unit/convert.test.js
+++ b/codegens/curl/test/unit/convert.test.js
@@ -207,6 +207,55 @@ describe('curl convert function', function () {
       });
     });
 
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('no file=@/path/to/file');
+        expect(snippet).to.include('no src=@/path/to/file');
+        expect(snippet).to.include('invalid src=@/path/to/file');
+      });
+    });
+
     describe('getUrlStringfromUrlObject function', function () {
       var rawUrl, urlObject, outputUrlString;
 
diff --git a/codegens/golang/test/unit/convert.test.js b/codegens/golang/test/unit/convert.test.js
index f20e365..d8c982e 100644
--- a/codegens/golang/test/unit/convert.test.js
+++ b/codegens/golang/test/unit/convert.test.js
@@ -116,5 +116,54 @@ describe('Golang convert function', function () {
         expect(snippet).to.include('req.Header.Add("key_containing_whitespaces", "  value_containing_whitespaces  ")');
       });
     });
+
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('writer.CreateFormFile("no file",filepath.Base("/path/to/file"))');
+        expect(snippet).to.include('writer.CreateFormFile("no src",filepath.Base("/path/to/file"))');
+        expect(snippet).to.include('writer.CreateFormFile("invalid src",filepath.Base("/path/to/file"))');
+      });
+    });
   });
 });
diff --git a/codegens/http/test/unit/converter.test.js b/codegens/http/test/unit/converter.test.js
index 3050afc..66c566c 100644
--- a/codegens/http/test/unit/converter.test.js
+++ b/codegens/http/test/unit/converter.test.js
@@ -140,6 +140,17 @@ describe('Converter test', function () {
             'type': 'file',
             'src': ['/test2.txt',
               '/test3.txt']
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
           }
         ]
       },
@@ -161,9 +172,12 @@ describe('Converter test', function () {
         expect.fail(null, null, error);
       }
       expect(snippet).to.be.a('string');
-      expect(snippet).to.include('test1.txt');
-      expect(snippet).to.include('test2.txt');
-      expect(snippet).to.include('test3.txt');
+      expect(snippet).to.include('name="single file"; filename="test1.txt"');
+      expect(snippet).to.include('name="multiple files"; filename="test2.txt"');
+      expect(snippet).to.include('name="multiple files"; filename="test3.txt"');
+      expect(snippet).to.include('name="no file"; filename="file"');
+      expect(snippet).to.include('name="no src"; filename="file"');
+      expect(snippet).to.include('name="invalid src"; filename="file"');
     });
   });
 });
diff --git a/codegens/java-okhttp/test/unit/convert.test.js b/codegens/java-okhttp/test/unit/convert.test.js
index 7738bcf..17224af 100644
--- a/codegens/java-okhttp/test/unit/convert.test.js
+++ b/codegens/java-okhttp/test/unit/convert.test.js
@@ -106,6 +106,56 @@ describe('okhttp convert function', function () {
         expect(snippet).to.include('.addHeader("key_containing_whitespaces", "  value_containing_whitespaces  ")');
       });
     });
+
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('"no file","file"');
+        expect(snippet).to.include('"no src","file"');
+        expect(snippet).to.include('"invalid src","file"');
+        expect(snippet).to.include('new File("/path/to/file")');
+      });
+    });
   });
 
   describe('getOptions function', function () {
diff --git a/codegens/java-unirest/test/unit/convert.test.js b/codegens/java-unirest/test/unit/convert.test.js
index d8ebf75..3cbfce6 100644
--- a/codegens/java-unirest/test/unit/convert.test.js
+++ b/codegens/java-unirest/test/unit/convert.test.js
@@ -322,6 +322,53 @@ describe('java unirest convert function for test collection', function () {
         expect(snippet).to.not.include('.multiPartContent()');
       });
     });
+
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('.field("file", new File("/path/to/file"))');
+      });
+    });
   });
   describe('getUrlStringfromUrlObject function', function () {
     var rawUrl, urlObject, outputUrlString;
diff --git a/codegens/js-fetch/test/unit/convert.test.js b/codegens/js-fetch/test/unit/convert.test.js
index dd16869..06aad1b 100644
--- a/codegens/js-fetch/test/unit/convert.test.js
+++ b/codegens/js-fetch/test/unit/convert.test.js
@@ -180,6 +180,55 @@ describe('js-fetch convert function for test collection', function () {
         expect(snippet).to.include('var raw = JSON.stringify({"json":"Test-Test"})');
       });
     });
+
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('formdata.append("no file", fileInput.files[0], "file")');
+        expect(snippet).to.include('formdata.append("no src", fileInput.files[0], "file")');
+        expect(snippet).to.include('formdata.append("invalid src", fileInput.files[0], "file")');
+      });
+    });
   });
 
   describe('getOptions function', function () {
diff --git a/codegens/js-jquery/test/unit/converter.test.js b/codegens/js-jquery/test/unit/converter.test.js
index 03567e6..80ef42a 100644
--- a/codegens/js-jquery/test/unit/converter.test.js
+++ b/codegens/js-jquery/test/unit/converter.test.js
@@ -191,6 +191,17 @@ describe('jQuery converter', function () {
             'type': 'file',
             'src': ['/test2.txt',
               '/test3.txt']
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
           }
         ]
       },
@@ -212,9 +223,12 @@ describe('jQuery converter', function () {
         expect.fail(null, null, error);
       }
       expect(snippet).to.be.a('string');
-      expect(snippet).to.include('test1.txt');
-      expect(snippet).to.include('test2.txt');
-      expect(snippet).to.include('test3.txt');
+      expect(snippet).to.include('"no file", fileInput.files[0], "file"');
+      expect(snippet).to.include('"single file", fileInput.files[0], "test1.txt"');
+      expect(snippet).to.include('"multiple files", fileInput.files[0], "test2.txt"');
+      expect(snippet).to.include('"multiple files", fileInput.files[0], "test3.txt"');
+      expect(snippet).to.include('"no src", fileInput.files[0], "file"');
+      expect(snippet).to.include('"invalid src", fileInput.files[0], "file"');
     });
   });
 });
diff --git a/codegens/js-xhr/test/unit/convert.test.js b/codegens/js-xhr/test/unit/convert.test.js
index 8a4e166..c180a0b 100644
--- a/codegens/js-xhr/test/unit/convert.test.js
+++ b/codegens/js-xhr/test/unit/convert.test.js
@@ -67,6 +67,54 @@ describe('js-xhr convert function', function () {
       expect(snippet).to.include('var data = JSON.stringify({"json":"Test-Test"})');
     });
   });
+  it('should generate snippets for no files in form data', function () {
+    var request = new sdk.Request({
+      'method': 'POST',
+      'header': [],
+      'body': {
+        'mode': 'formdata',
+        'formdata': [
+          {
+            'key': 'no file',
+            'value': '',
+            'type': 'file',
+            'src': []
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
+          }
+        ]
+      },
+      'url': {
+        'raw': 'https://postman-echo.com/post',
+        'protocol': 'https',
+        'host': [
+          'postman-echo',
+          'com'
+        ],
+        'path': [
+          'post'
+        ]
+      }
+    });
+    convert(request, {}, function (error, snippet) {
+      if (error) {
+        expect.fail(null, null, error);
+      }
+      expect(snippet).to.be.a('string');
+      expect(snippet).to.include('data.append("no file", fileInput.files[0], "file")');
+      expect(snippet).to.include('data.append("no src", fileInput.files[0], "file")');
+      expect(snippet).to.include('data.append("invalid src", fileInput.files[0], "file")');
+    });
+  });
 
   describe('Sanitize function', function () {
     it('should return empty string when input is not a string type', function () {
diff --git a/codegens/libcurl/test/unit/convert.test.js b/codegens/libcurl/test/unit/convert.test.js
index 2579bb0..fd40f82 100644
--- a/codegens/libcurl/test/unit/convert.test.js
+++ b/codegens/libcurl/test/unit/convert.test.js
@@ -60,6 +60,56 @@ describe('libcurl convert function', function () {
         '  value_containing_whitespaces  "');
       });
     });
+
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('curl_mime_name(part, "no file");');
+        expect(snippet).to.include('curl_mime_filedata(part, "/path/to/file");');
+        expect(snippet).to.include('curl_mime_name(part, "no src");');
+        expect(snippet).to.include('curl_mime_name(part, "invalid src");');
+      });
+    });
   });
 
   describe('getOptions function', function () {
diff --git a/codegens/nodejs-native/test/unit/snippet.test.js b/codegens/nodejs-native/test/unit/snippet.test.js
index 393a1c7..652a497 100644
--- a/codegens/nodejs-native/test/unit/snippet.test.js
+++ b/codegens/nodejs-native/test/unit/snippet.test.js
@@ -127,4 +127,52 @@ describe('nodejs-native convert function', function () {
       expect(snippet).to.include('var postData = JSON.stringify({"json":"Test-Test"})');
     });
   });
+  it('should generate snippets for no files in form data', function () {
+    var request = new sdk.Request({
+      'method': 'POST',
+      'header': [],
+      'body': {
+        'mode': 'formdata',
+        'formdata': [
+          {
+            'key': 'no file',
+            'value': '',
+            'type': 'file',
+            'src': []
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
+          }
+        ]
+      },
+      'url': {
+        'raw': 'https://postman-echo.com/post',
+        'protocol': 'https',
+        'host': [
+          'postman-echo',
+          'com'
+        ],
+        'path': [
+          'post'
+        ]
+      }
+    });
+    convert(request, {}, function (error, snippet) {
+      if (error) {
+        expect.fail(null, null, error);
+      }
+      expect(snippet).to.be.a('string');
+      expect(snippet).to.include('name=\\"no file\\"; filename=\\"file\\"');
+      expect(snippet).to.include('name=\\"no src\\"; filename=\\"file\\"');
+      expect(snippet).to.include('name=\\"invalid src\\"; filename=\\"file\\"');
+    });
+  });
 });
diff --git a/codegens/nodejs-request/test/unit/snippet.test.js b/codegens/nodejs-request/test/unit/snippet.test.js
index 17803f8..f4a8b54 100644
--- a/codegens/nodejs-request/test/unit/snippet.test.js
+++ b/codegens/nodejs-request/test/unit/snippet.test.js
@@ -307,6 +307,56 @@ describe('nodejs-request convert function', function () {
       });
     });
 
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('\'no file\': {');
+        expect(snippet).to.include('\'no src\': {');
+        expect(snippet).to.include('\'invalid src\': {');
+        expect(snippet).to.include('\'value\': fs.createReadStream(\'/path/to/file\')');
+      });
+    });
+
     describe('getOptions function', function () {
 
       it('should return an array of specific options', function () {
diff --git a/codegens/nodejs-unirest/test/unit/snippet.test.js b/codegens/nodejs-unirest/test/unit/snippet.test.js
index 6a04e5b..6fb1073 100644
--- a/codegens/nodejs-unirest/test/unit/snippet.test.js
+++ b/codegens/nodejs-unirest/test/unit/snippet.test.js
@@ -143,6 +143,53 @@ describe('nodejs unirest convert function', function () {
         expect(snippet).to.include('.send(JSON.stringify({"json":"Test-Test"}))');
       });
     });
+
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('.attach(\'file\', \'/path/to/file\')');
+      });
+    });
   });
 
   describe('getOptions function', function () {
diff --git a/codegens/ocaml-cohttp/test/unit/convert.test.js b/codegens/ocaml-cohttp/test/unit/convert.test.js
index 071b635..2ca5727 100644
--- a/codegens/ocaml-cohttp/test/unit/convert.test.js
+++ b/codegens/ocaml-cohttp/test/unit/convert.test.js
@@ -147,6 +147,17 @@ describe('Ocaml unit tests', function () {
               'type': 'file',
               'src': ['/test2.txt',
                 '/test3.txt']
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
             }
           ]
         },
@@ -168,9 +179,12 @@ describe('Ocaml unit tests', function () {
           expect.fail(null, null, error);
         }
         expect(snippet).to.be.a('string');
-        expect(snippet).to.include('test1.txt');
-        expect(snippet).to.include('test2.txt');
-        expect(snippet).to.include('test3.txt');
+        expect(snippet).to.include('("name", "no file"); ("fileName", "/path/to/file")');
+        expect(snippet).to.include('("name", "single file"); ("fileName", "/test1.txt")');
+        expect(snippet).to.include('("name", "multiple files"); ("fileName", "/test2.txt")');
+        expect(snippet).to.include('("name", "multiple files"); ("fileName", "/test3.txt")');
+        expect(snippet).to.include('("name", "no src"); ("fileName", "/path/to/file")');
+        expect(snippet).to.include('("name", "invalid src"); ("fileName", "/path/to/file")');
       });
     });
   });
diff --git a/codegens/php-curl/test/unit/converter.test.js b/codegens/php-curl/test/unit/converter.test.js
index 0241383..799a527 100644
--- a/codegens/php-curl/test/unit/converter.test.js
+++ b/codegens/php-curl/test/unit/converter.test.js
@@ -36,4 +36,53 @@ describe('php-curl converter', function () {
     });
   });
 
+  it('should generate snippets for no files in form data', function () {
+    var request = new sdk.Request({
+      'method': 'POST',
+      'header': [],
+      'body': {
+        'mode': 'formdata',
+        'formdata': [
+          {
+            'key': 'no file',
+            'value': '',
+            'type': 'file',
+            'src': []
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
+          }
+        ]
+      },
+      'url': {
+        'raw': 'https://postman-echo.com/post',
+        'protocol': 'https',
+        'host': [
+          'postman-echo',
+          'com'
+        ],
+        'path': [
+          'post'
+        ]
+      }
+    });
+    convert(request, {}, function (error, snippet) {
+      if (error) {
+        expect.fail(null, null, error);
+      }
+      expect(snippet).to.be.a('string');
+      expect(snippet).to.include('\'no file\'=> new CURLFILE(\'/path/to/file\')');
+      expect(snippet).to.include('\'no src\'=> new CURLFILE(\'/path/to/file\')');
+      expect(snippet).to.include('\'invalid src\'=> new CURLFILE(\'/path/to/file\')');
+    });
+  });
+
 });
diff --git a/codegens/php-pecl-http/test/unit/converter.test.js b/codegens/php-pecl-http/test/unit/converter.test.js
index 6557880..4cdd55e 100644
--- a/codegens/php-pecl-http/test/unit/converter.test.js
+++ b/codegens/php-pecl-http/test/unit/converter.test.js
@@ -642,6 +642,17 @@ describe('Request Snippet', function () {
               'type': 'file',
               'src': ['/test2.txt',
                 '/test3.txt']
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
             }
           ]
         },
@@ -663,9 +674,16 @@ describe('Request Snippet', function () {
           expect.fail(null, null, error);
         }
         expect(snippet).to.be.a('string');
-        expect(snippet).to.include('test1.txt');
-        expect(snippet).to.include('test2.txt');
-        expect(snippet).to.include('test3.txt');
+        /* eslint-disable quotes */
+        /* eslint-disable max-len */
+        expect(snippet).to.include("array('name' => 'no file', 'type' => '<Content-type header>', 'file' => '/path/to/file', 'data' => null)");
+        expect(snippet).to.include("array('name' => 'single file', 'type' => '<Content-type header>', 'file' => '/test1.txt', 'data' => null)");
+        expect(snippet).to.include("array('name' => 'multiple files', 'type' => '<Content-type header>', 'file' => '/test3.txt', 'data' => null)");
+        expect(snippet).to.include("array('name' => 'multiple files', 'type' => '<Content-type header>', 'file' => '/test3.txt', 'data' => null)");
+        expect(snippet).to.include("array('name' => 'no src', 'type' => '<Content-type header>', 'file' => '/path/to/file', 'data' => null)");
+        expect(snippet).to.include("array('name' => 'invalid src', 'type' => '<Content-type header>', 'file' => '/path/to/file', 'data' => null)");
+        /* eslint-enable quotes */
+        /* eslint-enable max-len */
       });
     });
   });
diff --git a/codegens/powershell-restmethod/test/unit/convert.test.js b/codegens/powershell-restmethod/test/unit/convert.test.js
index 12e7025..5100ad0 100644
--- a/codegens/powershell-restmethod/test/unit/convert.test.js
+++ b/codegens/powershell-restmethod/test/unit/convert.test.js
@@ -378,6 +378,17 @@ describe('Powershell-restmethod converter', function () {
               'type': 'file',
               'src': ['/test2.txt',
                 '/test3.txt']
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
             }
           ]
         },
@@ -399,9 +410,15 @@ describe('Powershell-restmethod converter', function () {
           expect.fail(null, null, error);
         }
         expect(snippet).to.be.a('string');
-        expect(snippet).to.include('test1.txt');
-        expect(snippet).to.include('test2.txt');
-        expect(snippet).to.include('test3.txt');
+        expect(snippet).to.include('$fileHeader.Name = "no file"');
+        expect(snippet).to.include('$fileHeader.Name = "single file"');
+        expect(snippet).to.include('$fileHeader.Name = "multiple files"');
+        expect(snippet).to.include('$fileHeader.Name = "no src"');
+        expect(snippet).to.include('$fileHeader.Name = "invalid src"');
+        expect(snippet).to.include('$multipartFile = \'/path/to/file\'');
+        expect(snippet).to.include('$multipartFile = \'/test1.txt\'');
+        expect(snippet).to.include('$multipartFile = \'/test2.txt\'');
+        expect(snippet).to.include('$multipartFile = \'/test3.txt\'');
       });
     });
   });
diff --git a/codegens/python-http.client/test/unit/converter.test.js b/codegens/python-http.client/test/unit/converter.test.js
index acdb104..197f926 100644
--- a/codegens/python-http.client/test/unit/converter.test.js
+++ b/codegens/python-http.client/test/unit/converter.test.js
@@ -170,6 +170,56 @@ describe('Python-http.client converter', function () {
       });
     });
 
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('name=no file');
+        expect(snippet).to.include('name=no src');
+        expect(snippet).to.include('name=invalid src');
+        expect(snippet).to.include('with open(\'/path/to/file\')');
+      });
+    });
+
   });
 
   describe('parseBody function', function () {
diff --git a/codegens/python-requests/test/unit/converter.test.js b/codegens/python-requests/test/unit/converter.test.js
index 4fa6b86..4792ded 100644
--- a/codegens/python-requests/test/unit/converter.test.js
+++ b/codegens/python-requests/test/unit/converter.test.js
@@ -63,4 +63,53 @@ describe('Python- Requests converter', function () {
     });
   });
 
+  it('should generate snippets for no files in form data', function () {
+    var request = new sdk.Request({
+      'method': 'POST',
+      'header': [],
+      'body': {
+        'mode': 'formdata',
+        'formdata': [
+          {
+            'key': 'no file',
+            'value': '',
+            'type': 'file',
+            'src': []
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
+          }
+        ]
+      },
+      'url': {
+        'raw': 'https://postman-echo.com/post',
+        'protocol': 'https',
+        'host': [
+          'postman-echo',
+          'com'
+        ],
+        'path': [
+          'post'
+        ]
+      }
+    });
+    convert(request, {}, function (error, snippet) {
+      if (error) {
+        expect.fail(null, null, error);
+      }
+      expect(snippet).to.be.a('string');
+      expect(snippet).to.include('(\'no file\', open(\'/path/to/file\',\'rb\'))');
+      expect(snippet).to.include('(\'no src\', open(\'/path/to/file\',\'rb\'))');
+      expect(snippet).to.include('(\'invalid src\', open(\'/path/to/file\',\'rb\'))');
+    });
+  });
+
 });
diff --git a/codegens/ruby/test/unit/converter.test.js b/codegens/ruby/test/unit/converter.test.js
index b680817..bad80c7 100644
--- a/codegens/ruby/test/unit/converter.test.js
+++ b/codegens/ruby/test/unit/converter.test.js
@@ -58,4 +58,53 @@ describe('Ruby converter', function () {
     });
   });
 
+  it('should generate snippets for no files in form data', function () {
+    var request = new sdk.Request({
+      'method': 'POST',
+      'header': [],
+      'body': {
+        'mode': 'formdata',
+        'formdata': [
+          {
+            'key': 'no file',
+            'value': '',
+            'type': 'file',
+            'src': []
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
+          }
+        ]
+      },
+      'url': {
+        'raw': 'https://postman-echo.com/post',
+        'protocol': 'https',
+        'host': [
+          'postman-echo',
+          'com'
+        ],
+        'path': [
+          'post'
+        ]
+      }
+    });
+    convert(request, {}, function (error, snippet) {
+      if (error) {
+        expect.fail(null, null, error);
+      }
+      expect(snippet).to.be.a('string');
+      expect(snippet).to.include('[\'no file\', File.open(\'/path/to/file\')]');
+      expect(snippet).to.include('[\'no src\', File.open(\'/path/to/file\')]');
+      expect(snippet).to.include('[\'invalid src\', File.open(\'/path/to/file\')]');
+    });
+  });
+
 });
diff --git a/codegens/shell-httpie/test/unit/converter.test.js b/codegens/shell-httpie/test/unit/converter.test.js
index 9af7093..1fd96cf 100644
--- a/codegens/shell-httpie/test/unit/converter.test.js
+++ b/codegens/shell-httpie/test/unit/converter.test.js
@@ -94,6 +94,55 @@ describe('Shell-Httpie convert function', function () {
       expect(snippet).to.include('key_containing_whitespaces:\'  value_containing_whitespaces  \'');
     });
   });
+
+  it('should generate snippets for no files in form data', function () {
+    var request = new sdk.Request({
+      'method': 'POST',
+      'header': [],
+      'body': {
+        'mode': 'formdata',
+        'formdata': [
+          {
+            'key': 'no file',
+            'value': '',
+            'type': 'file',
+            'src': []
+          },
+          {
+            'key': 'no src',
+            'value': '',
+            'type': 'file'
+          },
+          {
+            'key': 'invalid src',
+            'value': '',
+            'type': 'file',
+            'src': {}
+          }
+        ]
+      },
+      'url': {
+        'raw': 'https://postman-echo.com/post',
+        'protocol': 'https',
+        'host': [
+          'postman-echo',
+          'com'
+        ],
+        'path': [
+          'post'
+        ]
+      }
+    });
+    convert(request, {}, function (error, snippet) {
+      if (error) {
+        expect.fail(null, null, error);
+      }
+      expect(snippet).to.be.a('string');
+      expect(snippet).to.include('\'no file\'@/path/to/file');
+      expect(snippet).to.include('\'no src\'@/path/to/file');
+      expect(snippet).to.include('\'invalid src\'@/path/to/file');
+    });
+  });
 });
 
 describe('Sanitize function', function () {
diff --git a/codegens/swift/test/unit/convert.test.js b/codegens/swift/test/unit/convert.test.js
index dbce12b..a76e901 100644
--- a/codegens/swift/test/unit/convert.test.js
+++ b/codegens/swift/test/unit/convert.test.js
@@ -149,6 +149,56 @@ describe('Swift Converter', function () {
         'forHTTPHeaderField: "key_containing_whitespaces")');
       });
     });
+
+    it('should generate snippets for no files in form data', function () {
+      var request = new sdk.Request({
+        'method': 'POST',
+        'header': [],
+        'body': {
+          'mode': 'formdata',
+          'formdata': [
+            {
+              'key': 'no file',
+              'value': '',
+              'type': 'file',
+              'src': []
+            },
+            {
+              'key': 'no src',
+              'value': '',
+              'type': 'file'
+            },
+            {
+              'key': 'invalid src',
+              'value': '',
+              'type': 'file',
+              'src': {}
+            }
+          ]
+        },
+        'url': {
+          'raw': 'https://postman-echo.com/post',
+          'protocol': 'https',
+          'host': [
+            'postman-echo',
+            'com'
+          ],
+          'path': [
+            'post'
+          ]
+        }
+      });
+      convert(request, {}, function (error, snippet) {
+        if (error) {
+          expect.fail(null, null, error);
+        }
+        expect(snippet).to.be.a('string');
+        expect(snippet).to.include('"key": "no file"');
+        expect(snippet).to.include('"src": "/path/to/file"');
+        expect(snippet).to.include('"key": "no src"');
+        expect(snippet).to.include('"key": "invalid src"');
+      });
+    });
   });
 
   describe('getUrlStringfromUrlObject function', function () {
diff --git a/test/codegen/newman/fixtures/formdataFileCollection.json b/test/codegen/newman/fixtures/formdataFileCollection.json
index 9aa8d78..5db4f20 100644
--- a/test/codegen/newman/fixtures/formdataFileCollection.json
+++ b/test/codegen/newman/fixtures/formdataFileCollection.json
@@ -6,7 +6,7 @@
 	},
 	"item": [
 		{
-			"name": "No/Single/multiple file upload via form-data",
+			"name": "Single/multiple file upload via form-data",
 			"request": {
 				"method": "POST",
 				"header": [],
@@ -14,12 +14,6 @@
 					"mode": "formdata",
 					"formdata": [
 						{
-              "key": "no file",
-              "value": "",
-              "type": "file",
-              "src": []
-						},
-						{
               "key": "single file",
               "value": "",
               "type": "file",