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
|
@@ -220,7 +220,7 @@ function buildRequest(options) {
|
|
|
220
220
|
method,
|
|
221
221
|
pathName
|
|
222
222
|
} = operationRaw;
|
|
223
|
-
|
|
223
|
+
const baseURL = baseUrl({
|
|
224
224
|
spec,
|
|
225
225
|
scheme,
|
|
226
226
|
contextUrl,
|
|
@@ -229,6 +229,7 @@ function buildRequest(options) {
|
|
|
229
229
|
pathName,
|
|
230
230
|
method
|
|
231
231
|
});
|
|
232
|
+
req.url += baseURL;
|
|
232
233
|
|
|
233
234
|
// Mostly for testing
|
|
234
235
|
if (!operationId) {
|
|
@@ -292,7 +293,7 @@ function buildRequest(options) {
|
|
|
292
293
|
value,
|
|
293
294
|
operation,
|
|
294
295
|
spec,
|
|
295
|
-
|
|
296
|
+
baseURL
|
|
296
297
|
});
|
|
297
298
|
}
|
|
298
299
|
});
|
|
@@ -372,7 +373,7 @@ function oas3BaseUrl({
|
|
|
372
373
|
}
|
|
373
374
|
if (selectedServerUrl.includes('{')) {
|
|
374
375
|
// do variable substitution
|
|
375
|
-
const varNames =
|
|
376
|
+
const varNames = extractServerVariableNames(selectedServerUrl);
|
|
376
377
|
varNames.forEach(variable => {
|
|
377
378
|
if (selectedServerObj.variables && selectedServerObj.variables[variable]) {
|
|
378
379
|
// variable is defined in server
|
|
@@ -402,16 +403,9 @@ function buildOas3UrlWithContext(ourUrl = '', contextUrl = '') {
|
|
|
402
403
|
}
|
|
403
404
|
return res[res.length - 1] === '/' ? res.slice(0, -1) : res;
|
|
404
405
|
}
|
|
405
|
-
function
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
let text;
|
|
409
|
-
|
|
410
|
-
// eslint-disable-next-line no-cond-assign
|
|
411
|
-
while (text = re.exec(str)) {
|
|
412
|
-
results.push(text[1]);
|
|
413
|
-
}
|
|
414
|
-
return results;
|
|
406
|
+
function extractServerVariableNames(serverURL) {
|
|
407
|
+
const match = serverURL.matchAll(/\{([^{}]+)}|([^{}]+)/g);
|
|
408
|
+
return Array.from(match, ([, variable]) => variable).filter(Boolean);
|
|
415
409
|
}
|
|
416
410
|
|
|
417
411
|
// Compose the baseUrl ( scheme + host + basePath )
|
|
@@ -680,7 +674,7 @@ function path({
|
|
|
680
674
|
req,
|
|
681
675
|
value,
|
|
682
676
|
parameter,
|
|
683
|
-
|
|
677
|
+
baseURL
|
|
684
678
|
}) {
|
|
685
679
|
const {
|
|
686
680
|
name,
|
|
@@ -689,16 +683,17 @@ function path({
|
|
|
689
683
|
content
|
|
690
684
|
} = parameter;
|
|
691
685
|
if (value === undefined) return;
|
|
686
|
+
const pathname = req.url.replace(baseURL, '');
|
|
692
687
|
let resolvedPathname;
|
|
693
688
|
if (content) {
|
|
694
689
|
const effectiveMediaType = Object.keys(content)[0];
|
|
695
|
-
resolvedPathname = (0,openapi_path_templating__WEBPACK_IMPORTED_MODULE_0__.resolve)(
|
|
690
|
+
resolvedPathname = (0,openapi_path_templating__WEBPACK_IMPORTED_MODULE_0__.resolve)(pathname, {
|
|
696
691
|
[name]: value
|
|
697
692
|
}, {
|
|
698
693
|
encoder: val => (0,_style_serializer_js__WEBPACK_IMPORTED_MODULE_1__.encodeCharacters)((0,_content_serializer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(val, effectiveMediaType))
|
|
699
694
|
});
|
|
700
695
|
} else {
|
|
701
|
-
resolvedPathname = (0,openapi_path_templating__WEBPACK_IMPORTED_MODULE_0__.resolve)(
|
|
696
|
+
resolvedPathname = (0,openapi_path_templating__WEBPACK_IMPORTED_MODULE_0__.resolve)(pathname, {
|
|
702
697
|
[name]: value
|
|
703
698
|
}, {
|
|
704
699
|
encoder: val => (0,_style_serializer_js__WEBPACK_IMPORTED_MODULE_1__["default"])({
|
|
@@ -710,7 +705,7 @@ function path({
|
|
|
710
705
|
})
|
|
711
706
|
});
|
|
712
707
|
}
|
|
713
|
-
req.url =
|
|
708
|
+
req.url = baseURL + resolvedPathname;
|
|
714
709
|
}
|
|
715
710
|
function query({
|
|
716
711
|
req,
|
|
@@ -1167,13 +1162,14 @@ function pathBuilder({
|
|
|
1167
1162
|
req,
|
|
1168
1163
|
value,
|
|
1169
1164
|
parameter,
|
|
1170
|
-
|
|
1165
|
+
baseURL
|
|
1171
1166
|
}) {
|
|
1172
1167
|
if (value !== undefined) {
|
|
1173
|
-
const
|
|
1168
|
+
const pathname = req.url.replace(baseURL, '');
|
|
1169
|
+
const resolvedPathname = (0,openapi_path_templating__WEBPACK_IMPORTED_MODULE_0__.resolve)(pathname, {
|
|
1174
1170
|
[parameter.name]: value
|
|
1175
1171
|
});
|
|
1176
|
-
req.url =
|
|
1172
|
+
req.url = baseURL + resolvedPathname;
|
|
1177
1173
|
}
|
|
1178
1174
|
}
|
|
1179
1175
|
|