swagger-client 3.13.0 → 3.13.5
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.
- package/README.md +1 -1
- package/dist/swagger-client.browser.js +1439 -2075
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +28 -42
- package/es/execute/oas3/build-request.js +44 -26
- package/es/execute/oas3/content-serializer.js +1 -1
- package/es/execute/oas3/parameter-builders.js +3 -5
- package/es/execute/oas3/style-serializer.js +36 -43
- package/es/execute/swagger2/build-request.js +17 -17
- package/es/execute/swagger2/parameter-builders.js +1 -4
- package/es/helpers.js +6 -13
- package/es/http.js +64 -82
- package/es/index.js +1 -2
- package/es/interfaces.js +3 -6
- package/es/internal/form-data-monkey-patch.js +4 -7
- package/es/resolver.js +1 -1
- package/es/specmap/helpers.js +7 -14
- package/es/specmap/index.js +64 -75
- package/es/specmap/lib/all-of.js +4 -10
- package/es/specmap/lib/context-tree.js +4 -10
- package/es/specmap/lib/index.js +25 -30
- package/es/specmap/lib/parameters.js +3 -6
- package/es/specmap/lib/refs.js +20 -33
- package/es/subtree-resolver/index.js +2 -3
- package/lib/execute/index.js +3 -3
- package/lib/execute/oas3/build-request.js +13 -0
- package/lib/execute/oas3/parameter-builders.js +2 -2
- package/lib/execute/swagger2/build-request.js +5 -0
- package/lib/index.js +3 -3
- package/lib/interfaces.js +1 -1
- package/lib/resolver.js +2 -2
- package/lib/specmap/index.js +1 -1
- package/lib/specmap/lib/all-of.js +1 -1
- package/lib/specmap/lib/context-tree.js +1 -1
- package/lib/specmap/lib/index.js +3 -3
- package/lib/specmap/lib/parameters.js +1 -1
- package/lib/specmap/lib/properties.js +1 -1
- package/lib/subtree-resolver/index.js +1 -1
- package/package.json +23 -26
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
2
1
|
// These functions will update the request.
|
|
3
2
|
// They'll be given {req, value, paramter, spec, operation}.
|
|
4
3
|
export default {
|
|
@@ -53,8 +52,6 @@ function pathBuilder(_ref4) {
|
|
|
53
52
|
|
|
54
53
|
|
|
55
54
|
function queryBuilder(_ref5) {
|
|
56
|
-
var _context;
|
|
57
|
-
|
|
58
55
|
var req = _ref5.req,
|
|
59
56
|
value = _ref5.value,
|
|
60
57
|
parameter = _ref5.parameter;
|
|
@@ -64,7 +61,7 @@ function queryBuilder(_ref5) {
|
|
|
64
61
|
value = 'false';
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
if (value === 0 &&
|
|
64
|
+
if (value === 0 && ['number', 'integer'].indexOf(parameter.type) > -1) {
|
|
68
65
|
value = '0';
|
|
69
66
|
}
|
|
70
67
|
|
package/es/helpers.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _createForOfIteratorHelper from "@babel/runtime-corejs3/helpers/createForOfIteratorHelper";
|
|
2
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
3
|
-
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
|
4
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
5
2
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
6
4
|
import isObject from 'lodash/isObject';
|
|
7
5
|
import startsWith from 'lodash/startsWith';
|
|
8
6
|
|
|
@@ -84,8 +82,6 @@ export function getOperationRaw(spec, id) {
|
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
return findOperation(spec, function (_ref3) {
|
|
87
|
-
var _context5;
|
|
88
|
-
|
|
89
85
|
var pathName = _ref3.pathName,
|
|
90
86
|
method = _ref3.method,
|
|
91
87
|
operation = _ref3.operation;
|
|
@@ -98,7 +94,7 @@ export function getOperationRaw(spec, id) {
|
|
|
98
94
|
|
|
99
95
|
var operationId = opId(operation, pathName, method);
|
|
100
96
|
var legacyOperationId = legacyIdFromPathMethod(pathName, method);
|
|
101
|
-
return
|
|
97
|
+
return [operationId, legacyOperationId, rawOperationId].some(function (val) {
|
|
102
98
|
return val && val === id;
|
|
103
99
|
});
|
|
104
100
|
});
|
|
@@ -187,12 +183,12 @@ export function normalizeSwagger(parsedSpec) {
|
|
|
187
183
|
var opList = map[oid];
|
|
188
184
|
|
|
189
185
|
if (opList.length > 1) {
|
|
190
|
-
|
|
191
|
-
var
|
|
186
|
+
opList.forEach(function (o, i) {
|
|
187
|
+
var _context5;
|
|
192
188
|
|
|
193
189
|
// eslint-disable-next-line no-underscore-dangle
|
|
194
190
|
o.__originalOperationId = o.__originalOperationId || o.operationId;
|
|
195
|
-
o.operationId = _concatInstanceProperty(
|
|
191
|
+
o.operationId = _concatInstanceProperty(_context5 = "".concat(oid)).call(_context5, i + 1);
|
|
196
192
|
});
|
|
197
193
|
} else if (typeof operation.operationId !== 'undefined') {
|
|
198
194
|
// Ensure we always add the normalized operation ID if one already exists
|
|
@@ -244,11 +240,8 @@ export function normalizeSwagger(parsedSpec) {
|
|
|
244
240
|
|
|
245
241
|
try {
|
|
246
242
|
var _loop2 = function _loop2() {
|
|
247
|
-
var _context7;
|
|
248
|
-
|
|
249
243
|
var param = _step2.value;
|
|
250
|
-
|
|
251
|
-
var exists = _someInstanceProperty(_context7 = operation[inheritName]).call(_context7, function (opParam) {
|
|
244
|
+
var exists = operation[inheritName].some(function (opParam) {
|
|
252
245
|
return opParam.name && opParam.name === param.name || opParam.$ref && opParam.$ref === param.$ref || opParam.$$ref && opParam.$$ref === param.$$ref || opParam === param;
|
|
253
246
|
});
|
|
254
247
|
|
package/es/http.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
2
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
3
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
4
1
|
import _createForOfIteratorHelper from "@babel/runtime-corejs3/helpers/createForOfIteratorHelper";
|
|
5
|
-
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
6
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
7
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
8
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
9
|
-
import _everyInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/every";
|
|
10
|
-
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
11
|
-
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
|
12
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
13
2
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
14
3
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
15
|
-
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
16
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
17
|
-
import _entriesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/entries";
|
|
18
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
19
|
-
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
20
4
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
6
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
7
|
+
import _entriesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/entries";
|
|
8
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
9
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
10
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
11
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
12
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
13
|
+
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
14
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
21
15
|
import 'cross-fetch/polyfill';
|
|
22
16
|
/* global fetch */
|
|
23
17
|
|
|
@@ -42,16 +36,15 @@ export default function http(_x) {
|
|
|
42
36
|
function _http() {
|
|
43
37
|
_http = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
44
38
|
var request,
|
|
45
|
-
_context11,
|
|
46
39
|
contentType,
|
|
47
40
|
res,
|
|
48
41
|
error,
|
|
49
42
|
_error,
|
|
50
43
|
_args = arguments;
|
|
51
44
|
|
|
52
|
-
return _regeneratorRuntime.wrap(function _callee$(
|
|
45
|
+
return _regeneratorRuntime.wrap(function _callee$(_context6) {
|
|
53
46
|
while (1) {
|
|
54
|
-
switch (
|
|
47
|
+
switch (_context6.prev = _context6.next) {
|
|
55
48
|
case 0:
|
|
56
49
|
request = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
57
50
|
|
|
@@ -69,7 +62,7 @@ function _http() {
|
|
|
69
62
|
// Context: https://stackoverflow.com/a/50709178
|
|
70
63
|
|
|
71
64
|
if (request.headers) {
|
|
72
|
-
|
|
65
|
+
_Object$keys(request.headers).forEach(function (headerName) {
|
|
73
66
|
var value = request.headers[headerName];
|
|
74
67
|
|
|
75
68
|
if (typeof value === 'string') {
|
|
@@ -82,25 +75,25 @@ function _http() {
|
|
|
82
75
|
|
|
83
76
|
|
|
84
77
|
if (!request.requestInterceptor) {
|
|
85
|
-
|
|
78
|
+
_context6.next = 12;
|
|
86
79
|
break;
|
|
87
80
|
}
|
|
88
81
|
|
|
89
|
-
|
|
82
|
+
_context6.next = 8;
|
|
90
83
|
return request.requestInterceptor(request);
|
|
91
84
|
|
|
92
85
|
case 8:
|
|
93
|
-
|
|
86
|
+
_context6.t0 = _context6.sent;
|
|
94
87
|
|
|
95
|
-
if (
|
|
96
|
-
|
|
88
|
+
if (_context6.t0) {
|
|
89
|
+
_context6.next = 11;
|
|
97
90
|
break;
|
|
98
91
|
}
|
|
99
92
|
|
|
100
|
-
|
|
93
|
+
_context6.t0 = request;
|
|
101
94
|
|
|
102
95
|
case 11:
|
|
103
|
-
request =
|
|
96
|
+
request = _context6.t0;
|
|
104
97
|
|
|
105
98
|
case 12:
|
|
106
99
|
// for content-type=multipart\/form-data remove content-type from request before fetch
|
|
@@ -113,64 +106,64 @@ function _http() {
|
|
|
113
106
|
} // eslint-disable-next-line no-undef
|
|
114
107
|
|
|
115
108
|
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
_context6.prev = 14;
|
|
110
|
+
_context6.next = 17;
|
|
118
111
|
return (request.userFetch || fetch)(request.url, request);
|
|
119
112
|
|
|
120
113
|
case 17:
|
|
121
|
-
res =
|
|
122
|
-
|
|
114
|
+
res = _context6.sent;
|
|
115
|
+
_context6.next = 20;
|
|
123
116
|
return self.serializeRes(res, url, request);
|
|
124
117
|
|
|
125
118
|
case 20:
|
|
126
|
-
res =
|
|
119
|
+
res = _context6.sent;
|
|
127
120
|
|
|
128
121
|
if (!request.responseInterceptor) {
|
|
129
|
-
|
|
122
|
+
_context6.next = 28;
|
|
130
123
|
break;
|
|
131
124
|
}
|
|
132
125
|
|
|
133
|
-
|
|
126
|
+
_context6.next = 24;
|
|
134
127
|
return request.responseInterceptor(res);
|
|
135
128
|
|
|
136
129
|
case 24:
|
|
137
|
-
|
|
130
|
+
_context6.t1 = _context6.sent;
|
|
138
131
|
|
|
139
|
-
if (
|
|
140
|
-
|
|
132
|
+
if (_context6.t1) {
|
|
133
|
+
_context6.next = 27;
|
|
141
134
|
break;
|
|
142
135
|
}
|
|
143
136
|
|
|
144
|
-
|
|
137
|
+
_context6.t1 = res;
|
|
145
138
|
|
|
146
139
|
case 27:
|
|
147
|
-
res =
|
|
140
|
+
res = _context6.t1;
|
|
148
141
|
|
|
149
142
|
case 28:
|
|
150
|
-
|
|
143
|
+
_context6.next = 39;
|
|
151
144
|
break;
|
|
152
145
|
|
|
153
146
|
case 30:
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
_context6.prev = 30;
|
|
148
|
+
_context6.t2 = _context6["catch"](14);
|
|
156
149
|
|
|
157
150
|
if (res) {
|
|
158
|
-
|
|
151
|
+
_context6.next = 34;
|
|
159
152
|
break;
|
|
160
153
|
}
|
|
161
154
|
|
|
162
|
-
throw
|
|
155
|
+
throw _context6.t2;
|
|
163
156
|
|
|
164
157
|
case 34:
|
|
165
158
|
error = new Error(res.statusText);
|
|
166
159
|
error.status = res.status;
|
|
167
160
|
error.statusCode = res.status;
|
|
168
|
-
error.responseError =
|
|
161
|
+
error.responseError = _context6.t2;
|
|
169
162
|
throw error;
|
|
170
163
|
|
|
171
164
|
case 39:
|
|
172
165
|
if (res.ok) {
|
|
173
|
-
|
|
166
|
+
_context6.next = 45;
|
|
174
167
|
break;
|
|
175
168
|
}
|
|
176
169
|
|
|
@@ -181,11 +174,11 @@ function _http() {
|
|
|
181
174
|
throw _error;
|
|
182
175
|
|
|
183
176
|
case 45:
|
|
184
|
-
return
|
|
177
|
+
return _context6.abrupt("return", res);
|
|
185
178
|
|
|
186
179
|
case 46:
|
|
187
180
|
case "end":
|
|
188
|
-
return
|
|
181
|
+
return _context6.stop();
|
|
189
182
|
}
|
|
190
183
|
}
|
|
191
184
|
}, _callee, null, [[14, 30]]);
|
|
@@ -199,7 +192,7 @@ export var shouldDownloadAsText = function shouldDownloadAsText() {
|
|
|
199
192
|
};
|
|
200
193
|
|
|
201
194
|
function parseBody(body, contentType) {
|
|
202
|
-
if (contentType && (
|
|
195
|
+
if (contentType && (contentType.indexOf('application/json') === 0 || contentType.indexOf('+json') > 0)) {
|
|
203
196
|
return JSON.parse(body);
|
|
204
197
|
}
|
|
205
198
|
|
|
@@ -252,11 +245,9 @@ function serializeHeaderValue(value) {
|
|
|
252
245
|
|
|
253
246
|
|
|
254
247
|
export function serializeHeaders() {
|
|
255
|
-
var _context;
|
|
256
|
-
|
|
257
248
|
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
258
249
|
if (!isFunction(_entriesInstanceProperty(headers))) return {};
|
|
259
|
-
return
|
|
250
|
+
return _Array$from(_entriesInstanceProperty(headers).call(headers)).reduce(function (acc, _ref2) {
|
|
260
251
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
261
252
|
header = _ref3[0],
|
|
262
253
|
value = _ref3[1];
|
|
@@ -297,7 +288,7 @@ export function isFile(obj, navigatorObj) {
|
|
|
297
288
|
}
|
|
298
289
|
|
|
299
290
|
function isArrayOfFile(obj, navigatorObj) {
|
|
300
|
-
return
|
|
291
|
+
return Array.isArray(obj) && obj.some(function (v) {
|
|
301
292
|
return isFile(v, navigatorObj);
|
|
302
293
|
});
|
|
303
294
|
}
|
|
@@ -328,7 +319,7 @@ function formatKeyValue(key, input) {
|
|
|
328
319
|
serializationOption = input.serializationOption,
|
|
329
320
|
encoding = input.encoding; // `input` can be string
|
|
330
321
|
|
|
331
|
-
var value = _typeof(input) === 'object' && !
|
|
322
|
+
var value = _typeof(input) === 'object' && !Array.isArray(input) ? input.value : input;
|
|
332
323
|
var encodeFn = skipEncoding ? function (k) {
|
|
333
324
|
return k.toString();
|
|
334
325
|
} : function (k) {
|
|
@@ -352,9 +343,7 @@ function formatKeyValue(key, input) {
|
|
|
352
343
|
|
|
353
344
|
|
|
354
345
|
if (encoding) {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (_someInstanceProperty(_context2 = [_typeof(encoding.style), _typeof(encoding.explode), _typeof(encoding.allowReserved)]).call(_context2, function (type) {
|
|
346
|
+
if ([_typeof(encoding.style), _typeof(encoding.explode), _typeof(encoding.allowReserved)].some(function (type) {
|
|
358
347
|
return type !== 'undefined';
|
|
359
348
|
})) {
|
|
360
349
|
return formatKeyValueBySerializationOption(key, value, skipEncoding, pick(encoding, ['style', 'explode', 'allowReserved']));
|
|
@@ -376,7 +365,7 @@ function formatKeyValue(key, input) {
|
|
|
376
365
|
} // Array of primitives
|
|
377
366
|
|
|
378
367
|
|
|
379
|
-
if (
|
|
368
|
+
if (Array.isArray(value) && value.every(function (v) {
|
|
380
369
|
return _typeof(v) !== 'object';
|
|
381
370
|
})) {
|
|
382
371
|
return [[encodedKey, _mapInstanceProperty(value).call(value, encodeFn).join(',')]];
|
|
@@ -393,7 +382,7 @@ function formatKeyValue(key, input) {
|
|
|
393
382
|
} // Array
|
|
394
383
|
|
|
395
384
|
|
|
396
|
-
if (
|
|
385
|
+
if (Array.isArray(value)) {
|
|
397
386
|
if (collectionFormat === 'multi') {
|
|
398
387
|
// In case of multipart/formdata, it is used as array.
|
|
399
388
|
// Otherwise, the caller will convert it to a query by qs.stringify.
|
|
@@ -408,7 +397,7 @@ function formatKeyValue(key, input) {
|
|
|
408
397
|
}
|
|
409
398
|
|
|
410
399
|
function formatKeyValueBySerializationOption(key, value, skipEncoding, serializationOption) {
|
|
411
|
-
var
|
|
400
|
+
var _context4;
|
|
412
401
|
|
|
413
402
|
var style = serializationOption.style || 'form';
|
|
414
403
|
var explode = typeof serializationOption.explode === 'undefined' ? style === 'form' : serializationOption.explode; // eslint-disable-next-line no-nested-ternary
|
|
@@ -434,7 +423,7 @@ function formatKeyValueBySerializationOption(key, value, skipEncoding, serializa
|
|
|
434
423
|
} // Array
|
|
435
424
|
|
|
436
425
|
|
|
437
|
-
if (
|
|
426
|
+
if (Array.isArray(value)) {
|
|
438
427
|
if (explode) {
|
|
439
428
|
// In case of multipart/formdata, it is used as array.
|
|
440
429
|
// Otherwise, the caller will convert it to a query by qs.stringify.
|
|
@@ -446,33 +435,31 @@ function formatKeyValueBySerializationOption(key, value, skipEncoding, serializa
|
|
|
446
435
|
|
|
447
436
|
|
|
448
437
|
if (style === 'deepObject') {
|
|
449
|
-
var
|
|
438
|
+
var _context;
|
|
450
439
|
|
|
451
|
-
return _mapInstanceProperty(
|
|
452
|
-
var
|
|
440
|
+
return _mapInstanceProperty(_context = _Object$keys(value)).call(_context, function (valueKey) {
|
|
441
|
+
var _context2;
|
|
453
442
|
|
|
454
|
-
return [encodeKeyFn(_concatInstanceProperty(
|
|
443
|
+
return [encodeKeyFn(_concatInstanceProperty(_context2 = "".concat(key, "[")).call(_context2, valueKey, "]")), encodeFn(value[valueKey])];
|
|
455
444
|
});
|
|
456
445
|
}
|
|
457
446
|
|
|
458
447
|
if (explode) {
|
|
459
|
-
var
|
|
448
|
+
var _context3;
|
|
460
449
|
|
|
461
|
-
return _mapInstanceProperty(
|
|
450
|
+
return _mapInstanceProperty(_context3 = _Object$keys(value)).call(_context3, function (valueKey) {
|
|
462
451
|
return [encodeKeyFn(valueKey), encodeFn(value[valueKey])];
|
|
463
452
|
});
|
|
464
453
|
}
|
|
465
454
|
|
|
466
|
-
return [[encodeKeyFn(key), _mapInstanceProperty(
|
|
467
|
-
var
|
|
455
|
+
return [[encodeKeyFn(key), _mapInstanceProperty(_context4 = _Object$keys(value)).call(_context4, function (valueKey) {
|
|
456
|
+
var _context5;
|
|
468
457
|
|
|
469
|
-
return [_concatInstanceProperty(
|
|
458
|
+
return [_concatInstanceProperty(_context5 = "".concat(encodeKeyFn(valueKey), ",")).call(_context5, encodeFn(value[valueKey]))];
|
|
470
459
|
}).join(',')]];
|
|
471
460
|
}
|
|
472
461
|
|
|
473
462
|
function buildFormData(reqForm) {
|
|
474
|
-
var _context8;
|
|
475
|
-
|
|
476
463
|
/**
|
|
477
464
|
* Build a new FormData instance, support array as field value
|
|
478
465
|
* OAS2.0 - when collectionFormat is multi
|
|
@@ -480,7 +467,7 @@ function buildFormData(reqForm) {
|
|
|
480
467
|
* @param {Object} reqForm - ori req.form
|
|
481
468
|
* @return {FormData} - new FormData instance
|
|
482
469
|
*/
|
|
483
|
-
return
|
|
470
|
+
return _Object$entries(reqForm).reduce(function (formData, _ref4) {
|
|
484
471
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
485
472
|
name = _ref5[0],
|
|
486
473
|
input = _ref5[1];
|
|
@@ -495,7 +482,7 @@ function buildFormData(reqForm) {
|
|
|
495
482
|
key = _step$value[0],
|
|
496
483
|
value = _step$value[1];
|
|
497
484
|
|
|
498
|
-
if (
|
|
485
|
+
if (Array.isArray(value)) {
|
|
499
486
|
// eslint-disable-next-line no-restricted-syntax
|
|
500
487
|
var _iterator2 = _createForOfIteratorHelper(value),
|
|
501
488
|
_step2;
|
|
@@ -526,15 +513,13 @@ function buildFormData(reqForm) {
|
|
|
526
513
|
|
|
527
514
|
|
|
528
515
|
export function encodeFormOrQuery(data) {
|
|
529
|
-
var _context9;
|
|
530
|
-
|
|
531
516
|
/**
|
|
532
517
|
* Encode parameter names and values
|
|
533
518
|
* @param {Object} result - parameter names and values
|
|
534
519
|
* @param {string} parameterName - Parameter name
|
|
535
520
|
* @return {object} encoded parameter names and values
|
|
536
521
|
*/
|
|
537
|
-
var encodedQuery =
|
|
522
|
+
var encodedQuery = _Object$keys(data).reduce(function (result, parameterName) {
|
|
538
523
|
// eslint-disable-next-line no-restricted-syntax
|
|
539
524
|
var _iterator3 = _createForOfIteratorHelper(formatKeyValue(parameterName, data[parameterName])),
|
|
540
525
|
_step3;
|
|
@@ -584,9 +569,7 @@ export function mergeInQueryOrForm() {
|
|
|
584
569
|
};
|
|
585
570
|
|
|
586
571
|
if (form) {
|
|
587
|
-
var
|
|
588
|
-
|
|
589
|
-
var hasFile = _someInstanceProperty(_context10 = _Object$keys(form)).call(_context10, function (key) {
|
|
572
|
+
var hasFile = _Object$keys(form).some(function (key) {
|
|
590
573
|
var value = form[key].value;
|
|
591
574
|
return isFile(value) || isArrayOfFile(value);
|
|
592
575
|
});
|
|
@@ -615,10 +598,9 @@ export function mergeInQueryOrForm() {
|
|
|
615
598
|
|
|
616
599
|
var keysToRemove = _Object$keys(query);
|
|
617
600
|
|
|
618
|
-
|
|
601
|
+
keysToRemove.forEach(function (key) {
|
|
619
602
|
return delete oriQuery[key];
|
|
620
603
|
});
|
|
621
|
-
|
|
622
604
|
newStr = qs.stringify(oriQuery, {
|
|
623
605
|
encode: true
|
|
624
606
|
});
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
|
|
2
|
-
import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
|
|
3
2
|
import assign from 'lodash/assign';
|
|
4
3
|
import startsWith from 'lodash/startsWith';
|
|
5
4
|
import Url from 'url';
|
|
@@ -10,7 +9,7 @@ import { makeApisTagOperation } from './interfaces';
|
|
|
10
9
|
import { execute, buildRequest, baseUrl } from './execute';
|
|
11
10
|
import { opId } from './helpers';
|
|
12
11
|
Swagger.http = Http;
|
|
13
|
-
Swagger.makeHttp =
|
|
12
|
+
Swagger.makeHttp = makeHttp.bind(null, Swagger.http);
|
|
14
13
|
Swagger.resolve = Resolver;
|
|
15
14
|
Swagger.resolveSubtree = resolveSubtree;
|
|
16
15
|
Swagger.execute = execute;
|
package/es/interfaces.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
2
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
3
1
|
import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
|
|
4
|
-
import
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
5
3
|
import pick from 'lodash/pick';
|
|
6
4
|
import { eachOperation, opId } from './helpers';
|
|
7
5
|
|
|
@@ -10,7 +8,7 @@ var nullFn = function nullFn() {
|
|
|
10
8
|
};
|
|
11
9
|
|
|
12
10
|
var normalizeArray = function normalizeArray(arg) {
|
|
13
|
-
return
|
|
11
|
+
return Array.isArray(arg) ? arg : [arg];
|
|
14
12
|
}; // To allow stubbing of functions
|
|
15
13
|
|
|
16
14
|
|
|
@@ -106,8 +104,7 @@ export function mapTagOperations(_ref2) {
|
|
|
106
104
|
method = _ref3.method,
|
|
107
105
|
operation = _ref3.operation;
|
|
108
106
|
var tags = operation.tags ? normalizeArray(operation.tags) : [defaultTag];
|
|
109
|
-
|
|
110
|
-
_forEachInstanceProperty(tags).call(tags, function (tag) {
|
|
107
|
+
tags.forEach(function (tag) {
|
|
111
108
|
if (typeof tag !== 'string') {
|
|
112
109
|
return;
|
|
113
110
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
|
2
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
3
|
-
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
4
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
5
1
|
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
6
2
|
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
7
3
|
import _get from "@babel/runtime-corejs3/helpers/get";
|
|
8
4
|
import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
|
|
9
5
|
import _inherits from "@babel/runtime-corejs3/helpers/inherits";
|
|
10
6
|
import _createSuper from "@babel/runtime-corejs3/helpers/createSuper";
|
|
7
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
8
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
9
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
11
10
|
import isFunction from 'lodash/isFunction';
|
|
12
11
|
import IsomorphicFormData from 'isomorphic-form-data'; // patches FormData type by mutating it.
|
|
13
12
|
// patch :: FormData -> PatchedFormData
|
|
@@ -91,9 +90,7 @@ export var patch = function patch(FormData) {
|
|
|
91
90
|
}, {
|
|
92
91
|
key: "has",
|
|
93
92
|
value: function has(field) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return _someInstanceProperty(_context5 = this.entryList).call(_context5, function (entry) {
|
|
93
|
+
return this.entryList.some(function (entry) {
|
|
97
94
|
return entry.name === field;
|
|
98
95
|
});
|
|
99
96
|
}
|
package/es/resolver.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
3
|
import Http from './http';
|
|
4
4
|
import mapSpec, { plugins } from './specmap';
|
|
5
5
|
import { normalizeSwagger } from './helpers';
|
package/es/specmap/helpers.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
2
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
4
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
5
2
|
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
8
5
|
import traverse from 'traverse';
|
|
9
6
|
import URL from 'url';
|
|
10
7
|
import isString from 'lodash/isString'; // This will match if the direct parent's key exactly matches an item.
|
|
@@ -30,14 +27,12 @@ export function isFreelyNamed(parentPath) {
|
|
|
30
27
|
var grandparentKey = parentPath[parentPath.length - 2];
|
|
31
28
|
var parentStr = parentPath.join('/');
|
|
32
29
|
return (// eslint-disable-next-line max-len
|
|
33
|
-
|
|
34
|
-
return
|
|
30
|
+
freelyNamedKeyParents.indexOf(parentKey) > -1 && nonFreelyNamedKeyGrandparents.indexOf(grandparentKey) === -1 || freelyNamedPaths.indexOf(parentStr) > -1 || freelyNamedAncestors.some(function (el) {
|
|
31
|
+
return parentStr.indexOf(el) > -1;
|
|
35
32
|
})
|
|
36
33
|
);
|
|
37
34
|
}
|
|
38
35
|
export function generateAbsoluteRefPatches(obj, basePath) {
|
|
39
|
-
var _context2;
|
|
40
|
-
|
|
41
36
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
42
37
|
specmap = _ref.specmap,
|
|
43
38
|
_ref$getBaseUrlForNod = _ref.getBaseUrlForNodePath,
|
|
@@ -50,8 +45,7 @@ export function generateAbsoluteRefPatches(obj, basePath) {
|
|
|
50
45
|
targetKeys = _ref$targetKeys === void 0 ? ['$ref', '$$ref'] : _ref$targetKeys;
|
|
51
46
|
|
|
52
47
|
var patches = [];
|
|
53
|
-
|
|
54
|
-
_forEachInstanceProperty(_context2 = traverse(obj)).call(_context2, function callback() {
|
|
48
|
+
traverse(obj).forEach(function callback() {
|
|
55
49
|
if (_includesInstanceProperty(targetKeys).call(targetKeys, this.key) && isString(this.node)) {
|
|
56
50
|
var nodePath = this.path; // this node's path, relative to `obj`
|
|
57
51
|
|
|
@@ -61,11 +55,10 @@ export function generateAbsoluteRefPatches(obj, basePath) {
|
|
|
61
55
|
patches.push(specmap.replace(fullPath, absolutifiedRefValue));
|
|
62
56
|
}
|
|
63
57
|
});
|
|
64
|
-
|
|
65
58
|
return patches;
|
|
66
59
|
}
|
|
67
60
|
export function absolutifyPointer(pointer, baseUrl) {
|
|
68
|
-
var
|
|
61
|
+
var _context2;
|
|
69
62
|
|
|
70
63
|
var _pointer$split = pointer.split('#'),
|
|
71
64
|
_pointer$split2 = _slicedToArray(_pointer$split, 2),
|
|
@@ -73,5 +66,5 @@ export function absolutifyPointer(pointer, baseUrl) {
|
|
|
73
66
|
fragmentPart = _pointer$split2[1];
|
|
74
67
|
|
|
75
68
|
var newRefUrlPart = URL.resolve(urlPart || '', baseUrl || '');
|
|
76
|
-
return fragmentPart ? _concatInstanceProperty(
|
|
69
|
+
return fragmentPart ? _concatInstanceProperty(_context2 = "".concat(newRefUrlPart, "#")).call(_context2, fragmentPart) : newRefUrlPart;
|
|
77
70
|
}
|