Skip to content

Commit

Permalink
Release v1.5.0
Browse files Browse the repository at this point in the history
Release v1.5.0
  • Loading branch information
Ankit Saini authored Mar 2, 2023
2 parents 397aa0a + b7853e2 commit 40fbece
Show file tree
Hide file tree
Showing 23 changed files with 368 additions and 663 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
"object-curly-newline": "off",
"object-curly-spacing": "off",
"object-property-newline": "off",
"one-var": ["error", "always"],
"one-var": ["error", "consecutive"],
"one-var-declaration-per-line": "error",
"operator-assignment": "error",
"operator-linebreak": ["error", "after"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Node JS
uses: actions/setup-node@v1
with:
node-version: '8.x'
node-version: '12.x'
- name: Install system dependencies
run: npm run cirequirements
- name: Install package dependencies
Expand Down
65 changes: 38 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
v1.5.0 (March 2, 2023)
* Change minimum supported NodeJS version to 12
* Fix for - [#11049](https://github.com/postmanlabs/postman-app-support/issues/11049) Escape backslash character in raw bodies for curl codegen
* Fix for - [#302](https://github.com/postmanlabs/postman-code-generators/issues/302) Add option to use async/await in NodeJS Axios codegen
* Fix for - [#322](https://github.com/postmanlabs/postman-code-generators/issues/322) Use multiline quotes in Powershell to simplify generated code
* Add long form option for -g flag in curl codegen
* Minor Swift codegen improvements

v1.4.1 (February 22, 2023)
* cURL codegen should work when request has a protocolProfileBehavior with null value

v1.4.0 (February 6, 2023)
* Add support for C# HttpClient Codegen
* Use short options in CURL as long as possible (9511)[https://github.com/postmanlabs/postman-app-support/issues/9511]
* Do not add HTTP method explicitly in CURL when not required (10581)[https://github.com/postmanlabs/postman-app-support/issues/10581]
* Remove usage of semaphore from Swift Codegen (10053)[https://github.com/postmanlabs/postman-app-support/issues/10053]
* Fix for - [#9511](https://github.com/postmanlabs/postman-app-support/issues/9511) - Use short options in CURL as long as possible
* Fix for - [#10581](https://github.com/postmanlabs/postman-app-support/issues/10581) - Do not add HTTP method explicitly in CURL when not required
* Fix for - [#10053](https://github.com/postmanlabs/postman-app-support/issues/10053) - Remove usage of semaphore from Swift Codegen

v1.3.0 (December 16, 2022)
* Update C# restsharp codegen to support (107)[https://restsharp.dev/v107/]
* Fixes an issue where HTTP code snippet was generating wrong boundaries (11084)[https://github.com/postmanlabs/postman-app-support/issues/11084]
* Update C# restsharp codegen to support [107](https://restsharp.dev/v107/)
* Fix for - [#11084](https://github.com/postmanlabs/postman-app-support/issues/11084) Fixes an issue where HTTP code snippet was generating wrong boundaries
* Fixes an issue with Axios code snippets not including maxBodyLength param

v1.2.1 (April 26, 2022)
Expand All @@ -15,8 +26,8 @@ v1.2.1 (April 26, 2022)
v1.2.0 (April 22, 2022)
* Add new codegens - php-guzzle, R-httr, R-rcurl
* Fix issue with pipeline failing due to updated version of RestSharp
* Fix for - [502](https://github.com/postmanlabs/postman-code-generators/issues/502) Allow GET method to have a body in java-okhttp if present in input request
* Fix for - [476](https://github.com/postmanlabs/postman-code-generators/pull/476) Properly escape already escaped double quotes in curl body
* Fix for - [#502](https://github.com/postmanlabs/postman-code-generators/issues/502) Allow GET method to have a body in java-okhttp if present in input request
* Fix for - [#476](https://github.com/postmanlabs/postman-code-generators/pull/476) Properly escape already escaped double quotes in curl body

v1.1.5 (May 10, 2021)
* Fixed an issue with how JSON bodies are shown in code snippets for Ruby, C#, and Dart.
Expand All @@ -26,15 +37,15 @@ v1.1.4 (May 6, 2021)

v1.1.3 (Mar 2, 2021)
* Use proper indentation for JSON bodies in Javascript and Nodejs codegens
* Fix for - [445](https://github.com/postmanlabs/postman-code-generators/issues/445) Add proper indentation in nodejs-axios when bodytype is urlencoded
* Fix for - [248](https://github.com/postmanlabs/postman-code-generators/issues/248) Use quoteType everywhere in curl, not just in the url
* Fix for - [454](https://github.com/postmanlabs/postman-code-generators/issues/454) Fix encoding when generating HTTP code snippets
* Fix for - [426](https://github.com/postmanlabs/postman-code-generators/issues/426) Use json.dumps in Python codegens if Content-Type is JSON
* Fix for - [#445](https://github.com/postmanlabs/postman-code-generators/issues/445) Add proper indentation in nodejs-axios when bodytype is urlencoded
* Fix for - [#248](https://github.com/postmanlabs/postman-code-generators/issues/248) Use quoteType everywhere in curl, not just in the url
* Fix for - [#454](https://github.com/postmanlabs/postman-code-generators/issues/454) Fix encoding when generating HTTP code snippets
* Fix for - [#426](https://github.com/postmanlabs/postman-code-generators/issues/426) Use json.dumps in Python codegens if Content-Type is JSON

v1.1.2 (Dec 15, 2020)
* Fix for - [8736](https://github.com/postmanlabs/postman-app-support/issues/8736) Add content type support for individual form-data fields
* Fix for - [8635](https://github.com/postmanlabs/postman-app-support/issues/8635) Use Json.parse for all json like application types
* Fix for - [9212](https://github.com/postmanlabs/postman-app-support/issues/9212) Add semicolon after header key in curl codegen if the value is empty string.
* Fix for - [#8736](https://github.com/postmanlabs/postman-app-support/issues/8736) Add content type support for individual form-data fields
* Fix for - [#8635](https://github.com/postmanlabs/postman-app-support/issues/8635) Use Json.parse for all json like application types
* Fix for - [#9212](https://github.com/postmanlabs/postman-app-support/issues/9212) Add semicolon after header key in curl codegen if the value is empty string.
* Add Newman test for powershell

v1.1.1 (Nov 10, 2020)
Expand All @@ -44,19 +55,19 @@ v1.1.1 (Nov 10, 2020)

v1.1.0 (Nov 2, 2020)
* Added support for Dart http
* Fix for - [315](https://github.com/postmanlabs/postman-code-generators/issues/315): Manually parse url provided in the request.
* Fix for - [253](https://github.com/postmanlabs/postman-code-generators/issues/253): Add -g flag to curl if braces ({}) or brackets ([]) are present in the url.
* Fix for - [257](https://github.com/postmanlabs/postman-code-generators/issues/257): Use double quotes to escape semicolon in curl requests
* Fix for - [247](https://github.com/postmanlabs/postman-code-generators/issues/247): Add ContentType to python snippets for multipart/formdata
* Fix for - [186](https://github.com/postmanlabs/postman-code-generators/issues/186): Add ` as line continuation delimiter for curl codegen
* Fix for - [248](https://github.com/postmanlabs/postman-code-generators/issues/248): Add quoteType as an additional option in curl codegen
* Fix for - [#315](https://github.com/postmanlabs/postman-code-generators/issues/315): Manually parse url provided in the request.
* Fix for - [#253](https://github.com/postmanlabs/postman-code-generators/issues/253): Add -g flag to curl if braces ({}) or brackets ([#]) are present in the url.
* Fix for - [#257](https://github.com/postmanlabs/postman-code-generators/issues/257): Use double quotes to escape semicolon in curl requests
* Fix for - [#247](https://github.com/postmanlabs/postman-code-generators/issues/247): Add ContentType to python snippets for multipart/formdata
* Fix for - [#186](https://github.com/postmanlabs/postman-code-generators/issues/186): Add ` as line continuation delimiter for curl codegen
* Fix for - [#248](https://github.com/postmanlabs/postman-code-generators/issues/248): Add quoteType as an additional option in curl codegen
* Fix deadlock in error case in Swift and Objective-C codegens.
* Fix for - [325](https://github.com/postmanlabs/postman-code-generators/issues/325): Use encodeURIComponent instead of escape for urlencoded request body.
* Fix for - [350](https://github.com/postmanlabs/postman-code-generators/issues/350): Sanitize \r in request body.
* Fix for - [366](https://github.com/postmanlabs/postman-code-generators/issues/366): Add support for uploading binary files for multipart/form-data bodies in python-http.client.
* Fix for - [353](https://github.com/postmanlabs/postman-code-generators/issues/353): Add optional import of FoundationNetworking in swift codegen
* Fix for - [284](https://github.com/postmanlabs/postman-code-generators/issues/284): Replace double-quotes by single-quotes in codegen/php-curl
* Fix for - [330](https://github.com/postmanlabs/postman-code-generators/issues/330): Use url.toString method for converting url in shell-httpie codegen
* Fix for - [#325](https://github.com/postmanlabs/postman-code-generators/issues/325): Use encodeURIComponent instead of escape for urlencoded request body.
* Fix for - [#350](https://github.com/postmanlabs/postman-code-generators/issues/350): Sanitize \r in request body.
* Fix for - [#366](https://github.com/postmanlabs/postman-code-generators/issues/366): Add support for uploading binary files for multipart/form-data bodies in python-http.client.
* Fix for - [#353](https://github.com/postmanlabs/postman-code-generators/issues/353): Add optional import of FoundationNetworking in swift codegen
* Fix for - [#284](https://github.com/postmanlabs/postman-code-generators/issues/284): Replace double-quotes by single-quotes in codegen/php-curl
* Fix for - [#330](https://github.com/postmanlabs/postman-code-generators/issues/330): Use url.toString method for converting url in shell-httpie codegen

v1.0.2 (Oct 15, 2020)
* Fixed spaces around variables and arguments in Python codgen to comply with PEP 8.
Expand All @@ -67,7 +78,7 @@ v1.0.2 (Oct 15, 2020)
* Fixed wrong name of HTTP codegen in README

v1.0.1 (Jun 29, 2020)
- Fix for - [8674](https://github.com/postmanlabs/postman-app-support/issues/8674): Add URL sanitization for quotes in cURL, Java Unirest, NodeJS Native, Python http.client, and Swift.
- Fix for - [#8674](https://github.com/postmanlabs/postman-app-support/issues/8674): Add URL sanitization for quotes in cURL, Java Unirest, NodeJS Native, Python http.client, and Swift.

v1.0.0 (May 29, 2020)
- Add axios framework support
Expand Down
4 changes: 2 additions & 2 deletions codegens/curl/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ self = module.exports = {
snippet += ` ${form('-m', format)} ${timeout}`;
}
if ((url.match(/[{[}\]]/g) || []).length > 0) {
snippet += ' -g';
snippet += ` ${form('-g', format)}`;
}
if (multiLine) {
indent = options.indentType === 'Tab' ? '\t' : ' ';
Expand Down Expand Up @@ -141,7 +141,7 @@ self = module.exports = {
isAsperandPresent = _.includes(rawBody, '@'),
// Use the long option if `@` is present in the request body otherwise follow user setting
optionName = isAsperandPresent ? '--data-raw' : form('-d', format);
snippet += indent + `${optionName} ${quoteType}${sanitize(rawBody, trim, quoteType)}${quoteType}`;
snippet += indent + `${optionName} ${quoteType}${sanitize(rawBody, trim, quoteType, true)}${quoteType}`;
break;
}

Expand Down
17 changes: 13 additions & 4 deletions codegens/curl/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ var self = module.exports = {
return '--data';
case '-F':
return '--form';
case '-g':
return '--globoff';
default:
return '';
}
Expand Down Expand Up @@ -292,12 +294,19 @@ var self = module.exports = {
* @returns {Boolean}
*/
shouldAddHttpMethod: function (request, options) {
const followRedirect = _.get(request, 'protocolProfileBehavior.followRedirects', options.followRedirect),
followOriginalHttpMethod =
_.get(request, 'protocolProfileBehavior.followOriginalHttpMethod', options.followOriginalHttpMethod),
disableBodyPruning = _.get(request, 'protocolProfileBehavior.disableBodyPruning', true),
let followRedirect = options.followRedirect,
followOriginalHttpMethod = options.followOriginalHttpMethod,
disableBodyPruning = true,
isBodyEmpty = self.isBodyEmpty(request.body);

// eslint-disable-next-line lodash/prefer-is-nil
if (request.protocolProfileBehavior !== null && request.protocolProfileBehavior !== undefined) {
followRedirect = _.get(request, 'protocolProfileBehavior.followRedirects', followRedirect);
followOriginalHttpMethod =
_.get(request, 'protocolProfileBehavior.followOriginalHttpMethod', followOriginalHttpMethod);
disableBodyPruning = _.get(request, 'protocolProfileBehavior.disableBodyPruning', true);
}

if (followRedirect && followOriginalHttpMethod) {
return true;
}
Expand Down
79 changes: 78 additions & 1 deletion codegens/curl/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@ describe('curl convert function', function () {
});
});

it('should escape backslash in raw bodies', function () {
request = new sdk.Request({
'method': 'POST',
'header': [
{
'key': 'Content-Type',
'value': 'application/json'
}
],
'body': {
'mode': 'raw',
'raw': '{ "foo": "\\" }'
},
'url': {
'raw': 'https://postman-echo.com/post',
'protocol': 'https',
'host': [
'postman-echo',
'com'
],
'path': [
'post'
]
}
});

convert(request, {}, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}

expect(snippet).to.contain('{ "foo": "\\\\" }');
});
});

it('should return snippet with url in single quote(\')', function () {
request = new sdk.Request({
'method': 'POST',
Expand Down Expand Up @@ -230,7 +265,7 @@ describe('curl convert function', function () {
']world',
'world}'
].forEach(function (value) {
request = new sdk.Request({
const request = new sdk.Request({
'method': 'GET',
'url': {
'raw': `http://example.com?hello=${value}`,
Expand All @@ -253,6 +288,12 @@ describe('curl convert function', function () {
}
expect(snippet).to.include('-g');
});
convert(request, { longFormat: true }, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}
expect(snippet).to.include('--globoff');
});
});
});

Expand Down Expand Up @@ -941,6 +982,42 @@ describe('curl convert function', function () {
expect(snippet).to.not.include('--request POST');
});
});

it('should work when protocolProfileBehavior is null in request settings', function () {
const request = new sdk.Request({
'method': 'POST',
'header': [],
'body': {
'mode': 'graphql',
'graphql': {
'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
'variables': '{\n\t"variable_key": "variable_value"\n}'
}
},
'url': {
'raw': 'https://postman-echo.com/post',
'protocol': 'https',
'host': [
'postman-echo',
'com'
],
'path': [
'post'
]
}
});

// this needs to be done here because protocolProfileBehavior is not in collections SDK
request.protocolProfileBehavior = null;

convert(request, { followRedirect: true, followOriginalHttpMethod: true }, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}
expect(snippet).to.be.a('string');
expect(snippet).to.include('--request POST');
});
});
});
});
});
3 changes: 2 additions & 1 deletion codegens/nodejs-axios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Convert function will take three parameters
* `requestTimeout` : Integer denoting time after which the request will bail out in milli-seconds
* `trimRequestBody` : Trim request body fields
* `followRedirect` : Boolean denoting whether to redirect a request
* `asyncAwaitEnabled` : Boolean denoting whether to use async/await syntax

* `callback`- callback function with first parameter as error and second parameter as string for code snippet

Expand All @@ -27,7 +28,7 @@ var request = new sdk.Request('www.google.com'), //using postman sdk to create
options = {
indentType: 'Space',
indentCount: 2,
ES6_enabled: true
asyncAwaitEnabled: true
};
convert(request, options, function(error, snippet) {
if (error) {
Expand Down
Loading

0 comments on commit 40fbece

Please sign in to comment.