swagger-client 3.27.6 → 3.27.8
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 +16 -20
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +8 -13
- package/es/execute/oas3/parameter-builders.js +5 -4
- package/es/execute/swagger2/parameter-builders.js +4 -3
- package/lib/execute/index.js +8 -13
- package/lib/execute/oas3/parameter-builders.js +5 -4
- package/lib/execute/swagger2/parameter-builders.js +4 -3
- package/package.json +1 -1
package/es/execute/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _matchAllInstanceProperty from "@babel/runtime-corejs3/core-js/instance/match-all";
|
|
1
2
|
import cookie from 'cookie';
|
|
2
3
|
import { isPlainObject } from 'is-plain-object';
|
|
3
4
|
import { escapeRegExp } from 'ramda-adjunct';
|
|
@@ -163,7 +164,7 @@ export function buildRequest(options) {
|
|
|
163
164
|
method,
|
|
164
165
|
pathName
|
|
165
166
|
} = operationRaw;
|
|
166
|
-
|
|
167
|
+
const baseURL = baseUrl({
|
|
167
168
|
spec,
|
|
168
169
|
scheme,
|
|
169
170
|
contextUrl,
|
|
@@ -172,6 +173,7 @@ export function buildRequest(options) {
|
|
|
172
173
|
pathName,
|
|
173
174
|
method
|
|
174
175
|
});
|
|
176
|
+
req.url += baseURL;
|
|
175
177
|
|
|
176
178
|
// Mostly for testing
|
|
177
179
|
if (!operationId) {
|
|
@@ -235,7 +237,7 @@ export function buildRequest(options) {
|
|
|
235
237
|
value,
|
|
236
238
|
operation,
|
|
237
239
|
spec,
|
|
238
|
-
|
|
240
|
+
baseURL
|
|
239
241
|
});
|
|
240
242
|
}
|
|
241
243
|
});
|
|
@@ -316,7 +318,7 @@ function oas3BaseUrl({
|
|
|
316
318
|
}
|
|
317
319
|
if (selectedServerUrl.includes('{')) {
|
|
318
320
|
// do variable substitution
|
|
319
|
-
const varNames =
|
|
321
|
+
const varNames = extractServerVariableNames(selectedServerUrl);
|
|
320
322
|
varNames.forEach(variable => {
|
|
321
323
|
if (selectedServerObj.variables && selectedServerObj.variables[variable]) {
|
|
322
324
|
// variable is defined in server
|
|
@@ -346,16 +348,9 @@ function buildOas3UrlWithContext(ourUrl = '', contextUrl = '') {
|
|
|
346
348
|
}
|
|
347
349
|
return res[res.length - 1] === '/' ? res.slice(0, -1) : res;
|
|
348
350
|
}
|
|
349
|
-
function
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
let text;
|
|
353
|
-
|
|
354
|
-
// eslint-disable-next-line no-cond-assign
|
|
355
|
-
while (text = re.exec(str)) {
|
|
356
|
-
results.push(text[1]);
|
|
357
|
-
}
|
|
358
|
-
return results;
|
|
351
|
+
function extractServerVariableNames(serverURL) {
|
|
352
|
+
const match = _matchAllInstanceProperty(serverURL).call(serverURL, /\{([^{}]+)}|([^{}]+)/g);
|
|
353
|
+
return Array.from(match, ([, variable]) => variable).filter(Boolean);
|
|
359
354
|
}
|
|
360
355
|
|
|
361
356
|
// Compose the baseUrl ( scheme + host + basePath )
|
|
@@ -5,7 +5,7 @@ export function path({
|
|
|
5
5
|
req,
|
|
6
6
|
value,
|
|
7
7
|
parameter,
|
|
8
|
-
|
|
8
|
+
baseURL
|
|
9
9
|
}) {
|
|
10
10
|
const {
|
|
11
11
|
name,
|
|
@@ -14,16 +14,17 @@ export function path({
|
|
|
14
14
|
content
|
|
15
15
|
} = parameter;
|
|
16
16
|
if (value === undefined) return;
|
|
17
|
+
const pathname = req.url.replace(baseURL, '');
|
|
17
18
|
let resolvedPathname;
|
|
18
19
|
if (content) {
|
|
19
20
|
const effectiveMediaType = Object.keys(content)[0];
|
|
20
|
-
resolvedPathname = resolvePathTemplate(
|
|
21
|
+
resolvedPathname = resolvePathTemplate(pathname, {
|
|
21
22
|
[name]: value
|
|
22
23
|
}, {
|
|
23
24
|
encoder: val => encodeCharacters(serialize(val, effectiveMediaType))
|
|
24
25
|
});
|
|
25
26
|
} else {
|
|
26
|
-
resolvedPathname = resolvePathTemplate(
|
|
27
|
+
resolvedPathname = resolvePathTemplate(pathname, {
|
|
27
28
|
[name]: value
|
|
28
29
|
}, {
|
|
29
30
|
encoder: val => stylize({
|
|
@@ -35,7 +36,7 @@ export function path({
|
|
|
35
36
|
})
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
req.url =
|
|
39
|
+
req.url = baseURL + resolvedPathname;
|
|
39
40
|
}
|
|
40
41
|
export function query({
|
|
41
42
|
req,
|
|
@@ -64,13 +64,14 @@ function pathBuilder({
|
|
|
64
64
|
req,
|
|
65
65
|
value,
|
|
66
66
|
parameter,
|
|
67
|
-
|
|
67
|
+
baseURL
|
|
68
68
|
}) {
|
|
69
69
|
if (value !== undefined) {
|
|
70
|
-
const
|
|
70
|
+
const pathname = req.url.replace(baseURL, '');
|
|
71
|
+
const resolvedPathname = resolvePathTemplate(pathname, {
|
|
71
72
|
[parameter.name]: value
|
|
72
73
|
});
|
|
73
|
-
req.url =
|
|
74
|
+
req.url = baseURL + resolvedPathname;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|
package/lib/execute/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.baseUrl = baseUrl;
|
|
|
7
7
|
exports.buildRequest = buildRequest;
|
|
8
8
|
exports.execute = execute;
|
|
9
9
|
exports.self = void 0;
|
|
10
|
+
var _matchAll = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/match-all"));
|
|
10
11
|
var _cookie = _interopRequireDefault(require("cookie"));
|
|
11
12
|
var _isPlainObject = require("is-plain-object");
|
|
12
13
|
var _ramdaAdjunct = require("ramda-adjunct");
|
|
@@ -172,7 +173,7 @@ function buildRequest(options) {
|
|
|
172
173
|
method,
|
|
173
174
|
pathName
|
|
174
175
|
} = operationRaw;
|
|
175
|
-
|
|
176
|
+
const baseURL = baseUrl({
|
|
176
177
|
spec,
|
|
177
178
|
scheme,
|
|
178
179
|
contextUrl,
|
|
@@ -181,6 +182,7 @@ function buildRequest(options) {
|
|
|
181
182
|
pathName,
|
|
182
183
|
method
|
|
183
184
|
});
|
|
185
|
+
req.url += baseURL;
|
|
184
186
|
|
|
185
187
|
// Mostly for testing
|
|
186
188
|
if (!operationId) {
|
|
@@ -244,7 +246,7 @@ function buildRequest(options) {
|
|
|
244
246
|
value,
|
|
245
247
|
operation,
|
|
246
248
|
spec,
|
|
247
|
-
|
|
249
|
+
baseURL
|
|
248
250
|
});
|
|
249
251
|
}
|
|
250
252
|
});
|
|
@@ -325,7 +327,7 @@ function oas3BaseUrl({
|
|
|
325
327
|
}
|
|
326
328
|
if (selectedServerUrl.includes('{')) {
|
|
327
329
|
// do variable substitution
|
|
328
|
-
const varNames =
|
|
330
|
+
const varNames = extractServerVariableNames(selectedServerUrl);
|
|
329
331
|
varNames.forEach(variable => {
|
|
330
332
|
if (selectedServerObj.variables && selectedServerObj.variables[variable]) {
|
|
331
333
|
// variable is defined in server
|
|
@@ -355,16 +357,9 @@ function buildOas3UrlWithContext(ourUrl = '', contextUrl = '') {
|
|
|
355
357
|
}
|
|
356
358
|
return res[res.length - 1] === '/' ? res.slice(0, -1) : res;
|
|
357
359
|
}
|
|
358
|
-
function
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
let text;
|
|
362
|
-
|
|
363
|
-
// eslint-disable-next-line no-cond-assign
|
|
364
|
-
while (text = re.exec(str)) {
|
|
365
|
-
results.push(text[1]);
|
|
366
|
-
}
|
|
367
|
-
return results;
|
|
360
|
+
function extractServerVariableNames(serverURL) {
|
|
361
|
+
const match = (0, _matchAll.default)(serverURL).call(serverURL, /\{([^{}]+)}|([^{}]+)/g);
|
|
362
|
+
return Array.from(match, ([, variable]) => variable).filter(Boolean);
|
|
368
363
|
}
|
|
369
364
|
|
|
370
365
|
// Compose the baseUrl ( scheme + host + basePath )
|
|
@@ -14,7 +14,7 @@ function path({
|
|
|
14
14
|
req,
|
|
15
15
|
value,
|
|
16
16
|
parameter,
|
|
17
|
-
|
|
17
|
+
baseURL
|
|
18
18
|
}) {
|
|
19
19
|
const {
|
|
20
20
|
name,
|
|
@@ -23,16 +23,17 @@ function path({
|
|
|
23
23
|
content
|
|
24
24
|
} = parameter;
|
|
25
25
|
if (value === undefined) return;
|
|
26
|
+
const pathname = req.url.replace(baseURL, '');
|
|
26
27
|
let resolvedPathname;
|
|
27
28
|
if (content) {
|
|
28
29
|
const effectiveMediaType = Object.keys(content)[0];
|
|
29
|
-
resolvedPathname = (0, _openapiPathTemplating.resolve)(
|
|
30
|
+
resolvedPathname = (0, _openapiPathTemplating.resolve)(pathname, {
|
|
30
31
|
[name]: value
|
|
31
32
|
}, {
|
|
32
33
|
encoder: val => (0, _styleSerializer.encodeCharacters)((0, _contentSerializer.default)(val, effectiveMediaType))
|
|
33
34
|
});
|
|
34
35
|
} else {
|
|
35
|
-
resolvedPathname = (0, _openapiPathTemplating.resolve)(
|
|
36
|
+
resolvedPathname = (0, _openapiPathTemplating.resolve)(pathname, {
|
|
36
37
|
[name]: value
|
|
37
38
|
}, {
|
|
38
39
|
encoder: val => (0, _styleSerializer.default)({
|
|
@@ -44,7 +45,7 @@ function path({
|
|
|
44
45
|
})
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
|
-
req.url =
|
|
48
|
+
req.url = baseURL + resolvedPathname;
|
|
48
49
|
}
|
|
49
50
|
function query({
|
|
50
51
|
req,
|
|
@@ -64,13 +64,14 @@ function pathBuilder({
|
|
|
64
64
|
req,
|
|
65
65
|
value,
|
|
66
66
|
parameter,
|
|
67
|
-
|
|
67
|
+
baseURL
|
|
68
68
|
}) {
|
|
69
69
|
if (value !== undefined) {
|
|
70
|
-
const
|
|
70
|
+
const pathname = req.url.replace(baseURL, '');
|
|
71
|
+
const resolvedPathname = (0, _openapiPathTemplating.resolve)(pathname, {
|
|
71
72
|
[parameter.name]: value
|
|
72
73
|
});
|
|
73
|
-
req.url =
|
|
74
|
+
req.url = baseURL + resolvedPathname;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|