swagger-client 3.24.5 → 3.24.6
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 +5548 -16664
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +26 -31
- package/es/execute/oas3/build-request.js +8 -13
- package/es/execute/oas3/parameter-builders.js +20 -24
- package/es/execute/oas3/style-serializer.js +23 -28
- package/es/execute/swagger2/build-request.js +6 -7
- package/es/execute/swagger2/parameter-builders.js +24 -29
- package/es/helpers/each-operation.js +0 -2
- package/es/helpers/get-operation-raw.js +5 -6
- package/es/helpers/id-from-path-method/index.js +3 -4
- package/es/helpers/op-id.js +3 -5
- package/es/http/index.js +12 -28
- package/es/index.js +2 -4
- package/es/interfaces.js +33 -42
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +5 -9
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
- package/es/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
- package/es/resolver/strategies/generic/index.js +3 -4
- package/es/resolver/strategies/generic/normalize.js +0 -2
- package/es/resolver/strategies/openapi-2/index.js +6 -8
- package/es/resolver/strategies/openapi-3-0/index.js +6 -8
- package/es/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
- package/es/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
- package/es/resolver/utils/index.js +1 -2
- package/es/specmap/helpers.js +5 -6
- package/es/specmap/index.js +2 -10
- package/es/specmap/lib/create-error.js +1 -4
- package/es/subtree-resolver/index.js +2 -4
- package/lib/execute/index.js +26 -35
- package/lib/execute/oas3/build-request.js +8 -13
- package/lib/execute/oas3/parameter-builders.js +20 -24
- package/lib/execute/oas3/style-serializer.js +23 -27
- package/lib/execute/swagger2/build-request.js +6 -7
- package/lib/execute/swagger2/parameter-builders.js +24 -29
- package/lib/helpers/each-operation.js +0 -2
- package/lib/helpers/get-operation-raw.js +5 -6
- package/lib/helpers/id-from-path-method/index.js +3 -4
- package/lib/helpers/op-id.js +3 -7
- package/lib/http/index.js +12 -42
- package/lib/index.js +2 -8
- package/lib/interfaces.js +33 -50
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +5 -9
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
- package/lib/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
- package/lib/resolver/strategies/generic/index.js +3 -4
- package/lib/resolver/strategies/generic/normalize.js +0 -2
- package/lib/resolver/strategies/openapi-2/index.js +6 -8
- package/lib/resolver/strategies/openapi-3-0/index.js +6 -8
- package/lib/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
- package/lib/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
- package/lib/resolver/utils/index.js +1 -4
- package/lib/specmap/helpers.js +5 -6
- package/lib/specmap/index.js +2 -10
- package/lib/specmap/lib/create-error.js +1 -4
- package/lib/subtree-resolver/index.js +2 -8
- package/package.json +4 -4
|
@@ -11,21 +11,19 @@ var _default = exports.default = {
|
|
|
11
11
|
path: pathBuilder,
|
|
12
12
|
formData: formDataBuilder
|
|
13
13
|
}; // Add the body to the request
|
|
14
|
-
function bodyBuilder(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref;
|
|
14
|
+
function bodyBuilder({
|
|
15
|
+
req,
|
|
16
|
+
value
|
|
17
|
+
}) {
|
|
19
18
|
req.body = value;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
// Add a form data object.
|
|
23
|
-
function formDataBuilder(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} = _ref2;
|
|
22
|
+
function formDataBuilder({
|
|
23
|
+
req,
|
|
24
|
+
value,
|
|
25
|
+
parameter
|
|
26
|
+
}) {
|
|
29
27
|
if (value || parameter.allowEmptyValue) {
|
|
30
28
|
req.form = req.form || {};
|
|
31
29
|
req.form[parameter.name] = {
|
|
@@ -37,12 +35,11 @@ function formDataBuilder(_ref2) {
|
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
// Add a header to the request
|
|
40
|
-
function headerBuilder(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} = _ref3;
|
|
38
|
+
function headerBuilder({
|
|
39
|
+
req,
|
|
40
|
+
parameter,
|
|
41
|
+
value
|
|
42
|
+
}) {
|
|
46
43
|
req.headers = req.headers || {};
|
|
47
44
|
if (typeof value !== 'undefined') {
|
|
48
45
|
req.headers[parameter.name] = value;
|
|
@@ -50,22 +47,20 @@ function headerBuilder(_ref3) {
|
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
// Replace path paramters, with values ( ie: the URL )
|
|
53
|
-
function pathBuilder(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} = _ref4;
|
|
50
|
+
function pathBuilder({
|
|
51
|
+
req,
|
|
52
|
+
value,
|
|
53
|
+
parameter
|
|
54
|
+
}) {
|
|
59
55
|
req.url = req.url.split(`{${parameter.name}}`).join(encodeURIComponent(value));
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
// Add a query to the `query` object, which will later be stringified into the URL's search
|
|
63
|
-
function queryBuilder(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} = _ref5;
|
|
59
|
+
function queryBuilder({
|
|
60
|
+
req,
|
|
61
|
+
value,
|
|
62
|
+
parameter
|
|
63
|
+
}) {
|
|
69
64
|
req.query = req.query || {};
|
|
70
65
|
if (value === false && parameter.type === 'boolean') {
|
|
71
66
|
value = 'false';
|
|
@@ -20,12 +20,10 @@ function eachOperation(spec, cb, find) {
|
|
|
20
20
|
if (method.toUpperCase() === 'PARAMETERS') {
|
|
21
21
|
continue; // eslint-disable-line no-continue
|
|
22
22
|
}
|
|
23
|
-
|
|
24
23
|
const operation = paths[pathName][method];
|
|
25
24
|
if (!operation || typeof operation !== 'object') {
|
|
26
25
|
continue; // eslint-disable-line no-continue
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
const operationObj = {
|
|
30
28
|
spec,
|
|
31
29
|
pathName,
|
|
@@ -10,12 +10,11 @@ function getOperationRaw(spec, id) {
|
|
|
10
10
|
if (!spec || !spec.paths) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
|
-
return (0, _findOperation.default)(spec,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref;
|
|
13
|
+
return (0, _findOperation.default)(spec, ({
|
|
14
|
+
pathName,
|
|
15
|
+
method,
|
|
16
|
+
operation
|
|
17
|
+
}) => {
|
|
19
18
|
if (!operation || typeof operation !== 'object') {
|
|
20
19
|
return false;
|
|
21
20
|
}
|
|
@@ -4,10 +4,9 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = idFromPathMethod;
|
|
6
6
|
var _replaceSpecialCharsWithUnderscore = _interopRequireDefault(require("../replace-special-chars-with-underscore.js"));
|
|
7
|
-
function idFromPathMethod(pathName, method,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _temp === void 0 ? {} : _temp;
|
|
7
|
+
function idFromPathMethod(pathName, method, {
|
|
8
|
+
v2OperationIdCompatibilityMode
|
|
9
|
+
} = {}) {
|
|
11
10
|
if (v2OperationIdCompatibilityMode) {
|
|
12
11
|
let res = `${method.toLowerCase()}_${pathName}`.replace(/[\s!@#$%^&*()_+=[{\]};:<>|./?,\\'""-]/g, '_');
|
|
13
12
|
res = res || `${pathName.substring(1)}_${method}`;
|
package/lib/helpers/op-id.js
CHANGED
|
@@ -5,13 +5,9 @@ exports.__esModule = true;
|
|
|
5
5
|
exports.default = opId;
|
|
6
6
|
var _index = _interopRequireDefault(require("./id-from-path-method/index.js"));
|
|
7
7
|
var _replaceSpecialCharsWithUnderscore = _interopRequireDefault(require("./replace-special-chars-with-underscore.js"));
|
|
8
|
-
function opId(operation, pathName, method,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
let {
|
|
13
|
-
v2OperationIdCompatibilityMode
|
|
14
|
-
} = _temp === void 0 ? {} : _temp;
|
|
8
|
+
function opId(operation, pathName, method = '', {
|
|
9
|
+
v2OperationIdCompatibilityMode
|
|
10
|
+
} = {}) {
|
|
15
11
|
if (!operation || typeof operation !== 'object') {
|
|
16
12
|
return null;
|
|
17
13
|
}
|
package/lib/http/index.js
CHANGED
|
@@ -23,10 +23,7 @@ const self = exports.self = {
|
|
|
23
23
|
|
|
24
24
|
// Handles fetch-like syntax and the case where there is only one object passed-in
|
|
25
25
|
// (which will have the URL as a property). Also serializes the response.
|
|
26
|
-
async function http(url, request) {
|
|
27
|
-
if (request === void 0) {
|
|
28
|
-
request = {};
|
|
29
|
-
}
|
|
26
|
+
async function http(url, request = {}) {
|
|
30
27
|
if (typeof url === 'object') {
|
|
31
28
|
request = url;
|
|
32
29
|
url = request.url;
|
|
@@ -98,12 +95,7 @@ async function http(url, request) {
|
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
// exported for testing
|
|
101
|
-
const shouldDownloadAsText =
|
|
102
|
-
if (contentType === void 0) {
|
|
103
|
-
contentType = '';
|
|
104
|
-
}
|
|
105
|
-
return /(json|xml|yaml|text)\b/.test(contentType);
|
|
106
|
-
};
|
|
98
|
+
const shouldDownloadAsText = (contentType = '') => /(json|xml|yaml|text)\b/.test(contentType);
|
|
107
99
|
exports.shouldDownloadAsText = shouldDownloadAsText;
|
|
108
100
|
function parseBody(body, contentType) {
|
|
109
101
|
if (contentType && (contentType.indexOf('application/json') === 0 || contentType.indexOf('+json') > 0)) {
|
|
@@ -113,10 +105,9 @@ function parseBody(body, contentType) {
|
|
|
113
105
|
}
|
|
114
106
|
|
|
115
107
|
// Serialize the response, returns a promise with headers and the body part of the hash
|
|
116
|
-
function serializeRes(oriRes, url,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
} = _temp === void 0 ? {} : _temp;
|
|
108
|
+
function serializeRes(oriRes, url, {
|
|
109
|
+
loadSpec = false
|
|
110
|
+
} = {}) {
|
|
120
111
|
const res = {
|
|
121
112
|
ok: oriRes.ok,
|
|
122
113
|
url: oriRes.url || url,
|
|
@@ -152,13 +143,9 @@ function serializeHeaderValue(value) {
|
|
|
152
143
|
// eg: Cookie: one
|
|
153
144
|
// Cookie: two
|
|
154
145
|
// = { Cookie: [ "one", "two" ]
|
|
155
|
-
function serializeHeaders(headers) {
|
|
156
|
-
if (headers === void 0) {
|
|
157
|
-
headers = {};
|
|
158
|
-
}
|
|
146
|
+
function serializeHeaders(headers = {}) {
|
|
159
147
|
if (typeof headers.entries !== 'function') return {};
|
|
160
|
-
return Array.from(headers.entries()).reduce((acc,
|
|
161
|
-
let [header, value] = _ref;
|
|
148
|
+
return Array.from(headers.entries()).reduce((acc, [header, value]) => {
|
|
162
149
|
acc[header] = serializeHeaderValue(value);
|
|
163
150
|
return acc;
|
|
164
151
|
}, {});
|
|
@@ -209,13 +196,7 @@ const SEPARATORS = {
|
|
|
209
196
|
* is defined within the Media Type Object (OpenAPI 3.x.y).
|
|
210
197
|
*/
|
|
211
198
|
class FileWithData extends File {
|
|
212
|
-
constructor(data, name, options) {
|
|
213
|
-
if (name === void 0) {
|
|
214
|
-
name = '';
|
|
215
|
-
}
|
|
216
|
-
if (options === void 0) {
|
|
217
|
-
options = {};
|
|
218
|
-
}
|
|
199
|
+
constructor(data, name = '', options = {}) {
|
|
219
200
|
super([data], name, options);
|
|
220
201
|
this.data = data;
|
|
221
202
|
}
|
|
@@ -235,10 +216,7 @@ class FileWithData extends File {
|
|
|
235
216
|
// Return value example 4: [['color', 'R,100,G,200,B,150']]
|
|
236
217
|
// Return value example 5: [['R', '100'], ['G', '200'], ['B', '150']]
|
|
237
218
|
// Return value example 6: [['color[R]', '100'], ['color[G]', '200'], ['color[B]', '150']]
|
|
238
|
-
function formatKeyValue(key, input, skipEncoding) {
|
|
239
|
-
if (skipEncoding === void 0) {
|
|
240
|
-
skipEncoding = false;
|
|
241
|
-
}
|
|
219
|
+
function formatKeyValue(key, input, skipEncoding = false) {
|
|
242
220
|
const {
|
|
243
221
|
collectionFormat,
|
|
244
222
|
allowEmptyValue,
|
|
@@ -376,8 +354,7 @@ function buildFormData(reqForm) {
|
|
|
376
354
|
* @param {Object} reqForm - ori req.form
|
|
377
355
|
* @return {FormData} - new FormData instance
|
|
378
356
|
*/
|
|
379
|
-
return Object.entries(reqForm).reduce((formData,
|
|
380
|
-
let [name, input] = _ref2;
|
|
357
|
+
return Object.entries(reqForm).reduce((formData, [name, input]) => {
|
|
381
358
|
// eslint-disable-next-line no-restricted-syntax
|
|
382
359
|
for (const [key, value] of formatKeyValue(name, input, true)) {
|
|
383
360
|
if (Array.isArray(value)) {
|
|
@@ -428,23 +405,16 @@ function encodeFormOrQuery(data) {
|
|
|
428
405
|
|
|
429
406
|
// If the request has a `query` object, merge it into the request.url, and delete the object
|
|
430
407
|
// If file and/or multipart, also create FormData instance
|
|
431
|
-
function mergeInQueryOrForm(req) {
|
|
432
|
-
if (req === void 0) {
|
|
433
|
-
req = {};
|
|
434
|
-
}
|
|
408
|
+
function mergeInQueryOrForm(req = {}) {
|
|
435
409
|
const {
|
|
436
410
|
url = '',
|
|
437
411
|
query,
|
|
438
412
|
form
|
|
439
413
|
} = req;
|
|
440
|
-
const joinSearch =
|
|
441
|
-
for (var _len = arguments.length, strs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
442
|
-
strs[_key] = arguments[_key];
|
|
443
|
-
}
|
|
414
|
+
const joinSearch = (...strs) => {
|
|
444
415
|
const search = strs.filter(a => a).join('&'); // Only truthy value
|
|
445
416
|
return search ? `?${search}` : ''; // Only add '?' if there is a str
|
|
446
417
|
};
|
|
447
|
-
|
|
448
418
|
if (form) {
|
|
449
419
|
const hasFile = Object.keys(form).some(key => {
|
|
450
420
|
const {
|
package/lib/index.js
CHANGED
|
@@ -68,10 +68,7 @@ Swagger.apidom = {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
function Swagger(url, opts) {
|
|
72
|
-
if (opts === void 0) {
|
|
73
|
-
opts = {};
|
|
74
|
-
}
|
|
71
|
+
function Swagger(url, opts = {}) {
|
|
75
72
|
// Allow url as a separate argument
|
|
76
73
|
if (typeof url === 'string') {
|
|
77
74
|
opts.url = url;
|
|
@@ -109,10 +106,7 @@ Swagger.prototype = {
|
|
|
109
106
|
...options
|
|
110
107
|
});
|
|
111
108
|
},
|
|
112
|
-
resolve(options) {
|
|
113
|
-
if (options === void 0) {
|
|
114
|
-
options = {};
|
|
115
|
-
}
|
|
109
|
+
resolve(options = {}) {
|
|
116
110
|
return Swagger.resolve({
|
|
117
111
|
spec: this.spec,
|
|
118
112
|
url: this.url,
|
package/lib/interfaces.js
CHANGED
|
@@ -17,37 +17,28 @@ const self = exports.self = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// Make an execute, bound to arguments defined in mapTagOperation's callback (cb)
|
|
20
|
-
function makeExecute(swaggerJs) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
function makeExecute(swaggerJs = {}) {
|
|
21
|
+
return ({
|
|
22
|
+
pathName,
|
|
23
|
+
method,
|
|
24
|
+
operationId
|
|
25
|
+
}) => (parameters, opts = {}) => {
|
|
26
|
+
const {
|
|
27
|
+
requestInterceptor,
|
|
28
|
+
responseInterceptor,
|
|
29
|
+
userFetch
|
|
30
|
+
} = swaggerJs;
|
|
31
|
+
return swaggerJs.execute({
|
|
32
|
+
spec: swaggerJs.spec,
|
|
33
|
+
requestInterceptor,
|
|
34
|
+
responseInterceptor,
|
|
35
|
+
userFetch,
|
|
26
36
|
pathName,
|
|
27
37
|
method,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
opts = {};
|
|
33
|
-
}
|
|
34
|
-
const {
|
|
35
|
-
requestInterceptor,
|
|
36
|
-
responseInterceptor,
|
|
37
|
-
userFetch
|
|
38
|
-
} = swaggerJs;
|
|
39
|
-
return swaggerJs.execute({
|
|
40
|
-
spec: swaggerJs.spec,
|
|
41
|
-
requestInterceptor,
|
|
42
|
-
responseInterceptor,
|
|
43
|
-
userFetch,
|
|
44
|
-
pathName,
|
|
45
|
-
method,
|
|
46
|
-
parameters,
|
|
47
|
-
operationId,
|
|
48
|
-
...opts
|
|
49
|
-
});
|
|
50
|
-
};
|
|
38
|
+
parameters,
|
|
39
|
+
operationId,
|
|
40
|
+
...opts
|
|
41
|
+
});
|
|
51
42
|
};
|
|
52
43
|
}
|
|
53
44
|
|
|
@@ -55,10 +46,7 @@ function makeExecute(swaggerJs) {
|
|
|
55
46
|
// The shape
|
|
56
47
|
// { apis: { [tag]: { operations: [operation]: { execute }}}}
|
|
57
48
|
// NOTE: this is mostly for compatibility
|
|
58
|
-
function makeApisTagOperationsOperationExecute(swaggerJs) {
|
|
59
|
-
if (swaggerJs === void 0) {
|
|
60
|
-
swaggerJs = {};
|
|
61
|
-
}
|
|
49
|
+
function makeApisTagOperationsOperationExecute(swaggerJs = {}) {
|
|
62
50
|
// { apis: tag: operations: execute }
|
|
63
51
|
const cb = self.makeExecute(swaggerJs);
|
|
64
52
|
const tagOperations = self.mapTagOperations({
|
|
@@ -85,10 +73,7 @@ function makeApisTagOperationsOperationExecute(swaggerJs) {
|
|
|
85
73
|
}
|
|
86
74
|
|
|
87
75
|
// .apis[tag][operationId]:ExecuteFunction interface
|
|
88
|
-
function makeApisTagOperation(swaggerJs) {
|
|
89
|
-
if (swaggerJs === void 0) {
|
|
90
|
-
swaggerJs = {};
|
|
91
|
-
}
|
|
76
|
+
function makeApisTagOperation(swaggerJs = {}) {
|
|
92
77
|
const cb = self.makeExecute(swaggerJs);
|
|
93
78
|
return {
|
|
94
79
|
apis: self.mapTagOperations({
|
|
@@ -108,21 +93,19 @@ function makeApisTagOperation(swaggerJs) {
|
|
|
108
93
|
* `defaultTag` will house all non-tagged operations
|
|
109
94
|
*
|
|
110
95
|
*/
|
|
111
|
-
function mapTagOperations(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
} = _ref2;
|
|
96
|
+
function mapTagOperations({
|
|
97
|
+
spec,
|
|
98
|
+
cb = nullFn,
|
|
99
|
+
defaultTag = 'default',
|
|
100
|
+
v2OperationIdCompatibilityMode
|
|
101
|
+
}) {
|
|
118
102
|
const operationIdCounter = {};
|
|
119
103
|
const tagOperations = {}; // Will house all tags + operations
|
|
120
|
-
(0, _index.eachOperation)(spec,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
} = _ref3;
|
|
104
|
+
(0, _index.eachOperation)(spec, ({
|
|
105
|
+
pathName,
|
|
106
|
+
method,
|
|
107
|
+
operation
|
|
108
|
+
}) => {
|
|
126
109
|
const tags = operation.tags ? normalizeArray(operation.tags) : [defaultTag];
|
|
127
110
|
tags.forEach(tag => {
|
|
128
111
|
if (typeof tag !== 'string') {
|
package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js
CHANGED
|
@@ -24,15 +24,14 @@ const OpenApi3_1SwaggerClientDereferenceStrategy = _openapi.default.compose({
|
|
|
24
24
|
mode: 'non-strict',
|
|
25
25
|
ancestors: null
|
|
26
26
|
},
|
|
27
|
-
init(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = _temp === void 0 ? {} : _temp;
|
|
27
|
+
init({
|
|
28
|
+
useCircularStructures = this.useCircularStructures,
|
|
29
|
+
allowMetaPatches = this.allowMetaPatches,
|
|
30
|
+
parameterMacro = this.parameterMacro,
|
|
31
|
+
modelPropertyMacro = this.modelPropertyMacro,
|
|
32
|
+
mode = this.mode,
|
|
33
|
+
ancestors = []
|
|
34
|
+
} = {}) {
|
|
36
35
|
this.name = 'openapi-3-1-swagger-client';
|
|
37
36
|
this.useCircularStructures = useCircularStructures;
|
|
38
37
|
this.allowMetaPatches = allowMetaPatches;
|
|
@@ -8,10 +8,9 @@ var _apidomNsOpenapi = require("@swagger-api/apidom-ns-openapi-3-1");
|
|
|
8
8
|
var _compose = _interopRequireDefault(require("../utils/compose.js"));
|
|
9
9
|
var _toPath = _interopRequireDefault(require("../utils/to-path.js"));
|
|
10
10
|
const AllOfVisitor = (0, _compose.default)({
|
|
11
|
-
init(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref;
|
|
11
|
+
init({
|
|
12
|
+
options
|
|
13
|
+
}) {
|
|
15
14
|
this.options = options;
|
|
16
15
|
},
|
|
17
16
|
props: {
|
|
@@ -36,12 +36,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
|
|
|
36
36
|
allowMetaPatches: false,
|
|
37
37
|
basePath: null
|
|
38
38
|
},
|
|
39
|
-
init(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} = _ref;
|
|
39
|
+
init({
|
|
40
|
+
allowMetaPatches = this.allowMetaPatches,
|
|
41
|
+
useCircularStructures = this.useCircularStructures,
|
|
42
|
+
basePath = this.basePath
|
|
43
|
+
}) {
|
|
45
44
|
this.allowMetaPatches = allowMetaPatches;
|
|
46
45
|
this.useCircularStructures = useCircularStructures;
|
|
47
46
|
this.basePath = basePath;
|
|
@@ -184,7 +183,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
|
|
|
184
183
|
} else if (Array.isArray(parent)) {
|
|
185
184
|
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
186
185
|
}
|
|
187
|
-
|
|
188
186
|
return false;
|
|
189
187
|
}
|
|
190
188
|
|
|
@@ -329,7 +327,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
|
|
|
329
327
|
} else if (Array.isArray(parent)) {
|
|
330
328
|
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
331
329
|
}
|
|
332
|
-
|
|
333
330
|
return false;
|
|
334
331
|
}
|
|
335
332
|
|
|
@@ -528,7 +525,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
|
|
|
528
525
|
} else if (Array.isArray(parent)) {
|
|
529
526
|
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
530
527
|
}
|
|
531
|
-
|
|
532
528
|
return false;
|
|
533
529
|
}
|
|
534
530
|
|
|
@@ -7,11 +7,10 @@ var _apidomCore = require("@swagger-api/apidom-core");
|
|
|
7
7
|
var _compose = _interopRequireDefault(require("../utils/compose.js"));
|
|
8
8
|
var _toPath = _interopRequireDefault(require("../utils/to-path.js"));
|
|
9
9
|
const ParameterMacroVisitor = (0, _compose.default)({
|
|
10
|
-
init(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref;
|
|
10
|
+
init({
|
|
11
|
+
parameterMacro,
|
|
12
|
+
options
|
|
13
|
+
}) {
|
|
15
14
|
this.parameterMacro = parameterMacro;
|
|
16
15
|
this.options = options;
|
|
17
16
|
},
|
|
@@ -7,11 +7,10 @@ var _apidomCore = require("@swagger-api/apidom-core");
|
|
|
7
7
|
var _compose = _interopRequireDefault(require("../utils/compose.js"));
|
|
8
8
|
var _toPath = _interopRequireDefault(require("../utils/to-path.js"));
|
|
9
9
|
const ModelPropertyMacroVisitor = (0, _compose.default)({
|
|
10
|
-
init(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref;
|
|
10
|
+
init({
|
|
11
|
+
modelPropertyMacro,
|
|
12
|
+
options
|
|
13
|
+
}) {
|
|
15
14
|
this.modelPropertyMacro = modelPropertyMacro;
|
|
16
15
|
this.options = options;
|
|
17
16
|
},
|
|
@@ -13,10 +13,9 @@ const HttpResolverSwaggerClient = _empty.HttpResolver.compose({
|
|
|
13
13
|
swaggerHTTPClient: _index.default,
|
|
14
14
|
swaggerHTTPClientConfig: {}
|
|
15
15
|
},
|
|
16
|
-
init(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = _temp === void 0 ? {} : _temp;
|
|
16
|
+
init({
|
|
17
|
+
swaggerHTTPClient = this.swaggerHTTPClient
|
|
18
|
+
} = {}) {
|
|
20
19
|
this.swaggerHTTPClient = swaggerHTTPClient;
|
|
21
20
|
},
|
|
22
21
|
methods: {
|
|
@@ -22,7 +22,6 @@ function normalize(parsedSpec) {
|
|
|
22
22
|
if (path == null || !['object', 'function'].includes(typeof path)) {
|
|
23
23
|
continue; // eslint-disable-line no-continue
|
|
24
24
|
}
|
|
25
|
-
|
|
26
25
|
const pathParameters = path.parameters;
|
|
27
26
|
|
|
28
27
|
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
@@ -31,7 +30,6 @@ function normalize(parsedSpec) {
|
|
|
31
30
|
if (operation == null || !['object', 'function'].includes(typeof operation)) {
|
|
32
31
|
continue; // eslint-disable-line no-continue
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
const oid = (0, _opId.default)(operation, pathName, method);
|
|
36
34
|
if (oid) {
|
|
37
35
|
if (map[oid]) {
|
|
@@ -10,16 +10,14 @@ var _index = require("../generic/index.js");
|
|
|
10
10
|
exports.clearCache = _index.clearCache;
|
|
11
11
|
const openApi2Strategy = {
|
|
12
12
|
name: 'openapi-2',
|
|
13
|
-
match(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref;
|
|
13
|
+
match({
|
|
14
|
+
spec
|
|
15
|
+
}) {
|
|
17
16
|
return (0, _openapiPredicates.isOpenAPI2)(spec);
|
|
18
17
|
},
|
|
19
|
-
normalize(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = _ref2;
|
|
18
|
+
normalize({
|
|
19
|
+
spec
|
|
20
|
+
}) {
|
|
23
21
|
const {
|
|
24
22
|
spec: normalized
|
|
25
23
|
} = (0, _normalize.default)({
|
|
@@ -10,16 +10,14 @@ var _index = require("../generic/index.js");
|
|
|
10
10
|
exports.clearCache = _index.clearCache;
|
|
11
11
|
const openApi30Strategy = {
|
|
12
12
|
name: 'openapi-3-0',
|
|
13
|
-
match(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref;
|
|
13
|
+
match({
|
|
14
|
+
spec
|
|
15
|
+
}) {
|
|
17
16
|
return (0, _openapiPredicates.isOpenAPI30)(spec);
|
|
18
17
|
},
|
|
19
|
-
normalize(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = _ref2;
|
|
18
|
+
normalize({
|
|
19
|
+
spec
|
|
20
|
+
}) {
|
|
23
21
|
const {
|
|
24
22
|
spec: normalized
|
|
25
23
|
} = (0, _normalize.default)({
|
|
@@ -9,16 +9,14 @@ var _normalize = _interopRequireWildcard(require("./normalize.js"));
|
|
|
9
9
|
var _openapiPredicates = require("../../../helpers/openapi-predicates.js");
|
|
10
10
|
const openApi31ApiDOMStrategy = {
|
|
11
11
|
name: 'openapi-3-1-apidom',
|
|
12
|
-
match(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = _ref;
|
|
12
|
+
match({
|
|
13
|
+
spec
|
|
14
|
+
}) {
|
|
16
15
|
return (0, _openapiPredicates.isOpenAPI31)(spec);
|
|
17
16
|
},
|
|
18
|
-
normalize(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = _ref2;
|
|
17
|
+
normalize({
|
|
18
|
+
spec
|
|
19
|
+
}) {
|
|
22
20
|
return (0, _normalize.pojoAdapter)(_normalize.default)(spec);
|
|
23
21
|
},
|
|
24
22
|
async resolve(options) {
|
|
@@ -36,7 +36,7 @@ const normalize = element => {
|
|
|
36
36
|
*/
|
|
37
37
|
const pojoAdapter = normalizeFn => spec => {
|
|
38
38
|
if (spec != null && spec.$$normalized) return spec;
|
|
39
|
-
if (pojoAdapter.cache.has(spec)) return spec;
|
|
39
|
+
if (pojoAdapter.cache.has(spec)) return pojoAdapter.cache.get(spec);
|
|
40
40
|
const openApiElement = _apidomNsOpenapi.OpenApi3_1Element.refract(spec);
|
|
41
41
|
const normalized = normalizeFn(openApiElement);
|
|
42
42
|
const value = (0, _apidomCore.toValue)(normalized);
|
|
@@ -4,10 +4,7 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.makeFetchJSON = makeFetchJSON;
|
|
5
5
|
var _constants = require("../../constants.js");
|
|
6
6
|
// eslint-disable-next-line import/prefer-default-export
|
|
7
|
-
function makeFetchJSON(http, opts) {
|
|
8
|
-
if (opts === void 0) {
|
|
9
|
-
opts = {};
|
|
10
|
-
}
|
|
7
|
+
function makeFetchJSON(http, opts = {}) {
|
|
11
8
|
const {
|
|
12
9
|
requestInterceptor,
|
|
13
10
|
responseInterceptor
|