Skip to content

Commit af2b86c

Browse files
authored
refactor: replace lodash.pick for native object destructuring (#2235)
Refs #2187
1 parent bc1ab5f commit af2b86c

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/execute/oas3/parameter-builders.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pick from 'lodash/pick';
2-
31
import stylize, { encodeDisallowedCharacters } from './style-serializer';
42
import serialize from './content-serializer';
53

@@ -45,9 +43,10 @@ export function query({ req, value, parameter }) {
4543
}
4644

4745
if (value) {
46+
const { style, explode, allowReserved } = parameter;
4847
req.query[parameter.name] = {
4948
value,
50-
serializationOption: pick(parameter, ['style', 'explode', 'allowReserved']),
49+
serializationOption: { style, explode, allowReserved },
5150
};
5251
} else if (parameter.allowEmptyValue && value !== undefined) {
5352
const paramName = parameter.name;

src/http/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'cross-fetch/polyfill'; /* global fetch */
22
import qs from 'qs';
33
import jsYaml from 'js-yaml';
4-
import pick from 'lodash/pick';
54
import isFunction from 'lodash/isFunction';
65
import { Buffer } from 'buffer';
76
import { FormData, File, Blob } from 'formdata-node';
@@ -229,12 +228,12 @@ function formatKeyValue(key, input, skipEncoding = false) {
229228
(type) => type !== 'undefined'
230229
)
231230
) {
232-
return formatKeyValueBySerializationOption(
233-
key,
234-
value,
235-
skipEncoding,
236-
pick(encoding, ['style', 'explode', 'allowReserved'])
237-
);
231+
const { style, explode, allowReserved } = encoding;
232+
return formatKeyValueBySerializationOption(key, value, skipEncoding, {
233+
style,
234+
explode,
235+
allowReserved,
236+
});
238237
}
239238

240239
if (encoding.contentType) {

src/interfaces.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pick from 'lodash/pick';
2-
31
import { eachOperation, opId } from './helpers';
42

53
const nullFn = () => null;
@@ -15,16 +13,20 @@ export const self = {
1513
// Make an execute, bound to arguments defined in mapTagOperation's callback (cb)
1614
export function makeExecute(swaggerJs = {}) {
1715
return ({ pathName, method, operationId }) =>
18-
(parameters, opts = {}) =>
19-
swaggerJs.execute({
16+
(parameters, opts = {}) => {
17+
const { requestInterceptor, responseInterceptor, userFetch } = swaggerJs;
18+
return swaggerJs.execute({
2019
spec: swaggerJs.spec,
21-
...pick(swaggerJs, 'requestInterceptor', 'responseInterceptor', 'userFetch'),
20+
requestInterceptor,
21+
responseInterceptor,
22+
userFetch,
2223
pathName,
2324
method,
2425
parameters,
2526
operationId,
2627
...opts,
2728
});
29+
};
2830
}
2931

3032
// Creates an interface with tags+operations = execute

0 commit comments

Comments
 (0)