Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lodash isArray + assign #2236

Merged
merged 2 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/execute/index.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions src/execute/oas3/build-request.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/execute/swagger2/build-request.js
Original file line number Diff line number Diff line change
@@ -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`
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import assign from 'lodash/assign';
import startsWith from 'lodash/startsWith';
import Url from 'url';

Expand Down Expand Up @@ -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;
});
Expand Down