swagger-client 3.34.2 → 3.34.4
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 +21 -14
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +20 -13
- package/es/resolver/specmap/index.js +1 -1
- package/lib/execute/index.js +20 -13
- package/lib/resolver/specmap/index.js +1 -1
- package/package.json +3 -3
package/es/execute/index.js
CHANGED
|
@@ -14,27 +14,27 @@ import { getOperationRaw, idFromPathMethodLegacy } from '../helpers/index.js';
|
|
|
14
14
|
import { isOpenAPI3 } from '../helpers/openapi-predicates.js';
|
|
15
15
|
import { serialize as serializeCookie } from '../helpers/cookie.js';
|
|
16
16
|
const arrayOrEmpty = ar => Array.isArray(ar) ? ar : [];
|
|
17
|
-
const
|
|
17
|
+
const findObjectOrArraySchema = (schema, {
|
|
18
18
|
recurse = true,
|
|
19
19
|
depth = 1
|
|
20
20
|
} = {}) => {
|
|
21
21
|
if (!isPlainObject(schema)) return undefined;
|
|
22
22
|
|
|
23
|
-
// check if the schema is an object type
|
|
24
|
-
if (schema.type === 'object' || Array.isArray(schema.type) && schema.type.includes('object')) {
|
|
23
|
+
// check if the schema is an object or array type
|
|
24
|
+
if (schema.type === 'object' || schema.type === 'array' || Array.isArray(schema.type) && (schema.type.includes('object') || schema.type.includes('array'))) {
|
|
25
25
|
return schema;
|
|
26
26
|
}
|
|
27
27
|
if (depth > TRAVERSE_LIMIT) return undefined;
|
|
28
28
|
if (recurse) {
|
|
29
29
|
// traverse oneOf keyword first
|
|
30
|
-
const oneOfResult = Array.isArray(schema.oneOf) ? schema.oneOf.find(subschema =>
|
|
30
|
+
const oneOfResult = Array.isArray(schema.oneOf) ? schema.oneOf.find(subschema => findObjectOrArraySchema(subschema, {
|
|
31
31
|
recurse,
|
|
32
32
|
depth: depth + 1
|
|
33
33
|
})) : undefined;
|
|
34
34
|
if (oneOfResult) return oneOfResult;
|
|
35
35
|
|
|
36
36
|
// traverse anyOf keyword second
|
|
37
|
-
const anyOfResult = Array.isArray(schema.anyOf) ? schema.anyOf.find(subschema =>
|
|
37
|
+
const anyOfResult = Array.isArray(schema.anyOf) ? schema.anyOf.find(subschema => findObjectOrArraySchema(subschema, {
|
|
38
38
|
recurse,
|
|
39
39
|
depth: depth + 1
|
|
40
40
|
})) : undefined;
|
|
@@ -42,21 +42,21 @@ const findObjectSchema = (schema, {
|
|
|
42
42
|
}
|
|
43
43
|
return undefined;
|
|
44
44
|
};
|
|
45
|
-
const
|
|
45
|
+
const parseJsonObjectOrArray = ({
|
|
46
46
|
value,
|
|
47
47
|
silentFail = false
|
|
48
48
|
}) => {
|
|
49
49
|
try {
|
|
50
50
|
const parsedValue = JSON.parse(value);
|
|
51
|
-
if (
|
|
51
|
+
if (isPlainObject(parsedValue) || Array.isArray(parsedValue)) {
|
|
52
52
|
return parsedValue;
|
|
53
53
|
}
|
|
54
54
|
if (!silentFail) {
|
|
55
|
-
throw new Error('Expected JSON serialized object');
|
|
55
|
+
throw new Error('Expected JSON serialized object or array');
|
|
56
56
|
}
|
|
57
57
|
} catch {
|
|
58
58
|
if (!silentFail) {
|
|
59
|
-
throw new Error('Could not parse
|
|
59
|
+
throw new Error('Could not parse parameter value string as JSON Object or JSON Array');
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
return value;
|
|
@@ -274,17 +274,24 @@ export function buildRequest(options) {
|
|
|
274
274
|
throw new Error(`Required parameter ${parameter.name} is not provided`);
|
|
275
275
|
}
|
|
276
276
|
if (specIsOAS3 && typeof value === 'string') {
|
|
277
|
-
if (has('type', parameter.schema) &&
|
|
277
|
+
if (has('type', parameter.schema) && typeof parameter.schema.type === 'string' && findObjectOrArraySchema(parameter.schema, {
|
|
278
278
|
recurse: false
|
|
279
279
|
})) {
|
|
280
|
-
value =
|
|
280
|
+
value = parseJsonObjectOrArray({
|
|
281
281
|
value,
|
|
282
282
|
silentFail: false
|
|
283
283
|
});
|
|
284
|
-
} else if (
|
|
284
|
+
} else if (has('type', parameter.schema) && Array.isArray(parameter.schema.type) && findObjectOrArraySchema(parameter.schema, {
|
|
285
|
+
recurse: false
|
|
286
|
+
})) {
|
|
287
|
+
value = parseJsonObjectOrArray({
|
|
288
|
+
value,
|
|
289
|
+
silentFail: true
|
|
290
|
+
});
|
|
291
|
+
} else if (!has('type', parameter.schema) && findObjectOrArraySchema(parameter.schema, {
|
|
285
292
|
recurse: true
|
|
286
293
|
})) {
|
|
287
|
-
value =
|
|
294
|
+
value = parseJsonObjectOrArray({
|
|
288
295
|
value,
|
|
289
296
|
silentFail: true
|
|
290
297
|
});
|
|
@@ -121,7 +121,7 @@ class SpecMap {
|
|
|
121
121
|
if (!traversed) {
|
|
122
122
|
if (isObj) {
|
|
123
123
|
// Only store the ref if it exists
|
|
124
|
-
if (specmap.allowMetaPatches && objRef) {
|
|
124
|
+
if (specmap.allowMetaPatches && objRef && isSubPath(pathDiscriminator, updatedPath)) {
|
|
125
125
|
refCache[objRef] = true;
|
|
126
126
|
}
|
|
127
127
|
yield* traverse(val, updatedPath, patch);
|
package/lib/execute/index.js
CHANGED
|
@@ -23,27 +23,27 @@ var _index3 = require("../helpers/index.js");
|
|
|
23
23
|
var _openapiPredicates = require("../helpers/openapi-predicates.js");
|
|
24
24
|
var _cookie = require("../helpers/cookie.js");
|
|
25
25
|
const arrayOrEmpty = ar => Array.isArray(ar) ? ar : [];
|
|
26
|
-
const
|
|
26
|
+
const findObjectOrArraySchema = (schema, {
|
|
27
27
|
recurse = true,
|
|
28
28
|
depth = 1
|
|
29
29
|
} = {}) => {
|
|
30
30
|
if (!(0, _ramdaAdjunct.isPlainObject)(schema)) return undefined;
|
|
31
31
|
|
|
32
|
-
// check if the schema is an object type
|
|
33
|
-
if (schema.type === 'object' || Array.isArray(schema.type) && schema.type.includes('object')) {
|
|
32
|
+
// check if the schema is an object or array type
|
|
33
|
+
if (schema.type === 'object' || schema.type === 'array' || Array.isArray(schema.type) && (schema.type.includes('object') || schema.type.includes('array'))) {
|
|
34
34
|
return schema;
|
|
35
35
|
}
|
|
36
36
|
if (depth > _constants.TRAVERSE_LIMIT) return undefined;
|
|
37
37
|
if (recurse) {
|
|
38
38
|
// traverse oneOf keyword first
|
|
39
|
-
const oneOfResult = Array.isArray(schema.oneOf) ? schema.oneOf.find(subschema =>
|
|
39
|
+
const oneOfResult = Array.isArray(schema.oneOf) ? schema.oneOf.find(subschema => findObjectOrArraySchema(subschema, {
|
|
40
40
|
recurse,
|
|
41
41
|
depth: depth + 1
|
|
42
42
|
})) : undefined;
|
|
43
43
|
if (oneOfResult) return oneOfResult;
|
|
44
44
|
|
|
45
45
|
// traverse anyOf keyword second
|
|
46
|
-
const anyOfResult = Array.isArray(schema.anyOf) ? schema.anyOf.find(subschema =>
|
|
46
|
+
const anyOfResult = Array.isArray(schema.anyOf) ? schema.anyOf.find(subschema => findObjectOrArraySchema(subschema, {
|
|
47
47
|
recurse,
|
|
48
48
|
depth: depth + 1
|
|
49
49
|
})) : undefined;
|
|
@@ -51,21 +51,21 @@ const findObjectSchema = (schema, {
|
|
|
51
51
|
}
|
|
52
52
|
return undefined;
|
|
53
53
|
};
|
|
54
|
-
const
|
|
54
|
+
const parseJsonObjectOrArray = ({
|
|
55
55
|
value,
|
|
56
56
|
silentFail = false
|
|
57
57
|
}) => {
|
|
58
58
|
try {
|
|
59
59
|
const parsedValue = JSON.parse(value);
|
|
60
|
-
if (
|
|
60
|
+
if ((0, _ramdaAdjunct.isPlainObject)(parsedValue) || Array.isArray(parsedValue)) {
|
|
61
61
|
return parsedValue;
|
|
62
62
|
}
|
|
63
63
|
if (!silentFail) {
|
|
64
|
-
throw new Error('Expected JSON serialized object');
|
|
64
|
+
throw new Error('Expected JSON serialized object or array');
|
|
65
65
|
}
|
|
66
66
|
} catch {
|
|
67
67
|
if (!silentFail) {
|
|
68
|
-
throw new Error('Could not parse
|
|
68
|
+
throw new Error('Could not parse parameter value string as JSON Object or JSON Array');
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
return value;
|
|
@@ -283,17 +283,24 @@ function buildRequest(options) {
|
|
|
283
283
|
throw new Error(`Required parameter ${parameter.name} is not provided`);
|
|
284
284
|
}
|
|
285
285
|
if (specIsOAS3 && typeof value === 'string') {
|
|
286
|
-
if ((0, _ramda.has)('type', parameter.schema) &&
|
|
286
|
+
if ((0, _ramda.has)('type', parameter.schema) && typeof parameter.schema.type === 'string' && findObjectOrArraySchema(parameter.schema, {
|
|
287
287
|
recurse: false
|
|
288
288
|
})) {
|
|
289
|
-
value =
|
|
289
|
+
value = parseJsonObjectOrArray({
|
|
290
290
|
value,
|
|
291
291
|
silentFail: false
|
|
292
292
|
});
|
|
293
|
-
} else if (
|
|
293
|
+
} else if ((0, _ramda.has)('type', parameter.schema) && Array.isArray(parameter.schema.type) && findObjectOrArraySchema(parameter.schema, {
|
|
294
|
+
recurse: false
|
|
295
|
+
})) {
|
|
296
|
+
value = parseJsonObjectOrArray({
|
|
297
|
+
value,
|
|
298
|
+
silentFail: true
|
|
299
|
+
});
|
|
300
|
+
} else if (!(0, _ramda.has)('type', parameter.schema) && findObjectOrArraySchema(parameter.schema, {
|
|
294
301
|
recurse: true
|
|
295
302
|
})) {
|
|
296
|
-
value =
|
|
303
|
+
value = parseJsonObjectOrArray({
|
|
297
304
|
value,
|
|
298
305
|
silentFail: true
|
|
299
306
|
});
|
|
@@ -128,7 +128,7 @@ class SpecMap {
|
|
|
128
128
|
if (!traversed) {
|
|
129
129
|
if (isObj) {
|
|
130
130
|
// Only store the ref if it exists
|
|
131
|
-
if (specmap.allowMetaPatches && objRef) {
|
|
131
|
+
if (specmap.allowMetaPatches && objRef && isSubPath(pathDiscriminator, updatedPath)) {
|
|
132
132
|
refCache[objRef] = true;
|
|
133
133
|
}
|
|
134
134
|
yield* traverse(val, updatedPath, patch);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-client",
|
|
3
|
-
"version": "3.34.
|
|
3
|
+
"version": "3.34.4",
|
|
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",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
107
107
|
"eslint-config-prettier": "=10.1.1",
|
|
108
108
|
"eslint-plugin-import": "=2.31.0",
|
|
109
|
-
"eslint-plugin-prettier": "=5.2.
|
|
109
|
+
"eslint-plugin-prettier": "=5.2.5",
|
|
110
110
|
"expect": "^29.0.3",
|
|
111
111
|
"glob": "=11.0.1",
|
|
112
112
|
"husky": "^9.0.11",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"jest-environment-jsdom": "^29.0.3",
|
|
117
117
|
"json-loader": "=0.5.7",
|
|
118
118
|
"license-checker": "=25.0.1",
|
|
119
|
-
"lint-staged": "=15.
|
|
119
|
+
"lint-staged": "=15.5.0",
|
|
120
120
|
"lodash": "^4.17.21",
|
|
121
121
|
"npm-run-all": "=4.1.5",
|
|
122
122
|
"prettier": "^3.1.1",
|