Skip to content

Commit 26630a1

Browse files
committed
Fix failing newman test, add unit test
1 parent d3b0d95 commit 26630a1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

codegens/curl/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ self = module.exports = {
7676
// If the header value is an empty string then add a semicolon after key
7777
// otherwise the header would be ignored by curl
7878
if (header.value) {
79-
snippet += `: ${sanitize(header.value, false, quoteType, true)}${quoteType}`;
79+
snippet += `: ${sanitize(header.value, false, quoteType)}${quoteType}`;
8080
}
8181
else {
8282
snippet += ';' + quoteType;

codegens/curl/test/unit/convert.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,38 @@ describe('curl convert function', function () {
499499
});
500500
});
501501

502+
it('should not add appropriate escaping characters when quote type is "double"', function () {
503+
var request = new sdk.Request({
504+
'method': 'POST',
505+
'header': [],
506+
'body': {
507+
'mode': 'graphql',
508+
'graphql': {
509+
'query': '{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: "performers"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}', // eslint-disable-line
510+
'variables': '{\n\t"variable_key": "variable_value"\n}'
511+
}
512+
},
513+
'url': {
514+
'raw': 'https://postman-echo.com/post',
515+
'protocol': 'https',
516+
'host': [
517+
'postman-echo',
518+
'com'
519+
],
520+
'path': [
521+
'post'
522+
]
523+
}
524+
});
525+
convert(request, { quoteType: 'double', lineContinuationCharacter: '^' }, function (error, snippet) {
526+
if (error) {
527+
expect.fail(null, null, error);
528+
}
529+
530+
expect(snippet).to.include('{\\"query\\":\\"{\\n findScenes(\\n filter: {per_page: 0}\\n scene_filter: {is_missing: \\\\\\"performers\\\\\\"})'); // eslint-disable-line
531+
});
532+
});
533+
502534
describe('getUrlStringfromUrlObject function', function () {
503535
var rawUrl, urlObject, outputUrlString;
504536

0 commit comments

Comments
 (0)