swagger-client 3.24.5 → 3.26.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 (69) hide show
  1. package/README.md +1 -2
  2. package/dist/swagger-client.browser.js +20592 -32714
  3. package/dist/swagger-client.browser.min.js +1 -1
  4. package/dist/swagger-client.browser.min.js.map +1 -1
  5. package/es/execute/index.js +26 -31
  6. package/es/execute/oas3/build-request.js +8 -13
  7. package/es/execute/oas3/parameter-builders.js +22 -26
  8. package/es/execute/oas3/style-serializer.js +23 -28
  9. package/es/execute/swagger2/build-request.js +6 -7
  10. package/es/execute/swagger2/parameter-builders.js +24 -29
  11. package/es/helpers/each-operation.js +0 -2
  12. package/es/helpers/fetch-polyfill.node.js +7 -8
  13. package/es/helpers/get-operation-raw.js +5 -6
  14. package/es/helpers/id-from-path-method/index.js +3 -4
  15. package/es/helpers/op-id.js +3 -5
  16. package/es/http/index.js +12 -28
  17. package/es/index.js +2 -4
  18. package/es/interfaces.js +33 -42
  19. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
  20. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
  21. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +73 -30
  22. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
  23. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
  24. package/es/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
  25. package/es/resolver/strategies/generic/index.js +3 -4
  26. package/es/resolver/strategies/generic/normalize.js +0 -2
  27. package/es/resolver/strategies/openapi-2/index.js +6 -8
  28. package/es/resolver/strategies/openapi-3-0/index.js +6 -8
  29. package/es/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
  30. package/es/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
  31. package/es/resolver/utils/index.js +1 -2
  32. package/es/specmap/helpers.js +5 -6
  33. package/es/specmap/index.js +14 -17
  34. package/es/specmap/lib/create-error.js +1 -4
  35. package/es/subtree-resolver/index.js +2 -4
  36. package/lib/execute/index.js +26 -35
  37. package/lib/execute/oas3/build-request.js +8 -13
  38. package/lib/execute/oas3/parameter-builders.js +22 -26
  39. package/lib/execute/oas3/style-serializer.js +23 -27
  40. package/lib/execute/swagger2/build-request.js +6 -7
  41. package/lib/execute/swagger2/parameter-builders.js +24 -29
  42. package/lib/helpers/each-operation.js +0 -2
  43. package/lib/helpers/fetch-polyfill.node.js +7 -8
  44. package/lib/helpers/get-operation-raw.js +5 -6
  45. package/lib/helpers/id-from-path-method/index.js +3 -4
  46. package/lib/helpers/op-id.js +3 -7
  47. package/lib/http/index.js +12 -42
  48. package/lib/index.js +2 -8
  49. package/lib/interfaces.js +33 -50
  50. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
  51. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
  52. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +72 -29
  53. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
  54. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
  55. package/lib/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
  56. package/lib/resolver/strategies/generic/index.js +3 -4
  57. package/lib/resolver/strategies/generic/normalize.js +0 -2
  58. package/lib/resolver/strategies/openapi-2/index.js +6 -8
  59. package/lib/resolver/strategies/openapi-3-0/index.js +6 -8
  60. package/lib/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
  61. package/lib/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
  62. package/lib/resolver/utils/index.js +1 -4
  63. package/lib/specmap/helpers.js +5 -6
  64. package/lib/specmap/index.js +14 -17
  65. package/lib/specmap/lib/create-error.js +1 -4
  66. package/lib/subtree-resolver/index.js +2 -8
  67. package/package.json +21 -19
  68. package/es/helpers/fetch-ponyfill-undici.node.js +0 -4
  69. package/lib/helpers/fetch-ponyfill-undici.node.js +0 -13
@@ -69,19 +69,18 @@ export const self = {
69
69
 
70
70
  // Execute request, with the given operationId and parameters
71
71
  // pathName/method or operationId is optional
72
- export function execute(_ref) {
73
- let {
74
- http: userHttp,
75
- fetch,
76
- // This is legacy
77
- spec,
78
- operationId,
79
- pathName,
80
- method,
81
- parameters,
82
- securities,
83
- ...extras
84
- } = _ref;
72
+ export function execute({
73
+ http: userHttp,
74
+ fetch,
75
+ // This is legacy
76
+ spec,
77
+ operationId,
78
+ pathName,
79
+ method,
80
+ parameters,
81
+ securities,
82
+ ...extras
83
+ }) {
85
84
  // Provide default fetch implementation
86
85
  const http = userHttp || fetch || stockHttp; // Default to _our_ http
87
86
 
@@ -284,16 +283,15 @@ export function baseUrl(obj) {
284
283
  return specIsOAS3 ? oas3BaseUrl(obj) : swagger2BaseUrl(obj);
285
284
  }
286
285
  const isNonEmptyServerList = value => Array.isArray(value) && value.length > 0;
287
- function oas3BaseUrl(_ref2) {
286
+ function oas3BaseUrl({
287
+ spec,
288
+ pathName,
289
+ method,
290
+ server,
291
+ contextUrl,
292
+ serverVariables = {}
293
+ }) {
288
294
  var _spec$paths, _spec$paths2;
289
- let {
290
- spec,
291
- pathName,
292
- method,
293
- server,
294
- contextUrl,
295
- serverVariables = {}
296
- } = _ref2;
297
295
  let servers = [];
298
296
  let selectedServerUrl = '';
299
297
  let selectedServerObj;
@@ -332,9 +330,7 @@ function oas3BaseUrl(_ref2) {
332
330
  }
333
331
  return buildOas3UrlWithContext(selectedServerUrl, contextUrl);
334
332
  }
335
- function buildOas3UrlWithContext() {
336
- let ourUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
337
- let contextUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
333
+ function buildOas3UrlWithContext(ourUrl = '', contextUrl = '') {
338
334
  // relative server url should be resolved against contextUrl
339
335
  const parsedUrl = ourUrl && contextUrl ? parseURIReference(url.resolve(contextUrl, ourUrl)) : parseURIReference(ourUrl);
340
336
  const parsedContextUrl = parseURIReference(contextUrl);
@@ -364,12 +360,11 @@ function getVariableTemplateNames(str) {
364
360
  }
365
361
 
366
362
  // Compose the baseUrl ( scheme + host + basePath )
367
- function swagger2BaseUrl(_ref3) {
368
- let {
369
- spec,
370
- scheme,
371
- contextUrl = ''
372
- } = _ref3;
363
+ function swagger2BaseUrl({
364
+ spec,
365
+ scheme,
366
+ contextUrl = ''
367
+ }) {
373
368
  const parsedContextUrl = parseURIReference(contextUrl);
374
369
  const firstSchemeInSpec = Array.isArray(spec.schemes) ? spec.schemes[0] : null;
375
370
  const computedScheme = scheme || firstSchemeInSpec || stripNonAlpha(parsedContextUrl.protocol) || 'http';
@@ -40,14 +40,10 @@ export default function buildRequest(options, req) {
40
40
  req.headers['Content-Type'] = requestContentType;
41
41
  }
42
42
  if (!options.responseContentType && operation.responses) {
43
- const mediaTypes = Object.entries(operation.responses).filter(_ref => {
44
- let [key, value] = _ref;
43
+ const mediaTypes = Object.entries(operation.responses).filter(([key, value]) => {
45
44
  const code = parseInt(key, 10);
46
45
  return code >= 200 && code < 300 && isPlainObject(value.content);
47
- }).reduce((acc, _ref2) => {
48
- let [, value] = _ref2;
49
- return acc.concat(Object.keys(value.content));
50
- }, []);
46
+ }).reduce((acc, [, value]) => acc.concat(Object.keys(value.content)), []);
51
47
  if (mediaTypes.length > 0) {
52
48
  req.headers.accept = mediaTypes.join(', ');
53
49
  }
@@ -86,14 +82,13 @@ export default function buildRequest(options, req) {
86
82
 
87
83
  // Add security values, to operations - that declare their need on them
88
84
  // Adapted from the Swagger2 implementation
89
- export function applySecurities(_ref3) {
85
+ export function applySecurities({
86
+ request,
87
+ securities = {},
88
+ operation = {},
89
+ spec
90
+ }) {
90
91
  var _spec$components;
91
- let {
92
- request,
93
- securities = {},
94
- operation = {},
95
- spec
96
- } = _ref3;
97
92
  const result = {
98
93
  ...request
99
94
  };
@@ -1,11 +1,10 @@
1
1
  import stylize, { encodeDisallowedCharacters } from './style-serializer.js';
2
2
  import serialize from './content-serializer.js';
3
- export function path(_ref) {
4
- let {
5
- req,
6
- value,
7
- parameter
8
- } = _ref;
3
+ export function path({
4
+ req,
5
+ value,
6
+ parameter
7
+ }) {
9
8
  const {
10
9
  name,
11
10
  style,
@@ -28,12 +27,11 @@ export function path(_ref) {
28
27
  });
29
28
  req.url = req.url.split(`{${name}}`).join(styledValue);
30
29
  }
31
- export function query(_ref2) {
32
- let {
33
- req,
34
- value,
35
- parameter
36
- } = _ref2;
30
+ export function query({
31
+ req,
32
+ value,
33
+ parameter
34
+ }) {
37
35
  req.query = req.query || {};
38
36
  if (parameter.content) {
39
37
  const effectiveMediaType = Object.keys(parameter.content)[0];
@@ -74,12 +72,11 @@ export function query(_ref2) {
74
72
  }
75
73
  }
76
74
  const PARAMETER_HEADER_BLACKLIST = ['accept', 'authorization', 'content-type'];
77
- export function header(_ref3) {
78
- let {
79
- req,
80
- parameter,
81
- value
82
- } = _ref3;
75
+ export function header({
76
+ req,
77
+ parameter,
78
+ value
79
+ }) {
83
80
  req.headers = req.headers || {};
84
81
  if (PARAMETER_HEADER_BLACKLIST.indexOf(parameter.name.toLowerCase()) > -1) {
85
82
  return;
@@ -89,7 +86,7 @@ export function header(_ref3) {
89
86
  req.headers[parameter.name] = serialize(value, effectiveMediaType);
90
87
  return;
91
88
  }
92
- if (typeof value !== 'undefined') {
89
+ if (value !== undefined && !(Array.isArray(value) && value.length === 0)) {
93
90
  req.headers[parameter.name] = stylize({
94
91
  key: parameter.name,
95
92
  value,
@@ -99,12 +96,11 @@ export function header(_ref3) {
99
96
  });
100
97
  }
101
98
  }
102
- export function cookie(_ref4) {
103
- let {
104
- req,
105
- parameter,
106
- value
107
- } = _ref4;
99
+ export function cookie({
100
+ req,
101
+ parameter,
102
+ value
103
+ }) {
108
104
  req.headers = req.headers || {};
109
105
  const type = typeof value;
110
106
  if (parameter.content) {
@@ -112,7 +108,7 @@ export function cookie(_ref4) {
112
108
  req.headers.Cookie = `${parameter.name}=${serialize(value, effectiveMediaType)}`;
113
109
  return;
114
110
  }
115
- if (type !== 'undefined') {
111
+ if (value !== undefined && !(Array.isArray(value) && value.length === 0)) {
116
112
  const prefix = type === 'object' && !Array.isArray(value) && parameter.explode ? '' : `${parameter.name}=`;
117
113
  req.headers.Cookie = prefix + stylize({
118
114
  key: parameter.name,
@@ -2,11 +2,9 @@ const isRfc3986Reserved = char => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
2
2
  const isRrc3986Unreserved = char => /^[a-z0-9\-._~]+$/i.test(char);
3
3
 
4
4
  // eslint-disable-next-line default-param-last
5
- export function encodeDisallowedCharacters(str) {
6
- let {
7
- escape
8
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9
- let parse = arguments.length > 2 ? arguments[2] : undefined;
5
+ export function encodeDisallowedCharacters(str, {
6
+ escape
7
+ } = {}, parse) {
10
8
  if (typeof str === 'number') {
11
9
  str = str.toString();
12
10
  }
@@ -48,14 +46,13 @@ export default function stylize(config) {
48
46
  }
49
47
  return encodePrimitive(config);
50
48
  }
51
- function encodeArray(_ref) {
52
- let {
53
- key,
54
- value,
55
- style,
56
- explode,
57
- escape
58
- } = _ref;
49
+ function encodeArray({
50
+ key,
51
+ value,
52
+ style,
53
+ explode,
54
+ escape
55
+ }) {
59
56
  const valueEncoder = str => encodeDisallowedCharacters(str, {
60
57
  escape
61
58
  });
@@ -87,14 +84,13 @@ function encodeArray(_ref) {
87
84
  }
88
85
  return undefined;
89
86
  }
90
- function encodeObject(_ref2) {
91
- let {
92
- key,
93
- value,
94
- style,
95
- explode,
96
- escape
97
- } = _ref2;
87
+ function encodeObject({
88
+ key,
89
+ value,
90
+ style,
91
+ explode,
92
+ escape
93
+ }) {
98
94
  const valueEncoder = str => encodeDisallowedCharacters(str, {
99
95
  escape
100
96
  });
@@ -140,13 +136,12 @@ function encodeObject(_ref2) {
140
136
  }
141
137
  return undefined;
142
138
  }
143
- function encodePrimitive(_ref3) {
144
- let {
145
- key,
146
- value,
147
- style,
148
- escape
149
- } = _ref3;
139
+ function encodePrimitive({
140
+ key,
141
+ value,
142
+ style,
143
+ escape
144
+ }) {
150
145
  const valueEncoder = str => encodeDisallowedCharacters(str, {
151
146
  escape
152
147
  });
@@ -45,13 +45,12 @@ export default function buildRequest(options, req) {
45
45
  }
46
46
 
47
47
  // Add security values, to operations - that declare their need on them
48
- export function applySecurities(_ref) {
49
- let {
50
- request,
51
- securities = {},
52
- operation = {},
53
- spec
54
- } = _ref;
48
+ export function applySecurities({
49
+ request,
50
+ securities = {},
51
+ operation = {},
52
+ spec
53
+ }) {
55
54
  const result = {
56
55
  ...request
57
56
  };
@@ -10,21 +10,19 @@ export default {
10
10
  };
11
11
 
12
12
  // Add the body to the request
13
- function bodyBuilder(_ref) {
14
- let {
15
- req,
16
- value
17
- } = _ref;
13
+ function bodyBuilder({
14
+ req,
15
+ value
16
+ }) {
18
17
  req.body = value;
19
18
  }
20
19
 
21
20
  // Add a form data object.
22
- function formDataBuilder(_ref2) {
23
- let {
24
- req,
25
- value,
26
- parameter
27
- } = _ref2;
21
+ function formDataBuilder({
22
+ req,
23
+ value,
24
+ parameter
25
+ }) {
28
26
  if (value || parameter.allowEmptyValue) {
29
27
  req.form = req.form || {};
30
28
  req.form[parameter.name] = {
@@ -36,12 +34,11 @@ function formDataBuilder(_ref2) {
36
34
  }
37
35
 
38
36
  // Add a header to the request
39
- function headerBuilder(_ref3) {
40
- let {
41
- req,
42
- parameter,
43
- value
44
- } = _ref3;
37
+ function headerBuilder({
38
+ req,
39
+ parameter,
40
+ value
41
+ }) {
45
42
  req.headers = req.headers || {};
46
43
  if (typeof value !== 'undefined') {
47
44
  req.headers[parameter.name] = value;
@@ -49,22 +46,20 @@ function headerBuilder(_ref3) {
49
46
  }
50
47
 
51
48
  // Replace path paramters, with values ( ie: the URL )
52
- function pathBuilder(_ref4) {
53
- let {
54
- req,
55
- value,
56
- parameter
57
- } = _ref4;
49
+ function pathBuilder({
50
+ req,
51
+ value,
52
+ parameter
53
+ }) {
58
54
  req.url = req.url.split(`{${parameter.name}}`).join(encodeURIComponent(value));
59
55
  }
60
56
 
61
57
  // Add a query to the `query` object, which will later be stringified into the URL's search
62
- function queryBuilder(_ref5) {
63
- let {
64
- req,
65
- value,
66
- parameter
67
- } = _ref5;
58
+ function queryBuilder({
59
+ req,
60
+ value,
61
+ parameter
62
+ }) {
68
63
  req.query = req.query || {};
69
64
  if (value === false && parameter.type === 'boolean') {
70
65
  value = 'false';
@@ -16,12 +16,10 @@ export default function eachOperation(spec, cb, find) {
16
16
  if (method.toUpperCase() === 'PARAMETERS') {
17
17
  continue; // eslint-disable-line no-continue
18
18
  }
19
-
20
19
  const operation = paths[pathName][method];
21
20
  if (!operation || typeof operation !== 'object') {
22
21
  continue; // eslint-disable-line no-continue
23
22
  }
24
-
25
23
  const operationObj = {
26
24
  spec,
27
25
  pathName,
@@ -1,23 +1,22 @@
1
- import { fetch as fetchU, Headers as HeaderU, Request as RequestU, Response as ResponseU, FormData as FormDataU, File as FileU, Blob as BlobU } from './fetch-ponyfill-undici.node.js';
2
1
  import { fetch as fetchNF, Headers as HeadersNF, Request as RequestNF, Response as ResponseNF, FormData as FormDataNF, File as FileNF, Blob as BlobNF } from './fetch-ponyfill-node-fetch.node.js';
3
2
  if (typeof globalThis.fetch === 'undefined') {
4
- globalThis.fetch = fetchU || fetchNF;
3
+ globalThis.fetch = fetchNF;
5
4
  }
6
5
  if (typeof globalThis.Headers === 'undefined') {
7
- globalThis.Headers = HeaderU || HeadersNF;
6
+ globalThis.Headers = HeadersNF;
8
7
  }
9
8
  if (typeof globalThis.Request === 'undefined') {
10
- globalThis.Request = RequestU || RequestNF;
9
+ globalThis.Request = RequestNF;
11
10
  }
12
11
  if (typeof globalThis.Response === 'undefined') {
13
- globalThis.Response = ResponseU || ResponseNF;
12
+ globalThis.Response = ResponseNF;
14
13
  }
15
14
  if (typeof globalThis.FormData === 'undefined') {
16
- globalThis.FormData = FormDataU || FormDataNF;
15
+ globalThis.FormData = FormDataNF;
17
16
  }
18
17
  if (typeof globalThis.File === 'undefined') {
19
- globalThis.File = FileU || FileNF;
18
+ globalThis.File = FileNF;
20
19
  }
21
20
  if (typeof globalThis.Blob === 'undefined') {
22
- globalThis.Blob = BlobU || BlobNF;
21
+ globalThis.Blob = BlobNF;
23
22
  }
@@ -5,12 +5,11 @@ export default function getOperationRaw(spec, id) {
5
5
  if (!spec || !spec.paths) {
6
6
  return null;
7
7
  }
8
- return findOperation(spec, _ref => {
9
- let {
10
- pathName,
11
- method,
12
- operation
13
- } = _ref;
8
+ return findOperation(spec, ({
9
+ pathName,
10
+ method,
11
+ operation
12
+ }) => {
14
13
  if (!operation || typeof operation !== 'object') {
15
14
  return false;
16
15
  }
@@ -1,8 +1,7 @@
1
1
  import replaceSpecialCharsWithUnderscore from '../replace-special-chars-with-underscore.js';
2
- export default function idFromPathMethod(pathName, method) {
3
- let {
4
- v2OperationIdCompatibilityMode
5
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2
+ export default function idFromPathMethod(pathName, method, {
3
+ v2OperationIdCompatibilityMode
4
+ } = {}) {
6
5
  if (v2OperationIdCompatibilityMode) {
7
6
  let res = `${method.toLowerCase()}_${pathName}`.replace(/[\s!@#$%^&*()_+=[{\]};:<>|./?,\\'""-]/g, '_');
8
7
  res = res || `${pathName.substring(1)}_${method}`;
@@ -1,10 +1,8 @@
1
1
  import idFromPathMethod from './id-from-path-method/index.js';
2
2
  import replaceSpecialCharsWithUnderscore from './replace-special-chars-with-underscore.js';
3
- export default function opId(operation, pathName) {
4
- let method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
5
- let {
6
- v2OperationIdCompatibilityMode
7
- } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3
+ export default function opId(operation, pathName, method = '', {
4
+ v2OperationIdCompatibilityMode
5
+ } = {}) {
8
6
  if (!operation || typeof operation !== 'object') {
9
7
  return null;
10
8
  }
package/es/http/index.js CHANGED
@@ -11,8 +11,7 @@ export const self = {
11
11
 
12
12
  // Handles fetch-like syntax and the case where there is only one object passed-in
13
13
  // (which will have the URL as a property). Also serializes the response.
14
- export default async function http(url) {
15
- let request = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
+ export default async function http(url, request = {}) {
16
15
  if (typeof url === 'object') {
17
16
  request = url;
18
17
  url = request.url;
@@ -84,10 +83,7 @@ export default async function http(url) {
84
83
  }
85
84
 
86
85
  // exported for testing
87
- export const shouldDownloadAsText = function () {
88
- let contentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
89
- return /(json|xml|yaml|text)\b/.test(contentType);
90
- };
86
+ export const shouldDownloadAsText = (contentType = '') => /(json|xml|yaml|text)\b/.test(contentType);
91
87
  function parseBody(body, contentType) {
92
88
  if (contentType && (contentType.indexOf('application/json') === 0 || contentType.indexOf('+json') > 0)) {
93
89
  return JSON.parse(body);
@@ -96,10 +92,9 @@ function parseBody(body, contentType) {
96
92
  }
97
93
 
98
94
  // Serialize the response, returns a promise with headers and the body part of the hash
99
- export function serializeRes(oriRes, url) {
100
- let {
101
- loadSpec = false
102
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
95
+ export function serializeRes(oriRes, url, {
96
+ loadSpec = false
97
+ } = {}) {
103
98
  const res = {
104
99
  ok: oriRes.ok,
105
100
  url: oriRes.url || url,
@@ -135,11 +130,9 @@ function serializeHeaderValue(value) {
135
130
  // eg: Cookie: one
136
131
  // Cookie: two
137
132
  // = { Cookie: [ "one", "two" ]
138
- export function serializeHeaders() {
139
- let headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
133
+ export function serializeHeaders(headers = {}) {
140
134
  if (typeof headers.entries !== 'function') return {};
141
- return Array.from(headers.entries()).reduce((acc, _ref) => {
142
- let [header, value] = _ref;
135
+ return Array.from(headers.entries()).reduce((acc, [header, value]) => {
143
136
  acc[header] = serializeHeaderValue(value);
144
137
  return acc;
145
138
  }, {});
@@ -190,9 +183,7 @@ const SEPARATORS = {
190
183
  * is defined within the Media Type Object (OpenAPI 3.x.y).
191
184
  */
192
185
  class FileWithData extends File {
193
- constructor(data) {
194
- let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
195
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
186
+ constructor(data, name = '', options = {}) {
196
187
  super([data], name, options);
197
188
  this.data = data;
198
189
  }
@@ -212,8 +203,7 @@ class FileWithData extends File {
212
203
  // Return value example 4: [['color', 'R,100,G,200,B,150']]
213
204
  // Return value example 5: [['R', '100'], ['G', '200'], ['B', '150']]
214
205
  // Return value example 6: [['color[R]', '100'], ['color[G]', '200'], ['color[B]', '150']]
215
- function formatKeyValue(key, input) {
216
- let skipEncoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
206
+ function formatKeyValue(key, input, skipEncoding = false) {
217
207
  const {
218
208
  collectionFormat,
219
209
  allowEmptyValue,
@@ -351,8 +341,7 @@ function buildFormData(reqForm) {
351
341
  * @param {Object} reqForm - ori req.form
352
342
  * @return {FormData} - new FormData instance
353
343
  */
354
- return Object.entries(reqForm).reduce((formData, _ref2) => {
355
- let [name, input] = _ref2;
344
+ return Object.entries(reqForm).reduce((formData, [name, input]) => {
356
345
  // eslint-disable-next-line no-restricted-syntax
357
346
  for (const [key, value] of formatKeyValue(name, input, true)) {
358
347
  if (Array.isArray(value)) {
@@ -403,21 +392,16 @@ export function encodeFormOrQuery(data) {
403
392
 
404
393
  // If the request has a `query` object, merge it into the request.url, and delete the object
405
394
  // If file and/or multipart, also create FormData instance
406
- export function mergeInQueryOrForm() {
407
- let req = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
395
+ export function mergeInQueryOrForm(req = {}) {
408
396
  const {
409
397
  url = '',
410
398
  query,
411
399
  form
412
400
  } = req;
413
- const joinSearch = function () {
414
- for (var _len = arguments.length, strs = new Array(_len), _key = 0; _key < _len; _key++) {
415
- strs[_key] = arguments[_key];
416
- }
401
+ const joinSearch = (...strs) => {
417
402
  const search = strs.filter(a => a).join('&'); // Only truthy value
418
403
  return search ? `?${search}` : ''; // Only add '?' if there is a str
419
404
  };
420
-
421
405
  if (form) {
422
406
  const hasFile = Object.keys(form).some(key => {
423
407
  const {
package/es/index.js CHANGED
@@ -61,8 +61,7 @@ Swagger.apidom = {
61
61
  }
62
62
  }
63
63
  };
64
- function Swagger(url) {
65
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
+ function Swagger(url, opts = {}) {
66
65
  // Allow url as a separate argument
67
66
  if (typeof url === 'string') {
68
67
  opts.url = url;
@@ -100,8 +99,7 @@ Swagger.prototype = {
100
99
  ...options
101
100
  });
102
101
  },
103
- resolve() {
104
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
102
+ resolve(options = {}) {
105
103
  return Swagger.resolve({
106
104
  spec: this.spec,
107
105
  url: this.url,