Merge pull request #413 from postmanlabs/issue/379

Set param type in request to `file` if schema type is `string` and format is `binary`
This commit is contained in:
Vishal Shingala
2021-10-11 12:38:28 +05:30
committed by GitHub
4 changed files with 43 additions and 16 deletions

View File

@@ -1701,6 +1701,7 @@ module.exports = {
var contentObj, // content is required
bodyData,
param,
originalParam,
paramArray = [],
updateOptions = {},
reqBody = new sdk.RequestBody(),
@@ -1832,11 +1833,27 @@ module.exports = {
}
}
param = new sdk.FormParam({
key: key,
value: value,
type: 'text'
});
// Fetch the original param and if it is of type 'string' and format 'binary'
// then set the type of FormParam to 'file'
originalParam = _.get(contentObj[FORM_DATA], ['schema', 'properties', key]);
if (originalParam &&
originalParam.type === 'string' &&
originalParam.format === 'binary'
) {
param = new sdk.FormParam({
key: key,
value: '',
type: 'file'
});
}
else {
param = new sdk.FormParam({
key: key,
value: value,
type: 'text'
});
}
param.description = description;
paramArray.push(param);
});