swagger-client 3.27.3 → 3.27.5
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 +2410 -37
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +4 -2
- package/es/execute/oas3/parameter-builders.js +20 -9
- package/es/execute/swagger2/parameter-builders.js +8 -2
- package/lib/execute/index.js +4 -2
- package/lib/execute/oas3/parameter-builders.js +20 -9
- package/lib/execute/swagger2/parameter-builders.js +7 -2
- package/package.json +3 -1
package/es/execute/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cookie from 'cookie';
|
|
2
2
|
import { isPlainObject } from 'is-plain-object';
|
|
3
|
+
import { escapeRegExp } from 'ramda-adjunct';
|
|
3
4
|
import { ApiDOMStructuredError } from '@swagger-api/apidom-error';
|
|
4
5
|
import { url } from '@swagger-api/apidom-reference/configuration/empty';
|
|
5
6
|
import { DEFAULT_BASE_URL, DEFAULT_OPENAPI_3_SERVER } from '../constants.js';
|
|
@@ -233,7 +234,8 @@ export function buildRequest(options) {
|
|
|
233
234
|
parameter,
|
|
234
235
|
value,
|
|
235
236
|
operation,
|
|
236
|
-
spec
|
|
237
|
+
spec,
|
|
238
|
+
pathName
|
|
237
239
|
});
|
|
238
240
|
}
|
|
239
241
|
});
|
|
@@ -320,7 +322,7 @@ function oas3BaseUrl({
|
|
|
320
322
|
// variable is defined in server
|
|
321
323
|
const variableDefinition = selectedServerObj.variables[variable];
|
|
322
324
|
const variableValue = serverVariables[variable] || variableDefinition.default;
|
|
323
|
-
const re = new RegExp(`{${variable}}`, 'g');
|
|
325
|
+
const re = new RegExp(`{${escapeRegExp(variable)}}`, 'g');
|
|
324
326
|
selectedServerUrl = selectedServerUrl.replace(re, variableValue);
|
|
325
327
|
}
|
|
326
328
|
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { resolve as resolvePathTemplate } from 'openapi-path-templating';
|
|
1
2
|
import stylize, { encodeCharacters } from './style-serializer.js';
|
|
2
3
|
import serialize from './content-serializer.js';
|
|
3
4
|
export function path({
|
|
4
5
|
req,
|
|
5
6
|
value,
|
|
6
|
-
parameter
|
|
7
|
+
parameter,
|
|
8
|
+
pathName
|
|
7
9
|
}) {
|
|
8
10
|
const {
|
|
9
11
|
name,
|
|
@@ -12,19 +14,28 @@ export function path({
|
|
|
12
14
|
content
|
|
13
15
|
} = parameter;
|
|
14
16
|
if (value === undefined) return;
|
|
17
|
+
let resolvedPathname;
|
|
15
18
|
if (content) {
|
|
16
19
|
const effectiveMediaType = Object.keys(content)[0];
|
|
17
|
-
|
|
20
|
+
resolvedPathname = resolvePathTemplate(pathName, {
|
|
21
|
+
[name]: value
|
|
22
|
+
}, {
|
|
23
|
+
encoder: val => encodeCharacters(serialize(val, effectiveMediaType))
|
|
24
|
+
});
|
|
18
25
|
} else {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
resolvedPathname = resolvePathTemplate(pathName, {
|
|
27
|
+
[name]: value
|
|
28
|
+
}, {
|
|
29
|
+
encoder: val => stylize({
|
|
30
|
+
key: parameter.name,
|
|
31
|
+
value: val,
|
|
32
|
+
style: style || 'simple',
|
|
33
|
+
explode: explode || false,
|
|
34
|
+
escape: 'reserved'
|
|
35
|
+
})
|
|
25
36
|
});
|
|
26
|
-
req.url = req.url.replace(new RegExp(`{${name}}`, 'g'), styledValue);
|
|
27
37
|
}
|
|
38
|
+
req.url = req.url.replace(pathName, resolvedPathname);
|
|
28
39
|
}
|
|
29
40
|
export function query({
|
|
30
41
|
req,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolve as resolvePathTemplate } from 'openapi-path-templating';
|
|
2
|
+
|
|
1
3
|
// These functions will update the request.
|
|
2
4
|
// They'll be given {req, value, paramter, spec, operation}.
|
|
3
5
|
|
|
@@ -61,10 +63,14 @@ function headerBuilder({
|
|
|
61
63
|
function pathBuilder({
|
|
62
64
|
req,
|
|
63
65
|
value,
|
|
64
|
-
parameter
|
|
66
|
+
parameter,
|
|
67
|
+
pathName
|
|
65
68
|
}) {
|
|
66
69
|
if (value !== undefined) {
|
|
67
|
-
|
|
70
|
+
const resolvedPathname = resolvePathTemplate(pathName, {
|
|
71
|
+
[parameter.name]: value
|
|
72
|
+
});
|
|
73
|
+
req.url = req.url.replace(pathName, resolvedPathname);
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
|
package/lib/execute/index.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.execute = execute;
|
|
|
9
9
|
exports.self = void 0;
|
|
10
10
|
var _cookie = _interopRequireDefault(require("cookie"));
|
|
11
11
|
var _isPlainObject = require("is-plain-object");
|
|
12
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
12
13
|
var _apidomError = require("@swagger-api/apidom-error");
|
|
13
14
|
var _empty = require("@swagger-api/apidom-reference/configuration/empty");
|
|
14
15
|
var _constants = require("../constants.js");
|
|
@@ -242,7 +243,8 @@ function buildRequest(options) {
|
|
|
242
243
|
parameter,
|
|
243
244
|
value,
|
|
244
245
|
operation,
|
|
245
|
-
spec
|
|
246
|
+
spec,
|
|
247
|
+
pathName
|
|
246
248
|
});
|
|
247
249
|
}
|
|
248
250
|
});
|
|
@@ -329,7 +331,7 @@ function oas3BaseUrl({
|
|
|
329
331
|
// variable is defined in server
|
|
330
332
|
const variableDefinition = selectedServerObj.variables[variable];
|
|
331
333
|
const variableValue = serverVariables[variable] || variableDefinition.default;
|
|
332
|
-
const re = new RegExp(`{${variable}}`, 'g');
|
|
334
|
+
const re = new RegExp(`{${(0, _ramdaAdjunct.escapeRegExp)(variable)}}`, 'g');
|
|
333
335
|
selectedServerUrl = selectedServerUrl.replace(re, variableValue);
|
|
334
336
|
}
|
|
335
337
|
});
|
|
@@ -7,12 +7,14 @@ exports.cookie = cookie;
|
|
|
7
7
|
exports.header = header;
|
|
8
8
|
exports.path = path;
|
|
9
9
|
exports.query = query;
|
|
10
|
+
var _openapiPathTemplating = require("openapi-path-templating");
|
|
10
11
|
var _styleSerializer = _interopRequireWildcard(require("./style-serializer.js"));
|
|
11
12
|
var _contentSerializer = _interopRequireDefault(require("./content-serializer.js"));
|
|
12
13
|
function path({
|
|
13
14
|
req,
|
|
14
15
|
value,
|
|
15
|
-
parameter
|
|
16
|
+
parameter,
|
|
17
|
+
pathName
|
|
16
18
|
}) {
|
|
17
19
|
const {
|
|
18
20
|
name,
|
|
@@ -21,19 +23,28 @@ function path({
|
|
|
21
23
|
content
|
|
22
24
|
} = parameter;
|
|
23
25
|
if (value === undefined) return;
|
|
26
|
+
let resolvedPathname;
|
|
24
27
|
if (content) {
|
|
25
28
|
const effectiveMediaType = Object.keys(content)[0];
|
|
26
|
-
|
|
29
|
+
resolvedPathname = (0, _openapiPathTemplating.resolve)(pathName, {
|
|
30
|
+
[name]: value
|
|
31
|
+
}, {
|
|
32
|
+
encoder: val => (0, _styleSerializer.encodeCharacters)((0, _contentSerializer.default)(val, effectiveMediaType))
|
|
33
|
+
});
|
|
27
34
|
} else {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
resolvedPathname = (0, _openapiPathTemplating.resolve)(pathName, {
|
|
36
|
+
[name]: value
|
|
37
|
+
}, {
|
|
38
|
+
encoder: val => (0, _styleSerializer.default)({
|
|
39
|
+
key: parameter.name,
|
|
40
|
+
value: val,
|
|
41
|
+
style: style || 'simple',
|
|
42
|
+
explode: explode || false,
|
|
43
|
+
escape: 'reserved'
|
|
44
|
+
})
|
|
34
45
|
});
|
|
35
|
-
req.url = req.url.replace(new RegExp(`{${name}}`, 'g'), styledValue);
|
|
36
46
|
}
|
|
47
|
+
req.url = req.url.replace(pathName, resolvedPathname);
|
|
37
48
|
}
|
|
38
49
|
function query({
|
|
39
50
|
req,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
+
var _openapiPathTemplating = require("openapi-path-templating");
|
|
5
6
|
// These functions will update the request.
|
|
6
7
|
// They'll be given {req, value, paramter, spec, operation}.
|
|
7
8
|
var _default = exports.default = {
|
|
@@ -62,10 +63,14 @@ function headerBuilder({
|
|
|
62
63
|
function pathBuilder({
|
|
63
64
|
req,
|
|
64
65
|
value,
|
|
65
|
-
parameter
|
|
66
|
+
parameter,
|
|
67
|
+
pathName
|
|
66
68
|
}) {
|
|
67
69
|
if (value !== undefined) {
|
|
68
|
-
|
|
70
|
+
const resolvedPathname = (0, _openapiPathTemplating.resolve)(pathName, {
|
|
71
|
+
[parameter.name]: value
|
|
72
|
+
});
|
|
73
|
+
req.url = req.url.replace(pathName, resolvedPathname);
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-client",
|
|
3
|
-
"version": "3.27.
|
|
3
|
+
"version": "3.27.5",
|
|
4
4
|
"description": "SwaggerJS - a collection of interfaces for OAI specs",
|
|
5
5
|
"browser": {
|
|
6
6
|
"./src/helpers/btoa.node.js": "./src/helpers/btoa.browser.js",
|
|
@@ -122,7 +122,9 @@
|
|
|
122
122
|
"js-yaml": "^4.1.0",
|
|
123
123
|
"node-abort-controller": "^3.1.1",
|
|
124
124
|
"node-fetch-commonjs": "^3.3.2",
|
|
125
|
+
"openapi-path-templating": "^1.5.1",
|
|
125
126
|
"qs": "^6.10.2",
|
|
127
|
+
"ramda-adjunct": "^5.0.0",
|
|
126
128
|
"traverse": "=0.6.8"
|
|
127
129
|
},
|
|
128
130
|
"overrides": {
|