From 284aeebdc842a1d6cbfea6262ba73f44633a56b8 Mon Sep 17 00:00:00 2001 From: ErikWittern Date: Fri, 13 Aug 2021 13:47:09 +0200 Subject: [PATCH] Bump version; fix typo --- openapi-to-har.js | 37 +++++++++++++++++++++++-------------- package-lock.json | 16 ++++++++-------- package.json | 2 +- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/openapi-to-har.js b/openapi-to-har.js index 67a4173..a3864a1 100644 --- a/openapi-to-har.js +++ b/openapi-to-har.js @@ -107,7 +107,8 @@ const getPayload = function (openApi, path, method) { openApi.paths[path][method].requestBody && openApi.paths[path][method].requestBody.content ) { - if (openApi.paths[path][method].requestBody.content['application/json'] && + if ( + openApi.paths[path][method].requestBody.content['application/json'] && openApi.paths[path][method].requestBody.content['application/json'].schema ) { const sample = OpenAPISampler.sample( @@ -118,34 +119,42 @@ const getPayload = function (openApi, path, method) { ); return { mimeType: 'application/json', - text: JSON.stringify(sample) + text: JSON.stringify(sample), }; } - if (openApi.paths[path][method].requestBody.content['application/x-www-form-urlencoded'] && - openApi.paths[path][method].requestBody.content['application/x-www-form-urlencoded'].schema + if ( + openApi.paths[path][method].requestBody.content[ + 'application/x-www-form-urlencoded' + ] && + openApi.paths[path][method].requestBody.content[ + 'application/x-www-form-urlencoded' + ].schema ) { - const sample = OpenAPISampler.sample(openApi.paths[path][method].requestBody.content['application/x-www-form-urlencoded'] - .schema, - {skipReadOnly: true}, + const sample = OpenAPISampler.sample( + openApi.paths[path][method].requestBody.content[ + 'application/x-www-form-urlencoded' + ].schema, + { skipReadOnly: true }, openApi ); if (sample === undefined) return null; const params = []; - Object.keys(sample).map( - key => params.push({ - 'name': encodeURIComponent(key).replace(/\%20/g, '+'), - 'value': encodeURIComponent(sample[key]).replace(/\%20/g, '+') - }) - } + Object.keys(sample).map((key) => + params.push({ + name: encodeURIComponent(key).replace(/\%20/g, '+'), + value: encodeURIComponent(sample[key]).replace(/\%20/g, '+'), + }) ); return { mimeType: 'application/x-www-form-urlencoded', params: params, - text: Object.keys(params).map(key => key + '=' + sample[key]).join('&') + text: Object.keys(params) + .map((key) => key + '=' + sample[key]) + .join('&'), }; } } diff --git a/package-lock.json b/package-lock.json index 6611054..febcf80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "openapi-snippet", - "version": "0.9.3", + "version": "0.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.9.3", + "version": "0.11.0", "license": "MIT", "dependencies": { "httpsnippet": "^1.16.7", @@ -1683,9 +1683,9 @@ } }, "node_modules/path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "node_modules/path-platform": { @@ -4121,9 +4121,9 @@ "dev": true }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-platform": { diff --git a/package.json b/package.json index 8ee7641..9a210ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi-snippet", - "version": "0.10.0", + "version": "0.11.0", "description": "Generates code snippets from Open API (previously Swagger) documents.", "repository": { "type": "git",