Skip to content

Release 1.0.0 #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 71 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
6283cb9
ignore unused `resp` variable on line 392
idkjs Jan 24, 2020
989cdec
Added ES6 feature support to NodeJS-Request codegen
sastava007 Feb 27, 2020
65757af
Reduced code repitition
sastava007 Mar 1, 2020
d460aaa
Fix maven issues while downloading java dependencies (#171)
umeshp7 Mar 1, 2020
80ec51b
Added PR template (#183)
sastava007 Mar 2, 2020
06dd1d1
Merge pull request #154 from idkjs/patch-1
umeshp7 Mar 2, 2020
6af97a7
Move test file creation step from ci-requirements script to test scri…
shreys7 Mar 2, 2020
33c3e16
Added newman test to verify snippet generated is runnable
sastava007 Mar 2, 2020
5970d80
Fix csharp-restsharp user agent header issue (#170)
ttzztztz Mar 2, 2020
d0e40c2
Merge pull request #180 from sastava007/ES6-Feature-Support
shreys7 Mar 3, 2020
ccc7db2
Refactored global namespase import for shelljs in boilerplate and ref…
nikhilmuz Mar 4, 2020
666d65b
Fixed typo
nikhilmuz Mar 4, 2020
9efa5d2
Added ES6 feature support to NodeJS-Native codegen
sastava007 Mar 4, 2020
25467a6
Added ES6 feature support to NodeJS Unirest codegen
sastava007 Mar 4, 2020
a311f34
Added unit test for .end arrow function
sastava007 Mar 9, 2020
4ed94b1
Added more unit tests and reduced redundancy in code
sastava007 Mar 9, 2020
92d62fe
Fixed lint testing issue
nikhilmuz Mar 11, 2020
0b514e1
Merge pull request #197 from sastava007/ES6-NodeJS-Unirest
shreys7 Mar 11, 2020
d6c3701
Merge pull request #196 from sastava007/ES6-NodeJS-Native
shreys7 Mar 11, 2020
caf1250
fix: upgrade form-data from 2.3.2 to 2.5.1
snyk-bot Mar 15, 2020
52861a9
Fixes #193
nikhilmuz Mar 16, 2020
40b5d5c
fix typos
liyingxiu Mar 17, 2020
db6b4ec
Add: Eslint in root files/folders (#177)
vibhorgupta-gh Mar 17, 2020
ba3ad6a
Merge pull request #218 from liyingxiu/typo-fix
umeshp7 Mar 17, 2020
60f65c4
Merge pull request #195 from nikhilmuz/issue-193
shreys7 Mar 19, 2020
9fee7bb
Fixed example code and removed typos throughout the repo
sastava007 Mar 19, 2020
d691208
Merge pull request #223 from sastava007/fix/typo
shreys7 Mar 20, 2020
e62a295
Merge pull request #217 from postmanlabs/snyk-upgrade-307131a085de23d…
umeshp7 Mar 23, 2020
72dd928
Converted package.sh and zip.sh to Javascript files. (#219)
sastava007 Mar 26, 2020
fa8265a
README typo fix
ajwad-shaikh Mar 30, 2020
7c72bfa
Added recently supported language variants
ajwad-shaikh Mar 31, 2020
ad51688
Merge pull request #234 from ajwad-shaikh/readme-todo
shreys7 Apr 16, 2020
f2d40e8
feat(nodejs-axios): Added nodejs axios code generation
Mar 29, 2020
9cdcaad
updates readme
r3dsm0k3 Mar 29, 2020
acf7c92
better formatting for the header object in the generated snippet
r3dsm0k3 May 6, 2020
68bbf2e
reverts unrelated changes.
r3dsm0k3 May 7, 2020
ff7e37a
Skip java okhttp redirect tests for now to unblock contributions
shreys7 May 8, 2020
9d0cae0
Add x-amzn-trace-id header for skipping during newman tests
shreys7 May 8, 2020
48b657a
Skip curl newman tests for now
shreys7 May 14, 2020
469c69a
Changing DELETE request from postman-echo to mockbin
shreys7 May 18, 2020
5ca3f84
Skip java okhttp and unskip curl newman tests
shreys7 May 20, 2020
d61659d
Change protocol from http to https for postman-echo request(POST grap…
shreys7 May 20, 2020
fc4b1e8
Add handling for graphql and binary files for the https case URLs in …
shreys7 May 20, 2020
d5beaa3
Fix https protocol handling for shell-httpie
shreys7 May 21, 2020
5b80ed1
Merge pull request #246 from postmanlabs/feature/skip-redirect-test-j…
shreys7 May 21, 2020
431764d
Fix snippet generation for js-jquery for formdata params with no type…
shreys7 May 20, 2020
47426e8
Fix snippet generation for powershell for formdata params with no typ…
shreys7 May 20, 2020
9643a53
Remove console.log from jquery
shreys7 May 21, 2020
1aeaa79
Merge pull request #252 from postmanlabs/feauture/fix-type-absent-for…
shreys7 May 21, 2020
a54e54e
Removes unwanted commented code and additional options
someshkoli May 21, 2020
d12d44e
Merge branch 'develop' of https://github.com/r3dsm0k3/postman-code-ge…
someshkoli May 21, 2020
607c245
Adds ES6_ENABLE option to nodejs-axios codegen
someshkoli May 21, 2020
9897296
Adds `transfer-encoding` to headers to delete
someshkoli May 22, 2020
93ff66f
Snippet sanitization
someshkoli May 22, 2020
79127b6
Snippet Sanitization
someshkoli May 23, 2020
2e3ad20
Snippet sanitization(1)
someshkoli May 23, 2020
7f3561e
Snippet sanitization(2)
someshkoli May 23, 2020
593a716
reverts the collection to the develop branch
r3dsm0k3 May 25, 2020
53c4964
adds dummy file to the ignore list
r3dsm0k3 May 25, 2020
31e5c35
Merge pull request #232 from r3dsm0k3/feat/axios-nodejs
shreys7 May 25, 2020
2eb7700
Correct indentation of headers, add a new line after config declaration
shreys7 May 25, 2020
bf399e6
Remove unwanted comments
shreys7 May 25, 2020
9afeec9
Merge pull request #255 from postmanlabs/feature/fix-axios
shreys7 May 26, 2020
6fefffc
updates readme to include axios
r3dsm0k3 May 26, 2020
931a9e3
Merge pull request #256 from r3dsm0k3/fix/readme
shreys7 May 26, 2020
dde834a
1.0.0
shreys7 May 29, 2020
f825027
Add changelog file
shreys7 May 29, 2020
52b4ce8
Add ES6 syntax addition to changelog
shreys7 May 29, 2020
479c46e
Fix ES6 handling in Axios
shreys7 May 29, 2020
def58d7
Merge pull request #263 from postmanlabs/feature/fix-axios-ES6-option
umeshp7 May 30, 2020
736ab6b
Merge branch 'develop' into release/v1.0.0
shreys7 May 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/Pull_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**What this PR does**
<< Please describe briefly what this PR is trying to solve >>

**Changes you made**
<< List all the changes you made >>

**Screenshot/ CodeSnippet**
<< Attach relevant screenshots or code snippets related to this PR >>

**Test Configuration**:
<< Please describe the tests that you ran to verify your changes >>

**Follow up**
<< Anything you want to share >>



*Thanks for contributing!* ❤️
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ typings/

out/

newmanResponses.json
newmanResponses.json
dummyFile*.txt
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
v1.0.0 (May 29, 2020)
- Add axios framework support
- Add ES6 syntax support for NodeJS Request, NodeJS Native and NodeJS Unirest
- Fix snippet generation for powershell and jquery, where form data params had no type field
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- [Pull request guidelines](#pull-request-guidelines)
- [Tests](#tests)
- [Build Failures](build-failures)
- [Security guildelines](security-guidelines)
- [Security guidelines](security-guidelines)

## Getting Started Quick

Expand All @@ -33,7 +33,7 @@ Installs all `dependencies` of all the codegens. This runs the command `npm inst
The script associated with `npm test` will run all tests that ensures that your commit does not break anything in the
repository. Additional requirements to run these tests have been listed down in [ADDITIONAL_DEPENDENCIES](/ADDITIONAL_DEPENDENCIES.md)

* `npm test`: Runs strucutre, unit, newman and system tests for all codegens
* `npm test`: Runs structure, unit, newman and system tests for all codegens
* `npm run test <codegen-name>`: Runs tests for a particular codegen.


Expand Down Expand Up @@ -86,7 +86,7 @@ One of the following two contributions are possible for postman-code-generators:
- All pull requests should be to the develop branch.
- Every pull request should have associated issue(s) on our [issue tracker](https://github.com/postmanlabs/postman-code-generators/issues).
- For any non-trivial fixes, regression tests should be added as well. For a bug, we also recommend adding a request to the `testCollection.json` found inside `test/codegen/newman/fixtures` to run the request using common newman tests.
- For a new language to be added as a part of postman-code-generators, we will need some level of community support before we are able to accept the pull request. Feel free to add links to any sort of report/statistics from trusted sources that might help us understand the relavance and popularity of this language among users.
- For a new language to be added as a part of postman-code-generators, we will need some level of community support before we are able to accept the pull request. Feel free to add links to any sort of report/statistics from trusted sources that might help us understand the relevance and popularity of this language among users.


## Tests
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ List of supported code generators:

| Language | Variant |
|-----------|---------------|
| C | libcurl |
| C# | RestSharp |
| cURL | cURL |
| Go | Native |
Expand All @@ -25,7 +26,8 @@ List of supported code generators:
| Java | Unirest |
| JavaScript | Fetch |
| JavaScript | jQuery |
| JavaScript | XHR |
| JavaScript | XHR |
| NodeJs | Axios |
| NodeJs | Native |
| NodeJs | Request |
| NodeJs | Unirest |
Expand All @@ -35,6 +37,8 @@ List of supported code generators:
|PHP | pecl_http |
|PHP | HTTP_Request2 |
| PowerShell | RestMethod |
| Python | http.client |
| Python | Requests |
| Ruby | Net:HTTP |
| Shell | Httpie |
| Shell | wget |
Expand Down Expand Up @@ -104,7 +108,7 @@ var codegen = require('postman-code-generators'), // require postman-code-genera

This function takes in three parameters and returns a callback with error and supported options of that code generator.

* `language` - langugage key from the language list returned from getLanguageList function
* `language` - language key from the language list returned from getLanguageList function
* `variant` - variant key provided by getLanguageList function
* `callback` - callback function with first parameter as error and second parameter as array of options supported by the codegen.

Expand Down Expand Up @@ -153,15 +157,16 @@ This function takes in five parameters and returns a callback with error and gen
* `language` - lang key from the language list returned from getLanguageList function
* `variant` - variant key provided by getLanguageList function
* `request` - [Postman-SDK](https://github.com/postmanlabs/postman-collection) Request Object
* `options` - Options that can be used to configure generated code snippet. Defaults will be used for the
* `options` - Options that can be used to configure generated code snippet. Defaults will be used for the unspecified attributes
* `callback` - callback function with first parameter as error and second parameter as string for code snippet

##### Example:
```js
var codegen = require('postman-code-generators'), // require postman-code-generators in your project
request = new sdk.Request('www.google.com'), //using postman sdk to create request
sdk = require('postman-collection'), // require postman-collection in your project
request = new sdk.Request('https://www.google.com'), //using postman sdk to create request
language = 'nodejs',
variant = 'requests',
variant = 'request',
options = {
indentCount: 3,
indentType: 'Space',
Expand Down
9 changes: 7 additions & 2 deletions codegens/csharp-restsharp/lib/parseRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function parseBody (request, trimFields) {
/**
* Parses header in Postman-SDK request and returns code snippet of csharp-restsharp for adding headers
*
* @param {Object} requestJson - Postman SDK reqeust object
* @param {Object} requestJson - Postman SDK request object
* @returns {String} code snippet for adding headers in csharp-restsharp
*/
function parseHeader (requestJson) {
Expand All @@ -106,7 +106,12 @@ function parseHeader (requestJson) {

return requestJson.header.reduce((headerSnippet, header) => {
if (!header.disabled) {
headerSnippet += `request.AddHeader("${sanitize(header.key, true)}", "${sanitize(header.value)}");\n`;
if (sanitize(header.key, true).toLowerCase() === 'user-agent') {
headerSnippet += `client.UserAgent = "${sanitize(header.value)}";\n`;
}
else {
headerSnippet += `request.AddHeader("${sanitize(header.key, true)}", "${sanitize(header.value)}");\n`;
}
}
return headerSnippet;
}, '');
Expand Down
2 changes: 1 addition & 1 deletion codegens/csharp-restsharp/lib/restsharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ self = module.exports = {
* @param {String} options.indentType - type for indentation eg: Space, Tab (default: Space)
* @param {String} options.indentCount - number of spaces or tabs for indentation. (default: 4 for indentType:
Space, default: 1 for indentType: Tab)
* @param {Boolean} [options.includeBoilerplate] - indicates whether to include class defination in C#
* @param {Boolean} [options.includeBoilerplate] - indicates whether to include class definition in C#
* @param {Boolean} options.followRedirect - whether to enable followredirect
* @param {Boolean} options.trimRequestBody - whether to trim fields in request body or not (default: false)
* @param {Number} options.requestTimeout - time in milli-seconds after which request will bail out
Expand Down
7 changes: 3 additions & 4 deletions codegens/csharp-restsharp/npm/test-lint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
require('shelljs/global');

var chalk = require('chalk'),
var shell = require('shelljs'),
chalk = require('chalk'),
async = require('async'),
ESLintCLIEngine = require('eslint').CLIEngine,

Expand Down Expand Up @@ -56,4 +55,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
12 changes: 6 additions & 6 deletions codegens/csharp-restsharp/npm/test-newman.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// This script is intended to execute all newman tests.
// ---------------------------------------------------------------------------------------------------------------------

require('shelljs/global');
var shell = require('shelljs'),

// set directories and files for test and coverage report
var path = require('path'),
// set directories and files for test and coverage report
path = require('path'),

NYC = require('nyc'),
chalk = require('chalk'),
Expand All @@ -20,8 +20,8 @@ module.exports = function (exit) {
// banner line
console.info(chalk.yellow.bold('Running newman tests using mocha on node...'));

test('-d', COV_REPORT_PATH) && rm('-rf', COV_REPORT_PATH);
mkdir('-p', COV_REPORT_PATH);
shell.test('-d', COV_REPORT_PATH) && shell.rm('-rf', COV_REPORT_PATH);
shell.mkdir('-p', COV_REPORT_PATH);

var Mocha = require('mocha'),
nyc = new NYC({
Expand Down Expand Up @@ -56,4 +56,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
12 changes: 6 additions & 6 deletions codegens/csharp-restsharp/npm/test-unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// This script is intended to execute all unit tests.
// ---------------------------------------------------------------------------------------------------------------------

require('shelljs/global');
var shell = require('shelljs'),

// set directories and files for test and coverage report
var path = require('path'),
// set directories and files for test and coverage report
path = require('path'),

NYC = require('nyc'),
chalk = require('chalk'),
Expand All @@ -20,8 +20,8 @@ module.exports = function (exit) {
// banner line
console.info(chalk.yellow.bold('Running unit tests using mocha on node...'));

test('-d', COV_REPORT_PATH) && rm('-rf', COV_REPORT_PATH);
mkdir('-p', COV_REPORT_PATH);
shell.test('-d', COV_REPORT_PATH) && shell.rm('-rf', COV_REPORT_PATH);
shell.mkdir('-p', COV_REPORT_PATH);

var Mocha = require('mocha'),
nyc = new NYC({
Expand Down Expand Up @@ -56,4 +56,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
30 changes: 30 additions & 0 deletions codegens/csharp-restsharp/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,36 @@ describe('csharp restsharp function', function () {
expect(snippet).to.include('request.AddFile("invalid src", "/path/to/file"');
});
});

it('should use client.UserAgent instead of AddHeader function', function () {
const sampleUA = 'Safari/605.1.15',
expectValue = `client.UserAgent = "${sampleUA}";`;

var request = new sdk.Request({
'method': 'GET',
'header': [
{
'key': 'User-Agent',
'value': sampleUA
}
],
'url': {
'raw': 'https://google.com',
'protocol': 'https',
'host': [
'google',
'com'
]
}
});
convert(request, {}, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}
expect(snippet).to.be.a('string');
expect(snippet).to.include(expectValue);
});
});
});

describe('getOptions function', function () {
Expand Down
7 changes: 3 additions & 4 deletions codegens/curl/npm/test-lint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
require('shelljs/global');

var chalk = require('chalk'),
var shell = require('shelljs'),
chalk = require('chalk'),
async = require('async'),
ESLintCLIEngine = require('eslint').CLIEngine,

Expand Down Expand Up @@ -56,4 +55,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
12 changes: 6 additions & 6 deletions codegens/curl/npm/test-newman.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// This script is intended to execute all newman tests.
// ---------------------------------------------------------------------------------------------------------------------

require('shelljs/global');
var shell = require('shelljs'),

// set directories and files for test and coverage report
var path = require('path'),
// set directories and files for test and coverage report
path = require('path'),

NYC = require('nyc'),
chalk = require('chalk'),
Expand All @@ -20,8 +20,8 @@ module.exports = function (exit) {
// banner line
console.info(chalk.yellow.bold('Running newman tests using mocha on node...'));

test('-d', COV_REPORT_PATH) && rm('-rf', COV_REPORT_PATH);
mkdir('-p', COV_REPORT_PATH);
shell.test('-d', COV_REPORT_PATH) && shell.rm('-rf', COV_REPORT_PATH);
shell.mkdir('-p', COV_REPORT_PATH);

var Mocha = require('mocha'),
nyc = new NYC({
Expand Down Expand Up @@ -56,4 +56,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
12 changes: 6 additions & 6 deletions codegens/curl/npm/test-unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// This script is intended to execute all unit tests.
// ---------------------------------------------------------------------------------------------------------------------

require('shelljs/global');
var shell = require('shelljs'),

// set directories and files for test and coverage report
var path = require('path'),
// set directories and files for test and coverage report
path = require('path'),

NYC = require('nyc'),
chalk = require('chalk'),
Expand All @@ -20,8 +20,8 @@ module.exports = function (exit) {
// banner line
console.info(chalk.yellow.bold('Running unit tests using mocha on node...'));

test('-d', COV_REPORT_PATH) && rm('-rf', COV_REPORT_PATH);
mkdir('-p', COV_REPORT_PATH);
shell.test('-d', COV_REPORT_PATH) && shell.rm('-rf', COV_REPORT_PATH);
shell.mkdir('-p', COV_REPORT_PATH);

var Mocha = require('mocha'),
nyc = new NYC({
Expand Down Expand Up @@ -56,4 +56,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
7 changes: 3 additions & 4 deletions codegens/golang/npm/test-lint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
require('shelljs/global');

var chalk = require('chalk'),
var shell = require('shelljs'),
chalk = require('chalk'),
async = require('async'),
ESLintCLIEngine = require('eslint').CLIEngine,

Expand Down Expand Up @@ -56,4 +55,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
12 changes: 6 additions & 6 deletions codegens/golang/npm/test-newman.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// This script is intended to execute all newman tests.
// ---------------------------------------------------------------------------------------------------------------------

require('shelljs/global');
var shell = require('shelljs'),

// set directories and files for test and coverage report
var path = require('path'),
// set directories and files for test and coverage report
path = require('path'),

NYC = require('nyc'),
chalk = require('chalk'),
Expand All @@ -20,8 +20,8 @@ module.exports = function (exit) {
// banner line
console.info(chalk.yellow.bold('Running newman tests using mocha on node...'));

test('-d', COV_REPORT_PATH) && rm('-rf', COV_REPORT_PATH);
mkdir('-p', COV_REPORT_PATH);
shell.test('-d', COV_REPORT_PATH) && shell.rm('-rf', COV_REPORT_PATH);
shell.mkdir('-p', COV_REPORT_PATH);

var Mocha = require('mocha'),
nyc = new NYC({
Expand Down Expand Up @@ -56,4 +56,4 @@ module.exports = function (exit) {
};

// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);
!module.parent && module.exports(shell.exit);
Loading