diff --git a/codegens/curl/lib/index.js b/codegens/curl/lib/index.js index 8abc73df6..d55ad5550 100644 --- a/codegens/curl/lib/index.js +++ b/codegens/curl/lib/index.js @@ -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: diff --git a/codegens/curl/test/unit/convert.test.js b/codegens/curl/test/unit/convert.test.js index 849395a5e..ae2111acc 100644 --- a/codegens/curl/test/unit/convert.test.js +++ b/codegens/curl/test/unit/convert.test.js @@ -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\''); + }); + }); }); }); diff --git a/codegens/python-http.client/test/unit/converter.test.js b/codegens/python-http.client/test/unit/converter.test.js index 459aa428d..b409c31e6 100644 --- a/codegens/python-http.client/test/unit/converter.test.js +++ b/codegens/python-http.client/test/unit/converter.test.js @@ -337,7 +337,7 @@ describe('Python-http.client converter', function () { }); it('should generate valid snippets when url uses http protocol', function () { - var request = new sdk.Request({ + var request = new Request({ 'method': 'GET', 'header': [], 'url': {