Skip to content

Commit c45ef3c

Browse files
authored
Merge pull request #684 from postmanlabs/release/1.6.0
Release v1.6.0.
2 parents 40fbece + 77493c1 commit c45ef3c

31 files changed

+2339
-66
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ out/
6868

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

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v1.6.0 (March 17, 2023)
2+
* PEP8 improvements in python-requests code
3+
* Fix for - [#491](https://github.com/postmanlabs/postman-code-generators/issues/491) Added support for kotlin okhttp code snippets.
4+
* Refactored code for nodejs-axios util.js.
5+
16
v1.5.0 (March 2, 2023)
27
* Change minimum supported NodeJS version to 12
38
* Fix for - [#11049](https://github.com/postmanlabs/postman-app-support/issues/11049) Escape backslash character in raw bodies for curl codegen

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ List of supported code generators:
2929
| JavaScript | Fetch |
3030
| JavaScript | jQuery |
3131
| JavaScript | XHR |
32+
| Kotlin | OkHttp |
3233
| NodeJs | Axios |
3334
| NodeJs | Native |
3435
| NodeJs | Request |

codegens/kotlin-okhttp/.gitignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
*.java
2+
*.class
3+
*.jar
4+
5+
.DS_Store
6+
# Logs
7+
logs
8+
*.log
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Prevent IDE stuff
20+
.idea
21+
.vscode
22+
*.sublime-*
23+
24+
# Directory for instrumented libs generated by jscoverage/JSCover
25+
lib-cov
26+
27+
# Coverage directory used by tools like istanbul
28+
.coverage
29+
30+
# nyc test coverage
31+
.nyc_output
32+
33+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
34+
.grunt
35+
36+
# Bower dependency directory (https://bower.io/)
37+
bower_components
38+
39+
# node-waf configuration
40+
.lock-wscript
41+
42+
# Compiled binary addons (http://nodejs.org/api/addons.html)
43+
build/Release
44+
45+
# Dependency directories
46+
node_modules/
47+
jspm_packages/
48+
49+
# Typescript v1 declaration files
50+
typings/
51+
52+
# Optional npm cache directory
53+
.npm
54+
55+
# Optional eslint cache
56+
.eslintcache
57+
58+
# Optional REPL history
59+
.node_repl_history
60+
61+
# Output of 'npm pack'
62+
*.tgz
63+
64+
# Yarn Integrity file
65+
.yarn-integrity
66+
67+
# dotenv environment variables file
68+
.env
69+
70+
out/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"tags": {
3+
"allowUnknownTags": true,
4+
"dictionaries": ["jsdoc", "closure"]
5+
},
6+
"source": {
7+
"include": [ ],
8+
"includePattern": ".+\\.js(doc)?$",
9+
"excludePattern": "(^|\\/|\\\\)_"
10+
},
11+
12+
"plugins": [
13+
"plugins/markdown"
14+
],
15+
16+
"templates": {
17+
"cleverLinks": false,
18+
"monospaceLinks": false,
19+
"highlightTutorialCode" : true
20+
},
21+
22+
"opts": {
23+
"template": "./node_modules/postman-jsdoc-theme",
24+
"encoding": "utf8",
25+
"destination": "./out/docs",
26+
"recurse": true,
27+
"readme": "README.md"
28+
},
29+
30+
"markdown": {
31+
"parser": "gfm",
32+
"hardwrap": false
33+
}
34+
}

codegens/kotlin-okhttp/.npmignore

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
### NPM Specific: Disregard recursive project files
2+
### ===============================================
3+
/.editorconfig
4+
/.gitmodules
5+
/test
6+
7+
### Borrowed from .gitignore
8+
### ========================
9+
10+
# Logs
11+
logs
12+
*.log
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*
16+
17+
# Runtime data
18+
pids
19+
*.pid
20+
*.seed
21+
*.pid.lock
22+
23+
# Prevent IDE stuff
24+
.idea
25+
.vscode
26+
*.sublime-*
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
lib-cov
30+
31+
# Coverage directory used by tools like istanbul
32+
.coverage
33+
34+
# nyc test coverage
35+
.nyc_output
36+
37+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
38+
.grunt
39+
40+
# Bower dependency directory (https://bower.io/)
41+
bower_components
42+
43+
# node-waf configuration
44+
.lock-wscript
45+
46+
# Compiled binary addons (http://nodejs.org/api/addons.html)
47+
build/Release
48+
49+
# Dependency directories
50+
node_modules/
51+
jspm_packages/
52+
53+
# Typescript v1 declaration files
54+
typings/
55+
56+
# Optional npm cache directory
57+
.npm
58+
59+
# Optional eslint cache
60+
.eslintcache
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
74+
out/

codegens/kotlin-okhttp/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# codegen-kotlin-okhttp
2+
3+
> Converts Postman-SDK Request into code snippet for kotlin-okhttp.
4+
5+
#### Prerequisites
6+
To run Code-Gen, ensure that you have NodeJS >= v12. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager.
7+
8+
## Using the Module
9+
The module will expose an object which will have property `convert` which is the function for converting the Postman-SDK request to kotlin-okhttp code snippet and `getOptions` function which returns an array of supported options.
10+
11+
### convert function
12+
Convert function will take three parameters
13+
* `request`- Postman-SDK Request object
14+
15+
* `options`- options is an object which can have following properties
16+
* `indentType`- string representing type of indentation for code snippet. eg: 'Space', 'Tab'
17+
* `indentCount`- positiveInteger representing count of indentation required.
18+
* `includeBoilerplate`- boolean representing whether to include class definition in code snippet
19+
* `requestTimeout` : Integer denoting time after which the request will bail out in milli-seconds
20+
* `trimRequestBody` : Trim request body fields
21+
* `followRedirect` : Boolean denoting whether to redirect a request
22+
23+
* `callback`- callback function with first parameter as error and second parameter as string for code snippet
24+
25+
##### Example:
26+
```js
27+
var request = new sdk.Request('www.google.com'), //using postman sdk to create request
28+
options = {
29+
indentType: 'Space',
30+
indentCount: 2,
31+
includeBoilerplate: false
32+
};
33+
convert(request, options, function(error, snippet) {
34+
if (error) {
35+
// handle error
36+
}
37+
// handle snippet
38+
});
39+
```
40+
41+
### getOptions function
42+
43+
This function returns a list of options supported by this codegen.
44+
45+
#### Example
46+
```js
47+
var options = getOptions();
48+
49+
console.log(options);
50+
// output
51+
// [
52+
// {
53+
// name: 'Set indentation count',
54+
// id: 'indentCount',
55+
// type: 'positiveInteger',
56+
// default: 2,
57+
// description: 'Set the number of indentation characters to add per code level'
58+
// },
59+
// ...
60+
// ]
61+
```
62+
63+
### Guideline for using generated snippet
64+
* Generated snippet requires dependencies [okhttp3](https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/3.9.1) and [okio](https://mvnrepository.com/artifact/com.squareup.okio/okio/1.13.0) to compile and run
65+
66+
* Generated snippet uses `.method(nameOfMethod, body)` from `Request` class to form HTTP request. If the `method` doesn't require body then the value of `body` will be `null`.
67+
68+
* Generated snippet uses `MultipartBody.Builder()` when `multipart/formdata` is used otherwise it uses `RequestBody.create()` in order to add body to request.
69+
70+
* 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.
71+
72+
* `content-type` needs to be specified in order to add body to the request. So if no `content-type` is specified then `text/plain` will be used as default. **In case of `multipart/formdata` `content-type` is generated by snippet itself**.
73+
74+
* This module doesn't support cookies.

codegens/kotlin-okhttp/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib');

codegens/kotlin-okhttp/lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
convert: require('./okhttp').convert,
3+
getOptions: require('./okhttp').getOptions
4+
};

0 commit comments

Comments
 (0)