Skip to content

Commit

Permalink
Added support for usage of --data-binary flag when using long format …
Browse files Browse the repository at this point in the history
…option for body typr binary
  • Loading branch information
VShingala committed Sep 30, 2024
1 parent 3494492 commit 2ffde7a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion codegens/curl/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ self = module.exports = {
});
break;
case 'file':
snippet += indent + form('-d', format);
snippet += indent + (format ? '--data-binary' : '-d');
snippet += ` ${quoteType}@${sanitize(body[body.mode].src, trim)}${quoteType}`;
break;
default:
Expand Down
32 changes: 32 additions & 0 deletions codegens/curl/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,5 +1144,37 @@ describe('curl convert function', function () {
});
});
});

it('should use --data-binary when request body type is binary', function () {
var request = new Request({
'method': 'POST',
'header': [],
'body': {
'mode': 'file',
'file': {
'src': 'file-path/collection123.json'
}
},
'url': {
'raw': 'https://postman-echo.com/get',
'protocol': 'https',
'host': [
'postman-echo',
'com'
],
'path': [
'get'
]
}
});

convert(request, { longFormat: true }, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}
expect(snippet).to.be.a('string');
expect(snippet).to.include('--data-binary \'@file-path/collection123.json\'');
});
});
});
});

0 comments on commit 2ffde7a

Please sign in to comment.