-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Boilerplate commit for Nodejs(Superagent) Codegen
- Loading branch information
Showing
12 changed files
with
819 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.DS_Store | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Coverage directory used by tools like istanbul | ||
.coverage | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
### NPM Specific: Disregard recursive project files | ||
### =============================================== | ||
/.editorconfig | ||
/.gitmodules | ||
/test | ||
|
||
### Borrowed from .gitignore | ||
### ======================== | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Prevent IDE stuff | ||
.idea | ||
.vscode | ||
*.sublime-* | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
.coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
snippet.swift | ||
|
||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,42 @@ | ||
# codegen-nodejs-superagent | ||
|
||
> Converts Postman-SDK Request into code snippet for NodeJS-superagent. | ||
|
||
> Converts Postman-SDK Request into code snippet for Nodejs(Superagent). | ||
#### Prerequisites | ||
To run the module, ensure that you have NodeJS with superagent as a dependency. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager. | ||
To run Code-Gen, ensure that you have NodeJS >= v8. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager. | ||
|
||
## Using the Module | ||
The module will expose an object which will have property `convert` which is the function for converting the Postman-SDK request to swift code snippet. | ||
|
||
### convert function | ||
Convert function takes three parameters | ||
|
||
* `request` - Postman-SDK Request Object | ||
|
||
* `options` - options is an object which hsa following properties | ||
* `indentType` - String denoting type of indentation for code snippet. eg: 'Space', 'Tab' | ||
* `indentCount` - The number of indentation characters to add per code level | ||
* `trimRequestBody` - Whether or not request body fields should be trimmed | ||
|
||
* `callback` - callback function with first parameter as error and second parameter as string for code snippet | ||
|
||
##### Example: | ||
```js | ||
var request = new sdk.Request('www.google.com'), //using postman sdk to create request | ||
options = { | ||
indentCount: 3, | ||
indentType: 'Space', | ||
requestTimeout: 200, | ||
trimRequestBody: true | ||
}; | ||
convert(request, options, function(error, snippet) { | ||
if (error) { | ||
// handle error | ||
} | ||
// handle snippet | ||
}); | ||
``` | ||
### Guidelines for using generated snippet | ||
|
||
* Since Postman-SDK Request object doesn't provide complete path of the file, it needs to be manually inserted in case of uploading a file. | ||
|
||
* This module doesn't support cookies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./lib'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
convert: function (request, options) { | ||
// Use request object and options object to generate code snippet. | ||
// return (String) snippet | ||
}, | ||
getOptions: function () { | ||
// Return an array of options supported by this codegen. | ||
} | ||
}; |
Oops, something went wrong.