httpsnippet-client-api 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/index.js +16 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "httpsnippet-client-api",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "An HTTP Snippet client for generating snippets for the api module.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -32,9 +32,9 @@
32
32
  "oas": "^17.1.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@readme/eslint-config": "^7.2.2",
36
- "@readme/oas-examples": "^4.3.2",
37
- "eslint": "^7.32.0",
35
+ "@readme/eslint-config": "^8.0.2",
36
+ "@readme/oas-examples": "^4.3.3",
37
+ "eslint": "^8.3.0",
38
38
  "jest": "^27.3.1",
39
39
  "prettier": "^2.4.1"
40
40
  },
@@ -44,5 +44,5 @@
44
44
  "__tests__/__fixtures__/"
45
45
  ]
46
46
  },
47
- "gitHead": "057c930ba9ca953bda5413baae6efec062563807"
47
+ "gitHead": "eb3b741b7776ce01f3bafe7f23d2cd0df7ca8b21"
48
48
  }
package/src/index.js CHANGED
@@ -213,22 +213,24 @@ module.exports = function (source, options) {
213
213
  break;
214
214
 
215
215
  case 'multipart/form-data':
216
- body = {};
216
+ if (source.postData.params) {
217
+ body = {};
218
+
219
+ // If there's a `Content-Type` header present in the metadata, but it's for the form-data
220
+ // request then dump it off the snippet. We shouldn't offload that unnecessary bloat to the
221
+ // user, instead letting the SDK handle it automatically.
222
+ if ('content-type' in metadata && metadata['content-type'].indexOf('multipart/form-data') === 0) {
223
+ delete metadata['content-type'];
224
+ }
217
225
 
218
- // If there's a `Content-Type` header present in the metadata, but it's for the form-data
219
- // request then dump it off the snippet. We shouldn't offload that unnecessary bloat to the
220
- // user, instead letting the SDK handle it automatically.
221
- if ('content-type' in metadata && metadata['content-type'].indexOf('multipart/form-data') === 0) {
222
- delete metadata['content-type'];
226
+ source.postData.params.forEach(function (param) {
227
+ if (param.fileName) {
228
+ body[param.name] = param.fileName;
229
+ } else {
230
+ body[param.name] = param.value;
231
+ }
232
+ });
223
233
  }
224
-
225
- source.postData.params.forEach(function (param) {
226
- if (param.fileName) {
227
- body[param.name] = param.fileName;
228
- } else {
229
- body[param.name] = param.value;
230
- }
231
- });
232
234
  break;
233
235
 
234
236
  default: