Skip to content

Commit b295ad0

Browse files
author
Ankit Saini
authored
Merge branch 'develop' into snyk-upgrade-96cfb2f8738592e158bfbb54017de21f
2 parents f8951e6 + a2d32ed commit b295ad0

File tree

14 files changed

+799
-156
lines changed

14 files changed

+799
-156
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"node": true,
99
"es6": true
1010
},
11+
"parserOptions": {
12+
"ecmaVersion": 2018
13+
},
1114
"rules": {
1215
// Possible Errors
1316
"for-direction": "error",

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ typings/
6767
out/
6868

6969
newmanResponses.json
70-
dummyFile*.txt
70+
dummyFile*.txt
71+
dummyBinaryFile

codegens/curl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Convert function takes three parameters
1818
* `indentCount` - The number of indentation characters to add per code level
1919
* `trimRequestBody` - Trim request body fields
2020
* `followRedirect` - Boolean denoting whether to redirect a request
21-
* `requestTimeout` - Integer denoting time after which the request will bail out in milli-seconds
21+
* `requestTimeoutInSeconds` - Integer denoting time after which the request will bail out in seconds
2222
* `multiLine` - Boolean denoting whether to output code snippet with multi line breaks
2323
* `longFormat` - Boolean denoting whether to use longform cURL options in snippet
2424
* `quoteType` - String denoting the quote type to use (single or double) for URL

codegens/curl/lib/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ self = module.exports = {
1818
format, snippet, silent, url, quoteType;
1919

2020
redirect = options.followRedirect;
21-
timeout = options.requestTimeout;
21+
timeout = options.requestTimeoutInSeconds;
2222
multiLine = options.multiLine;
2323
format = options.longFormat;
2424
trim = options.trimRequestBody;
@@ -222,11 +222,11 @@ self = module.exports = {
222222
'(Use double quotes when running curl in cmd.exe and single quotes for the rest)'
223223
},
224224
{
225-
name: 'Set request timeout',
226-
id: 'requestTimeout',
225+
name: 'Set request timeout (in seconds)',
226+
id: 'requestTimeoutInSeconds',
227227
type: 'positiveInteger',
228228
default: 0,
229-
description: 'Set number of milliseconds the request should wait for a response before ' +
229+
description: 'Set number of seconds the request should wait for a response before ' +
230230
'timing out (use 0 for infinity)'
231231
},
232232
{

codegens/curl/lib/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var self = module.exports = {
55
*
66
* @param {String} inputString
77
* @param {Boolean} [trim] - indicates whether to trim string or not
8-
* @param {Boolean} [quoteType] - indicates which quoteType has to be escaped
8+
* @param {String} [quoteType] - indicates which quoteType has to be escaped
99
* @param {Boolean} [backSlash] - indicates whether to escape backslash(\\)
1010
* @returns {String}
1111
*/
@@ -20,6 +20,8 @@ var self = module.exports = {
2020

2121
if (quoteType === '"') {
2222
inputString = inputString.replace(/"/g, '\\"');
23+
// Escape backslash if double quote was already escaped before call to sanitize
24+
inputString = inputString.replace(/(?<!\\)\\\\"/g, '\\\\\\"');
2325
}
2426
else if (quoteType === '\'') {
2527
// for curl escaping of single quotes inside single quotes involves changing of ' to '\''

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

codegens/java-okhttp/lib/okhttp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var _ = require('./lodash'),
66
sanitizeOptions = require('./util').sanitizeOptions;
77

88
// Since Java OkHttp requires to add extralines of code to handle methods with body
9-
const METHODS_WITHOUT_BODY = ['GET', 'HEAD', 'COPY', 'UNLOCK', 'UNLINK', 'PURGE', 'LINK', 'VIEW'];
9+
const METHODS_WITHOUT_BODY = ['HEAD', 'COPY', 'UNLOCK', 'UNLINK', 'PURGE', 'LINK', 'VIEW'];
1010

1111
/**
1212
* returns snippet of java okhttp by parsing data from Postman-SDK request object

codegens/js-fetch/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"dependencies": {},
3030
"devDependencies": {
3131
"form-data": "2.5.1",
32-
"node-fetch": "2.6.1"
32+
"node-fetch": "2.6.7"
3333
},
3434
"engines": {
3535
"node": ">=8"

codegens/nodejs-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"postman-collection": "3.6.11"
3131
},
3232
"devDependencies": {
33-
"follow-redirects": "1.13.3"
33+
"follow-redirects": "1.14.9"
3434
},
3535
"engines": {
3636
"node": ">=8"

npm/ci-requirements.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pushd ./codegens/csharp-restsharp &>/dev/null;
2424
sudo apt-get install dotnet-sdk-2.2
2525
dotnet new console -o testProject
2626
pushd ./testProject &>/dev/null;
27-
dotnet add package RestSharp
27+
dotnet add package RestSharp --version 106.15.0
2828
popd &>/dev/null;
2929
popd &>/dev/null;
3030

0 commit comments

Comments
 (0)