swagger-client 3.13.1 → 3.13.2
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/dist/swagger-client.browser.js +1375 -1837
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +30 -41
- package/es/execute/oas3/build-request.js +41 -22
- 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 +33 -37
- 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 +66 -77
- 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 -7
- package/es/specmap/lib/index.js +18 -20
- package/es/specmap/lib/parameters.js +3 -6
- package/es/specmap/lib/refs.js +22 -30
- package/es/subtree-resolver/index.js +2 -3
- package/lib/execute/oas3/build-request.js +13 -0
- package/lib/execute/swagger2/build-request.js +5 -0
- package/package.json +17 -17
package/es/specmap/lib/refs.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
2
|
-
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
3
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
4
1
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
5
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
6
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
7
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
8
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
9
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
10
|
-
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
|
11
|
-
import _WeakMap from "@babel/runtime-corejs3/core-js-stable/weak-map";
|
|
12
2
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
|
+
import _WeakMap from "@babel/runtime-corejs3/core-js-stable/weak-map";
|
|
4
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
5
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
6
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
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 _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
13
10
|
import { fetch } from 'cross-fetch';
|
|
14
11
|
import jsYaml from 'js-yaml';
|
|
15
12
|
import qs from 'querystring-browser';
|
|
@@ -85,7 +82,7 @@ function (path) {
|
|
|
85
82
|
}];
|
|
86
83
|
|
|
87
84
|
var shouldSkipResolution = function shouldSkipResolution(path) {
|
|
88
|
-
return
|
|
85
|
+
return skipResolutionTestFns.some(function (fn) {
|
|
89
86
|
return fn(path);
|
|
90
87
|
});
|
|
91
88
|
}; // =========================
|
|
@@ -350,9 +347,7 @@ function clearCache(item) {
|
|
|
350
347
|
if (typeof item !== 'undefined') {
|
|
351
348
|
delete docCache[item];
|
|
352
349
|
} else {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
_forEachInstanceProperty(_context3 = _Object$keys(docCache)).call(_context3, function (key) {
|
|
350
|
+
_Object$keys(docCache).forEach(function (key) {
|
|
356
351
|
delete docCache[key];
|
|
357
352
|
});
|
|
358
353
|
}
|
|
@@ -433,7 +428,7 @@ function extract(pointer, obj) {
|
|
|
433
428
|
|
|
434
429
|
|
|
435
430
|
function jsonPointerToArray(pointer) {
|
|
436
|
-
var
|
|
431
|
+
var _context3;
|
|
437
432
|
|
|
438
433
|
if (typeof pointer !== 'string') {
|
|
439
434
|
throw new TypeError("Expected a string, got a ".concat(_typeof(pointer)));
|
|
@@ -447,7 +442,7 @@ function jsonPointerToArray(pointer) {
|
|
|
447
442
|
return [];
|
|
448
443
|
}
|
|
449
444
|
|
|
450
|
-
return _mapInstanceProperty(
|
|
445
|
+
return _mapInstanceProperty(_context3 = pointer.split('/')).call(_context3, unescapeJsonPointerToken);
|
|
451
446
|
}
|
|
452
447
|
/**
|
|
453
448
|
* Unescapes a JSON pointer.
|
|
@@ -494,7 +489,7 @@ function pointerIsAParent(pointer, parentPointer) {
|
|
|
494
489
|
|
|
495
490
|
var lastParentChar = _sliceInstanceProperty(parentPointer).call(parentPointer, -1);
|
|
496
491
|
|
|
497
|
-
return
|
|
492
|
+
return pointer.indexOf(parentPointer) === 0 && (!nextChar || nextChar === '/' || nextChar === '#') && lastParentChar !== '#';
|
|
498
493
|
} // =========================
|
|
499
494
|
// Private
|
|
500
495
|
// =========================
|
|
@@ -505,7 +500,7 @@ function pointerIsAParent(pointer, parentPointer) {
|
|
|
505
500
|
|
|
506
501
|
|
|
507
502
|
function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
508
|
-
var
|
|
503
|
+
var _context4, _context6;
|
|
509
504
|
|
|
510
505
|
var refs = specmapRefs.get(specmap);
|
|
511
506
|
|
|
@@ -518,7 +513,7 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
|
518
513
|
|
|
519
514
|
var parentPointer = arrayToJsonPointer(parent);
|
|
520
515
|
|
|
521
|
-
var fullyQualifiedPointer = _concatInstanceProperty(
|
|
516
|
+
var fullyQualifiedPointer = _concatInstanceProperty(_context4 = "".concat(basePath || '<specmap-base>', "#")).call(_context4, pointer); // dirty hack to strip `allof/[index]` from the path, in order to avoid cases
|
|
522
517
|
// where we get false negatives because:
|
|
523
518
|
// - we resolve a path, then
|
|
524
519
|
// - allOf plugin collapsed `allOf/[index]` out of the path, then
|
|
@@ -547,12 +542,11 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
|
547
542
|
|
|
548
543
|
|
|
549
544
|
var currPath = '';
|
|
545
|
+
var hasIndirectCycle = parent.some(function (token) {
|
|
546
|
+
var _context5;
|
|
550
547
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
currPath = _concatInstanceProperty(_context6 = "".concat(currPath, "/")).call(_context6, escapeJsonPointerToken(token));
|
|
555
|
-
return refs[currPath] && _someInstanceProperty(_context7 = refs[currPath]).call(_context7, function (ref) {
|
|
548
|
+
currPath = _concatInstanceProperty(_context5 = "".concat(currPath, "/")).call(_context5, escapeJsonPointerToken(token));
|
|
549
|
+
return refs[currPath] && refs[currPath].some(function (ref) {
|
|
556
550
|
return pointerIsAParent(ref, fullyQualifiedPointer) || pointerIsAParent(fullyQualifiedPointer, ref);
|
|
557
551
|
});
|
|
558
552
|
});
|
|
@@ -563,7 +557,7 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
|
563
557
|
// No need to store if has cycle, as parent path is a dead-end and won't be checked again.
|
|
564
558
|
|
|
565
559
|
|
|
566
|
-
refs[safeParentPointer] = _concatInstanceProperty(
|
|
560
|
+
refs[safeParentPointer] = _concatInstanceProperty(_context6 = refs[safeParentPointer] || []).call(_context6, fullyQualifiedPointer);
|
|
567
561
|
return undefined;
|
|
568
562
|
}
|
|
569
563
|
/**
|
|
@@ -572,11 +566,11 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
|
|
|
572
566
|
|
|
573
567
|
|
|
574
568
|
function patchValueAlreadyInPath(root, patch) {
|
|
575
|
-
var
|
|
569
|
+
var _context7;
|
|
576
570
|
|
|
577
571
|
var ancestors = [root];
|
|
578
572
|
|
|
579
|
-
_reduceInstanceProperty(
|
|
573
|
+
_reduceInstanceProperty(_context7 = patch.path).call(_context7, function (parent, p) {
|
|
580
574
|
ancestors.push(parent[p]);
|
|
581
575
|
return parent[p];
|
|
582
576
|
}, root);
|
|
@@ -584,9 +578,7 @@ function patchValueAlreadyInPath(root, patch) {
|
|
|
584
578
|
return pointToAncestor(patch.value);
|
|
585
579
|
|
|
586
580
|
function pointToAncestor(obj) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
return lib.isObject(obj) && (_indexOfInstanceProperty(ancestors).call(ancestors, obj) >= 0 || _someInstanceProperty(_context10 = _Object$keys(obj)).call(_context10, function (k) {
|
|
581
|
+
return lib.isObject(obj) && (ancestors.indexOf(obj) >= 0 || _Object$keys(obj).some(function (k) {
|
|
590
582
|
return pointToAncestor(obj[k]);
|
|
591
583
|
}));
|
|
592
584
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
2
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
3
1
|
import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
|
|
4
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
5
4
|
// The subtree resolver is a higher-level interface that allows you to
|
|
6
5
|
// get the same result that you would from `Swagger.resolve`, but focuses on
|
|
7
6
|
// a subtree of your object.
|
|
@@ -75,7 +74,7 @@ function _resolveSubtree() {
|
|
|
75
74
|
case 6:
|
|
76
75
|
result = _context.sent;
|
|
77
76
|
|
|
78
|
-
if (!returnEntireTree &&
|
|
77
|
+
if (!returnEntireTree && Array.isArray(path) && path.length) {
|
|
79
78
|
result.spec = get(result.spec, path) || null;
|
|
80
79
|
}
|
|
81
80
|
|
|
@@ -8,6 +8,8 @@ var _assign = _interopRequireDefault(require("lodash/assign"));
|
|
|
8
8
|
|
|
9
9
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
10
10
|
|
|
11
|
+
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
12
|
+
|
|
11
13
|
var _btoa = _interopRequireDefault(require("btoa"));
|
|
12
14
|
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -49,6 +51,17 @@ function buildRequest(options, req) {
|
|
|
49
51
|
}
|
|
50
52
|
} else if (requestContentType && isExplicitContentTypeValid) {
|
|
51
53
|
req.headers['Content-Type'] = requestContentType;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!options.responseContentType && operation.responses) {
|
|
57
|
+
const mediaTypes = Object.entries(operation.responses).filter(([key, value]) => {
|
|
58
|
+
const code = parseInt(key, 10);
|
|
59
|
+
return code >= 200 && code < 300 && (0, _isPlainObject.default)(value.content);
|
|
60
|
+
}).reduce((acc, [, value]) => acc.concat(Object.keys(value.content)), []);
|
|
61
|
+
|
|
62
|
+
if (mediaTypes.length > 0) {
|
|
63
|
+
req.headers.accept = mediaTypes.join(', ');
|
|
64
|
+
}
|
|
52
65
|
} // for OAS3: add requestBody to request
|
|
53
66
|
|
|
54
67
|
|
|
@@ -18,6 +18,7 @@ function buildRequest(options, req) {
|
|
|
18
18
|
operation,
|
|
19
19
|
securities,
|
|
20
20
|
requestContentType,
|
|
21
|
+
responseContentType,
|
|
21
22
|
attachContentTypeForEmptyPayload
|
|
22
23
|
} = options; // Add securities, which are applicable
|
|
23
24
|
|
|
@@ -50,6 +51,10 @@ function buildRequest(options, req) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
if (!responseContentType && Array.isArray(operation.produces) && operation.produces.length > 0) {
|
|
55
|
+
req.headers.accept = operation.produces.join(', ');
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
return req;
|
|
54
59
|
} // Add security values, to operations - that declare their need on them
|
|
55
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-client",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.2",
|
|
4
4
|
"description": "SwaggerJS - a collection of interfaces for OAI specs",
|
|
5
5
|
"main": "lib/commonjs.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -60,46 +60,46 @@
|
|
|
60
60
|
],
|
|
61
61
|
"license": "Apache-2.0",
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@babel/cli": "=7.
|
|
64
|
-
"@babel/core": "=7.
|
|
65
|
-
"@babel/plugin-proposal-class-properties": "=7.
|
|
66
|
-
"@babel/plugin-proposal-object-rest-spread": "=7.
|
|
67
|
-
"@babel/plugin-transform-runtime": "=7.
|
|
68
|
-
"@babel/preset-env": "=7.12
|
|
69
|
-
"@babel/register": "=7.
|
|
63
|
+
"@babel/cli": "=7.13.14",
|
|
64
|
+
"@babel/core": "=7.13.14",
|
|
65
|
+
"@babel/plugin-proposal-class-properties": "=7.13.0",
|
|
66
|
+
"@babel/plugin-proposal-object-rest-spread": "=7.13.8",
|
|
67
|
+
"@babel/plugin-transform-runtime": "=7.13.10",
|
|
68
|
+
"@babel/preset-env": "=7.13.12",
|
|
69
|
+
"@babel/register": "=7.13.14",
|
|
70
70
|
"@char0n/npm-audit": "gist:2964395223d7943c10396f59df9a8ea0",
|
|
71
|
-
"@commitlint/cli": "^
|
|
72
|
-
"@commitlint/config-conventional": "^
|
|
71
|
+
"@commitlint/cli": "^12.0.0",
|
|
72
|
+
"@commitlint/config-conventional": "^12.0.0",
|
|
73
73
|
"@release-it/conventional-changelog": "^1.1.4",
|
|
74
74
|
"babel-loader": "=8.2.2",
|
|
75
75
|
"babel-plugin-lodash": "=3.3.4",
|
|
76
76
|
"cross-env": "=7.0.3",
|
|
77
|
-
"eslint": "=7.
|
|
77
|
+
"eslint": "=7.23.0",
|
|
78
78
|
"eslint-config-airbnb-base": "=14.2.1",
|
|
79
|
-
"eslint-config-prettier": "=
|
|
79
|
+
"eslint-config-prettier": "=8.1.0",
|
|
80
80
|
"eslint-plugin-import": "=2.22.1",
|
|
81
81
|
"eslint-plugin-prettier": "=3.3.1",
|
|
82
82
|
"expect": "=26.6.2",
|
|
83
83
|
"fetch-mock": "=9.11.0",
|
|
84
84
|
"glob": "=7.1.6",
|
|
85
|
-
"husky": "=
|
|
86
|
-
"inspectpack": "=4.
|
|
85
|
+
"husky": "=6.0.0",
|
|
86
|
+
"inspectpack": "=4.7.1",
|
|
87
87
|
"install": "=0.13.0",
|
|
88
88
|
"jest": "=26.6.3",
|
|
89
89
|
"json-loader": "=0.5.7",
|
|
90
90
|
"license-checker": "=25.0.1",
|
|
91
91
|
"lint-staged": "=10.5.4",
|
|
92
92
|
"lodash-webpack-plugin": "=0.11.6",
|
|
93
|
-
"nock": "=13.0.
|
|
93
|
+
"nock": "=13.0.11",
|
|
94
94
|
"node-fetch": "=2.6.1",
|
|
95
95
|
"npm-run-all": "=4.1.5",
|
|
96
96
|
"prettier": "=2.2.1",
|
|
97
97
|
"release-it": "=12.4.3",
|
|
98
98
|
"rimraf": "=3.0.2",
|
|
99
99
|
"terser-webpack-plugin": "^5.0.3",
|
|
100
|
-
"webpack": "=5.
|
|
100
|
+
"webpack": "=5.28.0",
|
|
101
101
|
"webpack-bundle-size-analyzer": "=3.1.0",
|
|
102
|
-
"webpack-cli": "=4.
|
|
102
|
+
"webpack-cli": "=4.6.0",
|
|
103
103
|
"webpack-stats-plugin": "=1.0.3",
|
|
104
104
|
"xmock": "=0.3.0"
|
|
105
105
|
},
|