From 0864683fd1ca606d194d980b39cdf3a05be1f6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Mon, 13 Sep 2021 14:45:33 +0200 Subject: [PATCH 1/2] replace lodash isArray w. native --- src/execute/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/execute/index.js b/src/execute/index.js index 90b104f01..f5f21f31d 100755 --- a/src/execute/index.js +++ b/src/execute/index.js @@ -1,6 +1,5 @@ import getIn from 'lodash/get'; import isPlainObject from 'lodash/isPlainObject'; -import isArray from 'lodash/isArray'; import url from 'url'; import cookie from 'cookie'; @@ -77,7 +76,7 @@ export function execute({ ...extras, }); - if (request.body && (isPlainObject(request.body) || isArray(request.body))) { + if (request.body && (isPlainObject(request.body) || Array.isArray(request.body))) { request.body = JSON.stringify(request.body); } From df8e6f857c1cd03c916508bbb760b7f1bce6c40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Mon, 13 Sep 2021 14:45:51 +0200 Subject: [PATCH 2/2] replace lodash assign w. native --- src/execute/oas3/build-request.js | 3 +-- src/execute/swagger2/build-request.js | 3 +-- src/index.js | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/execute/oas3/build-request.js b/src/execute/oas3/build-request.js index e93ed0c7a..25fcc9678 100644 --- a/src/execute/oas3/build-request.js +++ b/src/execute/oas3/build-request.js @@ -1,6 +1,5 @@ // This function runs after the common function, // `src/execute/index.js#buildRequest` -import assign from 'lodash/assign'; import get from 'lodash/get'; import isPlainObject from 'lodash/isPlainObject'; import btoa from 'btoa'; @@ -88,7 +87,7 @@ export default function buildRequest(options, req) { // Add security values, to operations - that declare their need on them // Adapted from the Swagger2 implementation export function applySecurities({ request, securities = {}, operation = {}, spec }) { - const result = assign({}, request); + const result = { ...request }; const { authorized = {} } = securities; const security = operation.security || spec.security || []; const isAuthorized = authorized && !!Object.keys(authorized).length; diff --git a/src/execute/swagger2/build-request.js b/src/execute/swagger2/build-request.js index 435a0b4a1..2fb18c4d7 100644 --- a/src/execute/swagger2/build-request.js +++ b/src/execute/swagger2/build-request.js @@ -1,5 +1,4 @@ import btoa from 'btoa'; -import assign from 'lodash/assign'; // This function runs after the common function, // `src/execute/index.js#buildRequest` @@ -57,7 +56,7 @@ export default function buildRequest(options, req) { // Add security values, to operations - that declare their need on them export function applySecurities({ request, securities = {}, operation = {}, spec }) { - const result = assign({}, request); + const result = { ...request }; const { authorized = {}, specSecurity = [] } = securities; const security = operation.security || specSecurity; const isAuthorized = authorized && !!Object.keys(authorized).length; diff --git a/src/index.js b/src/index.js index a751b5a66..06d1a0bca 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,3 @@ -import assign from 'lodash/assign'; import startsWith from 'lodash/startsWith'; import Url from 'url'; @@ -34,11 +33,11 @@ function Swagger(url, opts = {}) { return new Swagger(opts); } - assign(this, opts); + Object.assign(this, opts); const prom = this.resolve().then(() => { if (!this.disableInterfaces) { - assign(this, Swagger.makeApisTagOperation(this)); + Object.assign(this, Swagger.makeApisTagOperation(this)); } return this; });