swagger-client 3.16.1 → 3.17.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.
- package/README.md +1 -1
- package/dist/swagger-client.browser.js +721 -4548
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +1 -2
- package/es/execute/oas3/build-request.js +4 -2
- package/es/execute/oas3/parameter-builders.js +8 -2
- package/es/execute/oas3/style-serializer.js +4 -4
- package/es/execute/swagger2/build-request.js +5 -3
- package/es/helpers.js +3 -3
- package/es/http/index.js +12 -8
- package/es/index.js +6 -5
- package/es/interfaces.js +8 -4
- package/es/specmap/helpers.js +2 -3
- package/es/specmap/index.js +16 -15
- package/es/specmap/lib/refs.js +12 -8
- package/lib/execute/index.js +3 -5
- package/lib/execute/oas3/build-request.js +9 -6
- package/lib/execute/oas3/parameter-builders.js +14 -7
- package/lib/execute/oas3/style-serializer.js +3 -6
- package/lib/execute/swagger2/build-request.js +9 -4
- package/lib/helpers.js +7 -9
- package/lib/http/index.js +20 -16
- package/lib/index.js +4 -8
- package/lib/interfaces.js +19 -14
- package/lib/resolver.js +1 -1
- package/lib/specmap/helpers.js +3 -5
- package/lib/specmap/index.js +6 -8
- package/lib/specmap/lib/refs.js +4 -4
- package/package.json +11 -13
package/es/execute/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
|
|
|
11
11
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
12
12
|
import getIn from 'lodash/get';
|
|
13
13
|
import isPlainObject from 'lodash/isPlainObject';
|
|
14
|
-
import isArray from 'lodash/isArray';
|
|
15
14
|
import url from 'url';
|
|
16
15
|
import cookie from 'cookie';
|
|
17
16
|
import stockHttp, { mergeInQueryOrForm } from '../http';
|
|
@@ -91,7 +90,7 @@ export function execute(_ref) {
|
|
|
91
90
|
http: http
|
|
92
91
|
}, extras));
|
|
93
92
|
|
|
94
|
-
if (request.body && (isPlainObject(request.body) || isArray(request.body))) {
|
|
93
|
+
if (request.body && (isPlainObject(request.body) || Array.isArray(request.body))) {
|
|
95
94
|
request.body = _JSON$stringify(request.body);
|
|
96
95
|
} // Build request and execute it
|
|
97
96
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
|
|
1
2
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
2
3
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
3
4
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
@@ -6,7 +7,6 @@ import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entrie
|
|
|
6
7
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
7
8
|
// This function runs after the common function,
|
|
8
9
|
// `src/execute/index.js#buildRequest`
|
|
9
|
-
import assign from 'lodash/assign';
|
|
10
10
|
import get from 'lodash/get';
|
|
11
11
|
import isPlainObject from 'lodash/isPlainObject';
|
|
12
12
|
import btoa from 'btoa';
|
|
@@ -107,7 +107,9 @@ export function applySecurities(_ref5) {
|
|
|
107
107
|
_ref5$operation = _ref5.operation,
|
|
108
108
|
operation = _ref5$operation === void 0 ? {} : _ref5$operation,
|
|
109
109
|
spec = _ref5.spec;
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
var result = _objectSpread({}, request);
|
|
112
|
+
|
|
111
113
|
var _securities$authorize = securities.authorized,
|
|
112
114
|
authorized = _securities$authorize === void 0 ? {} : _securities$authorize;
|
|
113
115
|
var security = operation.security || spec.security || [];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
2
2
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
3
3
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
|
-
import pick from 'lodash/pick';
|
|
5
4
|
import stylize, { encodeDisallowedCharacters } from './style-serializer';
|
|
6
5
|
import serialize from './content-serializer';
|
|
7
6
|
export function path(_ref) {
|
|
@@ -53,9 +52,16 @@ export function query(_ref2) {
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
if (value) {
|
|
55
|
+
var style = parameter.style,
|
|
56
|
+
explode = parameter.explode,
|
|
57
|
+
allowReserved = parameter.allowReserved;
|
|
56
58
|
req.query[parameter.name] = {
|
|
57
59
|
value: value,
|
|
58
|
-
serializationOption:
|
|
60
|
+
serializationOption: {
|
|
61
|
+
style: style,
|
|
62
|
+
explode: explode,
|
|
63
|
+
allowReserved: allowReserved
|
|
64
|
+
}
|
|
59
65
|
};
|
|
60
66
|
} else if (parameter.allowEmptyValue && value !== undefined) {
|
|
61
67
|
var paramName = parameter.name;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
3
3
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
4
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
4
5
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
5
6
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
6
7
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
7
8
|
|
|
8
|
-
var _require = require('buffer'),
|
|
9
|
-
Buffer = _require.Buffer;
|
|
10
|
-
|
|
11
9
|
var isRfc3986Reserved = function isRfc3986Reserved(char) {
|
|
12
10
|
return ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
|
|
13
11
|
};
|
|
@@ -55,7 +53,9 @@ export function encodeDisallowedCharacters(str) {
|
|
|
55
53
|
return char;
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
var
|
|
56
|
+
var encoder = new TextEncoder();
|
|
57
|
+
|
|
58
|
+
var encoded = _mapInstanceProperty(_context2 = _mapInstanceProperty(_context3 = _Array$from(encoder.encode(char))).call(_context3, function (byte) {
|
|
59
59
|
var _context4;
|
|
60
60
|
|
|
61
61
|
return _sliceInstanceProperty(_context4 = "0".concat(byte.toString(16).toUpperCase())).call(_context4, -2);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
|
|
1
2
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
2
3
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
3
4
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
5
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
5
|
-
import btoa from 'btoa';
|
|
6
|
-
import assign from 'lodash/assign'; // This function runs after the common function,
|
|
6
|
+
import btoa from 'btoa'; // This function runs after the common function,
|
|
7
7
|
// `src/execute/index.js#buildRequest`
|
|
8
8
|
|
|
9
9
|
export default function buildRequest(options, req) {
|
|
@@ -73,7 +73,9 @@ export function applySecurities(_ref) {
|
|
|
73
73
|
_ref$operation = _ref.operation,
|
|
74
74
|
operation = _ref$operation === void 0 ? {} : _ref$operation,
|
|
75
75
|
spec = _ref.spec;
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
var result = _objectSpread({}, request);
|
|
78
|
+
|
|
77
79
|
var _securities$authorize = securities.authorized,
|
|
78
80
|
authorized = _securities$authorize === void 0 ? {} : _securities$authorize,
|
|
79
81
|
_securities$specSecur = securities.specSecurity,
|
package/es/helpers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _createForOfIteratorHelper from "@babel/runtime-corejs3/helpers/createForOfIteratorHelper";
|
|
2
2
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
3
|
+
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
|
3
4
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
5
|
import isObject from 'lodash/isObject';
|
|
5
|
-
import startsWith from 'lodash/startsWith';
|
|
6
6
|
|
|
7
7
|
var toLower = function toLower(str) {
|
|
8
8
|
return String.prototype.toLowerCase.call(str);
|
|
@@ -20,7 +20,7 @@ export function isOAS3(spec) {
|
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
return
|
|
23
|
+
return _startsWithInstanceProperty(oasVersion).call(oasVersion, '3');
|
|
24
24
|
}
|
|
25
25
|
export function isSwagger2(spec) {
|
|
26
26
|
var swaggerVersion = spec.swagger;
|
|
@@ -29,7 +29,7 @@ export function isSwagger2(spec) {
|
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return _startsWithInstanceProperty(swaggerVersion).call(swaggerVersion, '2');
|
|
33
33
|
} // Strategy for determining operationId
|
|
34
34
|
|
|
35
35
|
export function opId(operation, pathName) {
|
package/es/http/index.js
CHANGED
|
@@ -17,9 +17,6 @@ import 'cross-fetch/polyfill';
|
|
|
17
17
|
|
|
18
18
|
import qs from 'qs';
|
|
19
19
|
import jsYaml from 'js-yaml';
|
|
20
|
-
import pick from 'lodash/pick';
|
|
21
|
-
import isFunction from 'lodash/isFunction';
|
|
22
|
-
import { Buffer } from 'buffer';
|
|
23
20
|
import { FormData, File, Blob } from 'formdata-node';
|
|
24
21
|
import { encodeDisallowedCharacters } from '../execute/oas3/style-serializer';
|
|
25
22
|
import foldFormDataToRequest from './fold-formdata-to-request.node'; // For testing
|
|
@@ -247,7 +244,7 @@ function serializeHeaderValue(value) {
|
|
|
247
244
|
|
|
248
245
|
export function serializeHeaders() {
|
|
249
246
|
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
250
|
-
if (
|
|
247
|
+
if (typeof _entriesInstanceProperty(headers) !== 'function') return {};
|
|
251
248
|
return _Array$from(_entriesInstanceProperty(headers).call(headers)).reduce(function (acc, _ref2) {
|
|
252
249
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
253
250
|
header = _ref3[0],
|
|
@@ -279,7 +276,7 @@ export function isFile(obj, navigatorObj) {
|
|
|
279
276
|
return true;
|
|
280
277
|
}
|
|
281
278
|
|
|
282
|
-
if (
|
|
279
|
+
if (ArrayBuffer.isView(obj)) {
|
|
283
280
|
return true;
|
|
284
281
|
}
|
|
285
282
|
|
|
@@ -345,7 +342,14 @@ function formatKeyValue(key, input) {
|
|
|
345
342
|
if ([_typeof(encoding.style), _typeof(encoding.explode), _typeof(encoding.allowReserved)].some(function (type) {
|
|
346
343
|
return type !== 'undefined';
|
|
347
344
|
})) {
|
|
348
|
-
|
|
345
|
+
var style = encoding.style,
|
|
346
|
+
explode = encoding.explode,
|
|
347
|
+
allowReserved = encoding.allowReserved;
|
|
348
|
+
return formatKeyValueBySerializationOption(key, value, skipEncoding, {
|
|
349
|
+
style: style,
|
|
350
|
+
explode: explode,
|
|
351
|
+
allowReserved: allowReserved
|
|
352
|
+
});
|
|
349
353
|
}
|
|
350
354
|
|
|
351
355
|
if (encoding.contentType) {
|
|
@@ -495,7 +499,7 @@ function buildFormData(reqForm) {
|
|
|
495
499
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
496
500
|
var v = _step2.value;
|
|
497
501
|
|
|
498
|
-
if (
|
|
502
|
+
if (ArrayBuffer.isView(v)) {
|
|
499
503
|
var blob = new Blob([v]);
|
|
500
504
|
formData.append(key, blob);
|
|
501
505
|
} else {
|
|
@@ -507,7 +511,7 @@ function buildFormData(reqForm) {
|
|
|
507
511
|
} finally {
|
|
508
512
|
_iterator2.f();
|
|
509
513
|
}
|
|
510
|
-
} else if (
|
|
514
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
511
515
|
var _blob = new Blob([value]);
|
|
512
516
|
|
|
513
517
|
formData.append(key, _blob);
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
|
|
2
|
-
import assign from
|
|
3
|
-
import
|
|
2
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
|
+
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
|
4
4
|
import Url from 'url';
|
|
5
5
|
import Http, { makeHttp, serializeRes, serializeHeaders } from './http';
|
|
6
6
|
import Resolver, { clearCache } from './resolver';
|
|
@@ -39,10 +39,11 @@ function Swagger(url) {
|
|
|
39
39
|
return new Swagger(opts);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
assign(this, opts);
|
|
42
|
+
_Object$assign(this, opts);
|
|
43
|
+
|
|
43
44
|
var prom = this.resolve().then(function () {
|
|
44
45
|
if (!_this.disableInterfaces) {
|
|
45
|
-
assign(_this, Swagger.makeApisTagOperation(_this));
|
|
46
|
+
_Object$assign(_this, Swagger.makeApisTagOperation(_this));
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
return _this;
|
|
@@ -93,7 +94,7 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
|
|
|
93
94
|
var spec = this.spec;
|
|
94
95
|
var specUrl = this.url; // TODO: OAS3: support servers here
|
|
95
96
|
|
|
96
|
-
if (specUrl &&
|
|
97
|
+
if (specUrl && _startsWithInstanceProperty(specUrl).call(specUrl, 'http')) {
|
|
97
98
|
var parsed = Url.parse(specUrl);
|
|
98
99
|
|
|
99
100
|
if (!spec.host) {
|
package/es/interfaces.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
3
|
-
import pick from 'lodash/pick';
|
|
4
3
|
import { eachOperation, opId } from './helpers';
|
|
5
4
|
|
|
6
5
|
var nullFn = function nullFn() {
|
|
@@ -25,9 +24,14 @@ export function makeExecute() {
|
|
|
25
24
|
operationId = _ref.operationId;
|
|
26
25
|
return function (parameters) {
|
|
27
26
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
var requestInterceptor = swaggerJs.requestInterceptor,
|
|
28
|
+
responseInterceptor = swaggerJs.responseInterceptor,
|
|
29
|
+
userFetch = swaggerJs.userFetch;
|
|
30
|
+
return swaggerJs.execute(_objectSpread({
|
|
31
|
+
spec: swaggerJs.spec,
|
|
32
|
+
requestInterceptor: requestInterceptor,
|
|
33
|
+
responseInterceptor: responseInterceptor,
|
|
34
|
+
userFetch: userFetch,
|
|
31
35
|
pathName: pathName,
|
|
32
36
|
method: method,
|
|
33
37
|
parameters: parameters,
|
package/es/specmap/helpers.js
CHANGED
|
@@ -3,8 +3,7 @@ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray
|
|
|
3
3
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
4
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
5
5
|
import traverse from 'traverse';
|
|
6
|
-
import URL from 'url';
|
|
7
|
-
import isString from 'lodash/isString'; // This will match if the direct parent's key exactly matches an item.
|
|
6
|
+
import URL from 'url'; // This will match if the direct parent's key exactly matches an item.
|
|
8
7
|
|
|
9
8
|
var freelyNamedKeyParents = ['properties']; // This will match if the grandparent's key exactly matches an item.
|
|
10
9
|
// NOTE that this is for finding non-free paths!
|
|
@@ -46,7 +45,7 @@ export function generateAbsoluteRefPatches(obj, basePath) {
|
|
|
46
45
|
|
|
47
46
|
var patches = [];
|
|
48
47
|
traverse(obj).forEach(function callback() {
|
|
49
|
-
if (_includesInstanceProperty(targetKeys).call(targetKeys, this.key) &&
|
|
48
|
+
if (_includesInstanceProperty(targetKeys).call(targetKeys, this.key) && typeof this.node === 'string') {
|
|
50
49
|
var nodePath = this.path; // this node's path, relative to `obj`
|
|
51
50
|
|
|
52
51
|
var fullPath = _concatInstanceProperty(basePath).call(basePath, this.path);
|
package/es/specmap/index.js
CHANGED
|
@@ -9,11 +9,10 @@ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
|
9
9
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
10
10
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
11
11
|
import _Object$keys2 from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
12
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
12
13
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
13
14
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
|
14
15
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
15
|
-
import find from 'lodash/find';
|
|
16
|
-
import noop from 'lodash/noop';
|
|
17
16
|
import lib from './lib';
|
|
18
17
|
import refs from './lib/refs';
|
|
19
18
|
import allOf from './lib/all-of';
|
|
@@ -22,6 +21,8 @@ import properties from './lib/properties';
|
|
|
22
21
|
import ContextTree from './lib/context-tree';
|
|
23
22
|
var HARD_LIMIT = 100;
|
|
24
23
|
|
|
24
|
+
var noop = function noop() {};
|
|
25
|
+
|
|
25
26
|
var SpecMap = /*#__PURE__*/function () {
|
|
26
27
|
function SpecMap(opts) {
|
|
27
28
|
var _this = this,
|
|
@@ -279,10 +280,10 @@ var SpecMap = /*#__PURE__*/function () {
|
|
|
279
280
|
}, {
|
|
280
281
|
key: "nextPlugin",
|
|
281
282
|
value: function nextPlugin() {
|
|
282
|
-
var
|
|
283
|
+
var _context6,
|
|
284
|
+
_this2 = this;
|
|
283
285
|
|
|
284
|
-
|
|
285
|
-
return find(this.wrappedPlugins, function (plugin) {
|
|
286
|
+
return _findInstanceProperty(_context6 = this.wrappedPlugins).call(_context6, function (plugin) {
|
|
286
287
|
var mutations = _this2.getMutationsForPlugin(plugin);
|
|
287
288
|
|
|
288
289
|
return mutations.length > 0;
|
|
@@ -292,9 +293,9 @@ var SpecMap = /*#__PURE__*/function () {
|
|
|
292
293
|
key: "nextPromisedPatch",
|
|
293
294
|
value: function nextPromisedPatch() {
|
|
294
295
|
if (this.promisedPatches.length > 0) {
|
|
295
|
-
var
|
|
296
|
+
var _context7;
|
|
296
297
|
|
|
297
|
-
return _Promise.race(_mapInstanceProperty(
|
|
298
|
+
return _Promise.race(_mapInstanceProperty(_context7 = this.promisedPatches).call(_context7, function (patch) {
|
|
298
299
|
return patch.value;
|
|
299
300
|
}));
|
|
300
301
|
}
|
|
@@ -400,7 +401,7 @@ var SpecMap = /*#__PURE__*/function () {
|
|
|
400
401
|
}, {
|
|
401
402
|
key: "removePromisedPatch",
|
|
402
403
|
value: function removePromisedPatch(patch) {
|
|
403
|
-
var
|
|
404
|
+
var _context8;
|
|
404
405
|
|
|
405
406
|
var index = this.promisedPatches.indexOf(patch);
|
|
406
407
|
|
|
@@ -409,7 +410,7 @@ var SpecMap = /*#__PURE__*/function () {
|
|
|
409
410
|
return;
|
|
410
411
|
}
|
|
411
412
|
|
|
412
|
-
_spliceInstanceProperty(
|
|
413
|
+
_spliceInstanceProperty(_context8 = this.promisedPatches).call(_context8, index, 1);
|
|
413
414
|
}
|
|
414
415
|
}, {
|
|
415
416
|
key: "promisedPatchThen",
|
|
@@ -434,7 +435,7 @@ var SpecMap = /*#__PURE__*/function () {
|
|
|
434
435
|
}, {
|
|
435
436
|
key: "getMutations",
|
|
436
437
|
value: function getMutations(from, to) {
|
|
437
|
-
var
|
|
438
|
+
var _context9;
|
|
438
439
|
|
|
439
440
|
from = from || 0;
|
|
440
441
|
|
|
@@ -442,7 +443,7 @@ var SpecMap = /*#__PURE__*/function () {
|
|
|
442
443
|
to = this.mutations.length;
|
|
443
444
|
}
|
|
444
445
|
|
|
445
|
-
return _sliceInstanceProperty(
|
|
446
|
+
return _sliceInstanceProperty(_context9 = this.mutations).call(_context9, from, to);
|
|
446
447
|
}
|
|
447
448
|
}, {
|
|
448
449
|
key: "getCurrentMutations",
|
|
@@ -526,19 +527,19 @@ var SpecMap = /*#__PURE__*/function () {
|
|
|
526
527
|
that.pluginCount[plugin] = (that.pluginCount[plugin] || 0) + 1;
|
|
527
528
|
|
|
528
529
|
if (that.pluginCount[plugin] > HARD_LIMIT) {
|
|
529
|
-
var
|
|
530
|
+
var _context10;
|
|
530
531
|
|
|
531
532
|
return _Promise.resolve({
|
|
532
533
|
spec: that.state,
|
|
533
|
-
errors: _concatInstanceProperty(
|
|
534
|
+
errors: _concatInstanceProperty(_context10 = that.errors).call(_context10, new Error("We've reached a hard limit of ".concat(HARD_LIMIT, " plugin runs")))
|
|
534
535
|
});
|
|
535
536
|
} // A different plugin runs, wait for all promises to resolve, then retry
|
|
536
537
|
|
|
537
538
|
|
|
538
539
|
if (plugin !== this.currentPlugin && this.promisedPatches.length) {
|
|
539
|
-
var
|
|
540
|
+
var _context11;
|
|
540
541
|
|
|
541
|
-
var promises = _mapInstanceProperty(
|
|
542
|
+
var promises = _mapInstanceProperty(_context11 = this.promisedPatches).call(_context11, function (p) {
|
|
542
543
|
return p.value;
|
|
543
544
|
}); // Waits for all to settle instead of Promise.all which stops on rejection
|
|
544
545
|
|
package/es/specmap/lib/refs.js
CHANGED
|
@@ -6,11 +6,11 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
|
6
6
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
7
7
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
8
8
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
9
|
+
import _URLSearchParams from "@babel/runtime-corejs3/core-js-stable/url-search-params";
|
|
9
10
|
import 'cross-fetch/polyfill';
|
|
10
11
|
/* global fetch */
|
|
11
12
|
|
|
12
13
|
import jsYaml from 'js-yaml';
|
|
13
|
-
import qs from 'querystring-browser';
|
|
14
14
|
import url from 'url';
|
|
15
15
|
import lib from '.';
|
|
16
16
|
import createError from './create-error';
|
|
@@ -456,7 +456,8 @@ function unescapeJsonPointerToken(token) {
|
|
|
456
456
|
return token;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
var params = new _URLSearchParams("=".concat(token.replace(/~1/g, '/').replace(/~0/g, '~')));
|
|
460
|
+
return params.get('');
|
|
460
461
|
}
|
|
461
462
|
/**
|
|
462
463
|
* Escapes a JSON pointer.
|
|
@@ -465,7 +466,10 @@ function unescapeJsonPointerToken(token) {
|
|
|
465
466
|
|
|
466
467
|
|
|
467
468
|
function escapeJsonPointerToken(token) {
|
|
468
|
-
|
|
469
|
+
var _context4;
|
|
470
|
+
|
|
471
|
+
var params = new _URLSearchParams([['', token.replace(/~/g, '~0').replace(/\//g, '~1')]]);
|
|
472
|
+
return _sliceInstanceProperty(_context4 = params.toString()).call(_context4, 1);
|
|
469
473
|
}
|
|
470
474
|
|
|
471
475
|
function arrayToJsonPointer(arr) {
|
|
@@ -501,7 +505,7 @@ function pointerIsAParent(pointer, parentPointer) {
|
|
|
501
505
|
|
|
502
506
|
|
|
503
507
|
function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
504
|
-
var
|
|
508
|
+
var _context5, _context7;
|
|
505
509
|
|
|
506
510
|
var refs = specmapRefs.get(specmap);
|
|
507
511
|
|
|
@@ -514,7 +518,7 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
|
514
518
|
|
|
515
519
|
var parentPointer = arrayToJsonPointer(parent);
|
|
516
520
|
|
|
517
|
-
var fullyQualifiedPointer = _concatInstanceProperty(
|
|
521
|
+
var fullyQualifiedPointer = _concatInstanceProperty(_context5 = "".concat(basePath || '<specmap-base>', "#")).call(_context5, pointer); // dirty hack to strip `allof/[index]` from the path, in order to avoid cases
|
|
518
522
|
// where we get false negatives because:
|
|
519
523
|
// - we resolve a path, then
|
|
520
524
|
// - allOf plugin collapsed `allOf/[index]` out of the path, then
|
|
@@ -544,9 +548,9 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
|
544
548
|
|
|
545
549
|
var currPath = '';
|
|
546
550
|
var hasIndirectCycle = parent.some(function (token) {
|
|
547
|
-
var
|
|
551
|
+
var _context6;
|
|
548
552
|
|
|
549
|
-
currPath = _concatInstanceProperty(
|
|
553
|
+
currPath = _concatInstanceProperty(_context6 = "".concat(currPath, "/")).call(_context6, escapeJsonPointerToken(token));
|
|
550
554
|
return refs[currPath] && refs[currPath].some(function (ref) {
|
|
551
555
|
return pointerIsAParent(ref, fullyQualifiedPointer) || pointerIsAParent(fullyQualifiedPointer, ref);
|
|
552
556
|
});
|
|
@@ -558,7 +562,7 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
|
558
562
|
// No need to store if has cycle, as parent path is a dead-end and won't be checked again.
|
|
559
563
|
|
|
560
564
|
|
|
561
|
-
refs[safeParentPointer] = _concatInstanceProperty(
|
|
565
|
+
refs[safeParentPointer] = _concatInstanceProperty(_context7 = refs[safeParentPointer] || []).call(_context7, fullyQualifiedPointer);
|
|
562
566
|
return undefined;
|
|
563
567
|
}
|
|
564
568
|
/**
|
package/lib/execute/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.execute = execute;
|
|
5
|
-
exports.buildRequest = buildRequest;
|
|
6
4
|
exports.baseUrl = baseUrl;
|
|
5
|
+
exports.buildRequest = buildRequest;
|
|
6
|
+
exports.execute = execute;
|
|
7
7
|
exports.self = void 0;
|
|
8
8
|
|
|
9
9
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
10
10
|
|
|
11
11
|
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
12
12
|
|
|
13
|
-
var _isArray = _interopRequireDefault(require("lodash/isArray"));
|
|
14
|
-
|
|
15
13
|
var _url = _interopRequireDefault(require("url"));
|
|
16
14
|
|
|
17
15
|
var _cookie = _interopRequireDefault(require("cookie"));
|
|
@@ -113,7 +111,7 @@ function execute(_ref) {
|
|
|
113
111
|
http
|
|
114
112
|
}, extras));
|
|
115
113
|
|
|
116
|
-
if (request.body && ((0, _isPlainObject.default)(request.body) ||
|
|
114
|
+
if (request.body && ((0, _isPlainObject.default)(request.body) || Array.isArray(request.body))) {
|
|
117
115
|
request.body = JSON.stringify(request.body);
|
|
118
116
|
} // Build request and execute it
|
|
119
117
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.default = buildRequest;
|
|
5
4
|
exports.applySecurities = applySecurities;
|
|
6
|
-
|
|
7
|
-
var _assign = _interopRequireDefault(require("lodash/assign"));
|
|
5
|
+
exports.default = buildRequest;
|
|
8
6
|
|
|
9
7
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
10
8
|
|
|
@@ -14,8 +12,12 @@ var _btoa = _interopRequireDefault(require("btoa"));
|
|
|
14
12
|
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
18
|
+
|
|
19
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
|
+
|
|
19
21
|
function buildRequest(options, req) {
|
|
20
22
|
const {
|
|
21
23
|
operation,
|
|
@@ -103,7 +105,8 @@ function applySecurities({
|
|
|
103
105
|
operation = {},
|
|
104
106
|
spec
|
|
105
107
|
}) {
|
|
106
|
-
const result = (
|
|
108
|
+
const result = _objectSpread({}, request);
|
|
109
|
+
|
|
107
110
|
const {
|
|
108
111
|
authorized = {}
|
|
109
112
|
} = securities;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
+
exports.cookie = cookie;
|
|
5
|
+
exports.header = header;
|
|
4
6
|
exports.path = path;
|
|
5
7
|
exports.query = query;
|
|
6
|
-
exports.header = header;
|
|
7
|
-
exports.cookie = cookie;
|
|
8
|
-
|
|
9
|
-
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
10
8
|
|
|
11
9
|
var _styleSerializer = _interopRequireWildcard(require("./style-serializer"));
|
|
12
10
|
|
|
13
11
|
var _contentSerializer = _interopRequireDefault(require("./content-serializer"));
|
|
14
12
|
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
16
|
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
18
|
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
19
|
function path({
|
|
22
20
|
req,
|
|
23
21
|
value,
|
|
@@ -70,9 +68,18 @@ function query({
|
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
if (value) {
|
|
71
|
+
const {
|
|
72
|
+
style,
|
|
73
|
+
explode,
|
|
74
|
+
allowReserved
|
|
75
|
+
} = parameter;
|
|
73
76
|
req.query[parameter.name] = {
|
|
74
77
|
value,
|
|
75
|
-
serializationOption:
|
|
78
|
+
serializationOption: {
|
|
79
|
+
style,
|
|
80
|
+
explode,
|
|
81
|
+
allowReserved
|
|
82
|
+
}
|
|
76
83
|
};
|
|
77
84
|
} else if (parameter.allowEmptyValue && value !== undefined) {
|
|
78
85
|
const paramName = parameter.name;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.encodeDisallowedCharacters = encodeDisallowedCharacters;
|
|
5
4
|
exports.default = stylize;
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
Buffer
|
|
9
|
-
} = require('buffer');
|
|
5
|
+
exports.encodeDisallowedCharacters = encodeDisallowedCharacters;
|
|
10
6
|
|
|
11
7
|
const isRfc3986Reserved = char => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
|
|
12
8
|
|
|
@@ -44,7 +40,8 @@ function encodeDisallowedCharacters(str, {
|
|
|
44
40
|
return char;
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
const
|
|
43
|
+
const encoder = new TextEncoder();
|
|
44
|
+
const encoded = Array.from(encoder.encode(char)).map(byte => `0${byte.toString(16).toUpperCase()}`.slice(-2)).map(encodedByte => `%${encodedByte}`).join('');
|
|
48
45
|
return encoded;
|
|
49
46
|
}).join('');
|
|
50
47
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.default = buildRequest;
|
|
5
4
|
exports.applySecurities = applySecurities;
|
|
5
|
+
exports.default = buildRequest;
|
|
6
6
|
|
|
7
7
|
var _btoa = _interopRequireDefault(require("btoa"));
|
|
8
8
|
|
|
9
|
-
var _assign = _interopRequireDefault(require("lodash/assign"));
|
|
10
|
-
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
10
|
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
+
|
|
15
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
|
|
13
17
|
// This function runs after the common function,
|
|
14
18
|
// `src/execute/index.js#buildRequest`
|
|
15
19
|
function buildRequest(options, req) {
|
|
@@ -65,7 +69,8 @@ function applySecurities({
|
|
|
65
69
|
operation = {},
|
|
66
70
|
spec
|
|
67
71
|
}) {
|
|
68
|
-
const result = (
|
|
72
|
+
const result = _objectSpread({}, request);
|
|
73
|
+
|
|
69
74
|
const {
|
|
70
75
|
authorized = {},
|
|
71
76
|
specSecurity = []
|