swagger-client 3.26.4 → 3.26.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 +154 -67
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/oas3/style-serializer.js +24 -25
- package/es/http/index.js +3 -7
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +2 -1
- package/lib/execute/oas3/style-serializer.js +25 -25
- package/lib/http/index.js +2 -6
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +2 -1
- package/package.json +7 -7
|
@@ -46,6 +46,14 @@ export default function stylize(config) {
|
|
|
46
46
|
}
|
|
47
47
|
return encodePrimitive(config);
|
|
48
48
|
}
|
|
49
|
+
export function valueEncoder(value, escape) {
|
|
50
|
+
if (Array.isArray(value) || value !== null && typeof value === 'object') {
|
|
51
|
+
value = JSON.stringify(value);
|
|
52
|
+
}
|
|
53
|
+
return encodeDisallowedCharacters(value, {
|
|
54
|
+
escape
|
|
55
|
+
});
|
|
56
|
+
}
|
|
49
57
|
function encodeArray({
|
|
50
58
|
key,
|
|
51
59
|
value,
|
|
@@ -53,17 +61,14 @@ function encodeArray({
|
|
|
53
61
|
explode,
|
|
54
62
|
escape
|
|
55
63
|
}) {
|
|
56
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
57
|
-
escape
|
|
58
|
-
});
|
|
59
64
|
if (style === 'simple') {
|
|
60
|
-
return value.map(val => valueEncoder(val)).join(',');
|
|
65
|
+
return value.map(val => valueEncoder(val, escape)).join(',');
|
|
61
66
|
}
|
|
62
67
|
if (style === 'label') {
|
|
63
|
-
return `.${value.map(val => valueEncoder(val)).join('.')}`;
|
|
68
|
+
return `.${value.map(val => valueEncoder(val, escape)).join('.')}`;
|
|
64
69
|
}
|
|
65
70
|
if (style === 'matrix') {
|
|
66
|
-
return value.map(val => valueEncoder(val)).reduce((prev, curr) => {
|
|
71
|
+
return value.map(val => valueEncoder(val, escape)).reduce((prev, curr) => {
|
|
67
72
|
if (!prev || explode) {
|
|
68
73
|
return `${prev || ''};${key}=${curr}`;
|
|
69
74
|
}
|
|
@@ -72,15 +77,15 @@ function encodeArray({
|
|
|
72
77
|
}
|
|
73
78
|
if (style === 'form') {
|
|
74
79
|
const after = explode ? `&${key}=` : ',';
|
|
75
|
-
return value.map(val => valueEncoder(val)).join(after);
|
|
80
|
+
return value.map(val => valueEncoder(val, escape)).join(after);
|
|
76
81
|
}
|
|
77
82
|
if (style === 'spaceDelimited') {
|
|
78
83
|
const after = explode ? `${key}=` : '';
|
|
79
|
-
return value.map(val => valueEncoder(val)).join(` ${after}`);
|
|
84
|
+
return value.map(val => valueEncoder(val, escape)).join(` ${after}`);
|
|
80
85
|
}
|
|
81
86
|
if (style === 'pipeDelimited') {
|
|
82
87
|
const after = explode ? `${key}=` : '';
|
|
83
|
-
return value.map(val => valueEncoder(val)).join(`|${after}`);
|
|
88
|
+
return value.map(val => valueEncoder(val, escape)).join(`|${after}`);
|
|
84
89
|
}
|
|
85
90
|
return undefined;
|
|
86
91
|
}
|
|
@@ -91,13 +96,10 @@ function encodeObject({
|
|
|
91
96
|
explode,
|
|
92
97
|
escape
|
|
93
98
|
}) {
|
|
94
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
95
|
-
escape
|
|
96
|
-
});
|
|
97
99
|
const valueKeys = Object.keys(value);
|
|
98
100
|
if (style === 'simple') {
|
|
99
101
|
return valueKeys.reduce((prev, curr) => {
|
|
100
|
-
const val = valueEncoder(value[curr]);
|
|
102
|
+
const val = valueEncoder(value[curr], escape);
|
|
101
103
|
const middleChar = explode ? '=' : ',';
|
|
102
104
|
const prefix = prev ? `${prev},` : '';
|
|
103
105
|
return `${prefix}${curr}${middleChar}${val}`;
|
|
@@ -105,7 +107,7 @@ function encodeObject({
|
|
|
105
107
|
}
|
|
106
108
|
if (style === 'label') {
|
|
107
109
|
return valueKeys.reduce((prev, curr) => {
|
|
108
|
-
const val = valueEncoder(value[curr]);
|
|
110
|
+
const val = valueEncoder(value[curr], escape);
|
|
109
111
|
const middleChar = explode ? '=' : '.';
|
|
110
112
|
const prefix = prev ? `${prev}.` : '.';
|
|
111
113
|
return `${prefix}${curr}${middleChar}${val}`;
|
|
@@ -113,7 +115,7 @@ function encodeObject({
|
|
|
113
115
|
}
|
|
114
116
|
if (style === 'matrix' && explode) {
|
|
115
117
|
return valueKeys.reduce((prev, curr) => {
|
|
116
|
-
const val = valueEncoder(value[curr]);
|
|
118
|
+
const val = valueEncoder(value[curr], escape);
|
|
117
119
|
const prefix = prev ? `${prev};` : ';';
|
|
118
120
|
return `${prefix}${curr}=${val}`;
|
|
119
121
|
}, '');
|
|
@@ -121,14 +123,14 @@ function encodeObject({
|
|
|
121
123
|
if (style === 'matrix') {
|
|
122
124
|
// no explode
|
|
123
125
|
return valueKeys.reduce((prev, curr) => {
|
|
124
|
-
const val = valueEncoder(value[curr]);
|
|
126
|
+
const val = valueEncoder(value[curr], escape);
|
|
125
127
|
const prefix = prev ? `${prev},` : `;${key}=`;
|
|
126
128
|
return `${prefix}${curr},${val}`;
|
|
127
129
|
}, '');
|
|
128
130
|
}
|
|
129
131
|
if (style === 'form') {
|
|
130
132
|
return valueKeys.reduce((prev, curr) => {
|
|
131
|
-
const val = valueEncoder(value[curr]);
|
|
133
|
+
const val = valueEncoder(value[curr], escape);
|
|
132
134
|
const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';
|
|
133
135
|
const separator = explode ? '=' : ',';
|
|
134
136
|
return `${prefix}${curr}${separator}${val}`;
|
|
@@ -142,23 +144,20 @@ function encodePrimitive({
|
|
|
142
144
|
style,
|
|
143
145
|
escape
|
|
144
146
|
}) {
|
|
145
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
146
|
-
escape
|
|
147
|
-
});
|
|
148
147
|
if (style === 'simple') {
|
|
149
|
-
return valueEncoder(value);
|
|
148
|
+
return valueEncoder(value, escape);
|
|
150
149
|
}
|
|
151
150
|
if (style === 'label') {
|
|
152
|
-
return `.${valueEncoder(value)}`;
|
|
151
|
+
return `.${valueEncoder(value, escape)}`;
|
|
153
152
|
}
|
|
154
153
|
if (style === 'matrix') {
|
|
155
|
-
return `;${key}=${valueEncoder(value)}`;
|
|
154
|
+
return `;${key}=${valueEncoder(value, escape)}`;
|
|
156
155
|
}
|
|
157
156
|
if (style === 'form') {
|
|
158
|
-
return valueEncoder(value);
|
|
157
|
+
return valueEncoder(value, escape);
|
|
159
158
|
}
|
|
160
159
|
if (style === 'deepObject') {
|
|
161
|
-
return valueEncoder(value,
|
|
160
|
+
return valueEncoder(value, escape);
|
|
162
161
|
}
|
|
163
162
|
return undefined;
|
|
164
163
|
}
|
package/es/http/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import qs from 'qs';
|
|
2
2
|
import jsYaml from 'js-yaml';
|
|
3
3
|
import '../helpers/fetch-polyfill.node.js';
|
|
4
|
-
import {
|
|
4
|
+
import { valueEncoder } from '../execute/oas3/style-serializer.js';
|
|
5
5
|
|
|
6
6
|
// For testing
|
|
7
7
|
export const self = {
|
|
@@ -297,12 +297,8 @@ function formatKeyValueBySerializationOption(key, value, skipEncoding, serializa
|
|
|
297
297
|
const explode = typeof serializationOption.explode === 'undefined' ? style === 'form' : serializationOption.explode;
|
|
298
298
|
// eslint-disable-next-line no-nested-ternary
|
|
299
299
|
const escape = skipEncoding ? false : serializationOption && serializationOption.allowReserved ? 'unsafe' : 'reserved';
|
|
300
|
-
const encodeFn = v =>
|
|
301
|
-
|
|
302
|
-
});
|
|
303
|
-
const encodeKeyFn = skipEncoding ? k => k : k => encodeDisallowedCharacters(k, {
|
|
304
|
-
escape
|
|
305
|
-
});
|
|
300
|
+
const encodeFn = v => valueEncoder(v, escape);
|
|
301
|
+
const encodeKeyFn = skipEncoding ? k => k : k => encodeFn(k);
|
|
306
302
|
|
|
307
303
|
// Primitive
|
|
308
304
|
if (typeof value !== 'object') {
|
package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import ParameterMacroVisitor from './visitors/parameters.js';
|
|
|
8
8
|
import ModelPropertyMacroVisitor from './visitors/properties.js';
|
|
9
9
|
import AllOfVisitor from './visitors/all-of.js';
|
|
10
10
|
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
|
|
11
|
+
const mergeAllVisitorsAsync = mergeAllVisitors[Symbol.for('nodejs.util.promisify.custom')];
|
|
11
12
|
const OpenApi3_1SwaggerClientDereferenceStrategy = OpenApi3_1DereferenceStrategy.compose({
|
|
12
13
|
props: {
|
|
13
14
|
useCircularStructures: true,
|
|
@@ -89,7 +90,7 @@ const OpenApi3_1SwaggerClientDereferenceStrategy = OpenApi3_1DereferenceStrategy
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
// establish root visitor by visitor merging
|
|
92
|
-
const rootVisitor =
|
|
93
|
+
const rootVisitor = mergeAllVisitorsAsync(visitors, {
|
|
93
94
|
nodeTypeGetter: getNodeType
|
|
94
95
|
});
|
|
95
96
|
const dereferencedElement = await visitAsync(refSet.rootRef.value, rootVisitor, {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = stylize;
|
|
5
5
|
exports.encodeDisallowedCharacters = encodeDisallowedCharacters;
|
|
6
|
+
exports.valueEncoder = valueEncoder;
|
|
6
7
|
const isRfc3986Reserved = char => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
|
|
7
8
|
const isRrc3986Unreserved = char => /^[a-z0-9\-._~]+$/i.test(char);
|
|
8
9
|
|
|
@@ -51,6 +52,14 @@ function stylize(config) {
|
|
|
51
52
|
}
|
|
52
53
|
return encodePrimitive(config);
|
|
53
54
|
}
|
|
55
|
+
function valueEncoder(value, escape) {
|
|
56
|
+
if (Array.isArray(value) || value !== null && typeof value === 'object') {
|
|
57
|
+
value = JSON.stringify(value);
|
|
58
|
+
}
|
|
59
|
+
return encodeDisallowedCharacters(value, {
|
|
60
|
+
escape
|
|
61
|
+
});
|
|
62
|
+
}
|
|
54
63
|
function encodeArray({
|
|
55
64
|
key,
|
|
56
65
|
value,
|
|
@@ -58,17 +67,14 @@ function encodeArray({
|
|
|
58
67
|
explode,
|
|
59
68
|
escape
|
|
60
69
|
}) {
|
|
61
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
62
|
-
escape
|
|
63
|
-
});
|
|
64
70
|
if (style === 'simple') {
|
|
65
|
-
return value.map(val => valueEncoder(val)).join(',');
|
|
71
|
+
return value.map(val => valueEncoder(val, escape)).join(',');
|
|
66
72
|
}
|
|
67
73
|
if (style === 'label') {
|
|
68
|
-
return `.${value.map(val => valueEncoder(val)).join('.')}`;
|
|
74
|
+
return `.${value.map(val => valueEncoder(val, escape)).join('.')}`;
|
|
69
75
|
}
|
|
70
76
|
if (style === 'matrix') {
|
|
71
|
-
return value.map(val => valueEncoder(val)).reduce((prev, curr) => {
|
|
77
|
+
return value.map(val => valueEncoder(val, escape)).reduce((prev, curr) => {
|
|
72
78
|
if (!prev || explode) {
|
|
73
79
|
return `${prev || ''};${key}=${curr}`;
|
|
74
80
|
}
|
|
@@ -77,15 +83,15 @@ function encodeArray({
|
|
|
77
83
|
}
|
|
78
84
|
if (style === 'form') {
|
|
79
85
|
const after = explode ? `&${key}=` : ',';
|
|
80
|
-
return value.map(val => valueEncoder(val)).join(after);
|
|
86
|
+
return value.map(val => valueEncoder(val, escape)).join(after);
|
|
81
87
|
}
|
|
82
88
|
if (style === 'spaceDelimited') {
|
|
83
89
|
const after = explode ? `${key}=` : '';
|
|
84
|
-
return value.map(val => valueEncoder(val)).join(` ${after}`);
|
|
90
|
+
return value.map(val => valueEncoder(val, escape)).join(` ${after}`);
|
|
85
91
|
}
|
|
86
92
|
if (style === 'pipeDelimited') {
|
|
87
93
|
const after = explode ? `${key}=` : '';
|
|
88
|
-
return value.map(val => valueEncoder(val)).join(`|${after}`);
|
|
94
|
+
return value.map(val => valueEncoder(val, escape)).join(`|${after}`);
|
|
89
95
|
}
|
|
90
96
|
return undefined;
|
|
91
97
|
}
|
|
@@ -96,13 +102,10 @@ function encodeObject({
|
|
|
96
102
|
explode,
|
|
97
103
|
escape
|
|
98
104
|
}) {
|
|
99
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
100
|
-
escape
|
|
101
|
-
});
|
|
102
105
|
const valueKeys = Object.keys(value);
|
|
103
106
|
if (style === 'simple') {
|
|
104
107
|
return valueKeys.reduce((prev, curr) => {
|
|
105
|
-
const val = valueEncoder(value[curr]);
|
|
108
|
+
const val = valueEncoder(value[curr], escape);
|
|
106
109
|
const middleChar = explode ? '=' : ',';
|
|
107
110
|
const prefix = prev ? `${prev},` : '';
|
|
108
111
|
return `${prefix}${curr}${middleChar}${val}`;
|
|
@@ -110,7 +113,7 @@ function encodeObject({
|
|
|
110
113
|
}
|
|
111
114
|
if (style === 'label') {
|
|
112
115
|
return valueKeys.reduce((prev, curr) => {
|
|
113
|
-
const val = valueEncoder(value[curr]);
|
|
116
|
+
const val = valueEncoder(value[curr], escape);
|
|
114
117
|
const middleChar = explode ? '=' : '.';
|
|
115
118
|
const prefix = prev ? `${prev}.` : '.';
|
|
116
119
|
return `${prefix}${curr}${middleChar}${val}`;
|
|
@@ -118,7 +121,7 @@ function encodeObject({
|
|
|
118
121
|
}
|
|
119
122
|
if (style === 'matrix' && explode) {
|
|
120
123
|
return valueKeys.reduce((prev, curr) => {
|
|
121
|
-
const val = valueEncoder(value[curr]);
|
|
124
|
+
const val = valueEncoder(value[curr], escape);
|
|
122
125
|
const prefix = prev ? `${prev};` : ';';
|
|
123
126
|
return `${prefix}${curr}=${val}`;
|
|
124
127
|
}, '');
|
|
@@ -126,14 +129,14 @@ function encodeObject({
|
|
|
126
129
|
if (style === 'matrix') {
|
|
127
130
|
// no explode
|
|
128
131
|
return valueKeys.reduce((prev, curr) => {
|
|
129
|
-
const val = valueEncoder(value[curr]);
|
|
132
|
+
const val = valueEncoder(value[curr], escape);
|
|
130
133
|
const prefix = prev ? `${prev},` : `;${key}=`;
|
|
131
134
|
return `${prefix}${curr},${val}`;
|
|
132
135
|
}, '');
|
|
133
136
|
}
|
|
134
137
|
if (style === 'form') {
|
|
135
138
|
return valueKeys.reduce((prev, curr) => {
|
|
136
|
-
const val = valueEncoder(value[curr]);
|
|
139
|
+
const val = valueEncoder(value[curr], escape);
|
|
137
140
|
const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';
|
|
138
141
|
const separator = explode ? '=' : ',';
|
|
139
142
|
return `${prefix}${curr}${separator}${val}`;
|
|
@@ -147,23 +150,20 @@ function encodePrimitive({
|
|
|
147
150
|
style,
|
|
148
151
|
escape
|
|
149
152
|
}) {
|
|
150
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
151
|
-
escape
|
|
152
|
-
});
|
|
153
153
|
if (style === 'simple') {
|
|
154
|
-
return valueEncoder(value);
|
|
154
|
+
return valueEncoder(value, escape);
|
|
155
155
|
}
|
|
156
156
|
if (style === 'label') {
|
|
157
|
-
return `.${valueEncoder(value)}`;
|
|
157
|
+
return `.${valueEncoder(value, escape)}`;
|
|
158
158
|
}
|
|
159
159
|
if (style === 'matrix') {
|
|
160
|
-
return `;${key}=${valueEncoder(value)}`;
|
|
160
|
+
return `;${key}=${valueEncoder(value, escape)}`;
|
|
161
161
|
}
|
|
162
162
|
if (style === 'form') {
|
|
163
|
-
return valueEncoder(value);
|
|
163
|
+
return valueEncoder(value, escape);
|
|
164
164
|
}
|
|
165
165
|
if (style === 'deepObject') {
|
|
166
|
-
return valueEncoder(value,
|
|
166
|
+
return valueEncoder(value, escape);
|
|
167
167
|
}
|
|
168
168
|
return undefined;
|
|
169
169
|
}
|
package/lib/http/index.js
CHANGED
|
@@ -310,12 +310,8 @@ function formatKeyValueBySerializationOption(key, value, skipEncoding, serializa
|
|
|
310
310
|
const explode = typeof serializationOption.explode === 'undefined' ? style === 'form' : serializationOption.explode;
|
|
311
311
|
// eslint-disable-next-line no-nested-ternary
|
|
312
312
|
const escape = skipEncoding ? false : serializationOption && serializationOption.allowReserved ? 'unsafe' : 'reserved';
|
|
313
|
-
const encodeFn = v => (0, _styleSerializer.
|
|
314
|
-
|
|
315
|
-
});
|
|
316
|
-
const encodeKeyFn = skipEncoding ? k => k : k => (0, _styleSerializer.encodeDisallowedCharacters)(k, {
|
|
317
|
-
escape
|
|
318
|
-
});
|
|
313
|
+
const encodeFn = v => (0, _styleSerializer.valueEncoder)(v, escape);
|
|
314
|
+
const encodeKeyFn = skipEncoding ? k => k : k => encodeFn(k);
|
|
319
315
|
|
|
320
316
|
// Primitive
|
|
321
317
|
if (typeof value !== 'object') {
|
package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var _allOf = _interopRequireDefault(require("./visitors/all-of.js"));
|
|
|
15
15
|
/* eslint-disable camelcase */
|
|
16
16
|
|
|
17
17
|
const visitAsync = _apidomCore.visit[Symbol.for('nodejs.util.promisify.custom')];
|
|
18
|
+
const mergeAllVisitorsAsync = _apidomCore.mergeAllVisitors[Symbol.for('nodejs.util.promisify.custom')];
|
|
18
19
|
const OpenApi3_1SwaggerClientDereferenceStrategy = _openapi.default.compose({
|
|
19
20
|
props: {
|
|
20
21
|
useCircularStructures: true,
|
|
@@ -96,7 +97,7 @@ const OpenApi3_1SwaggerClientDereferenceStrategy = _openapi.default.compose({
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
// establish root visitor by visitor merging
|
|
99
|
-
const rootVisitor = (
|
|
100
|
+
const rootVisitor = mergeAllVisitorsAsync(visitors, {
|
|
100
101
|
nodeTypeGetter: _apidomNsOpenapi.getNodeType
|
|
101
102
|
});
|
|
102
103
|
const dereferencedElement = await visitAsync(refSet.rootRef.value, rootVisitor, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-client",
|
|
3
|
-
"version": "3.26.
|
|
3
|
+
"version": "3.26.6",
|
|
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",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"eslint-plugin-import": "=2.29.1",
|
|
88
88
|
"eslint-plugin-prettier": "=5.1.3",
|
|
89
89
|
"expect": "^29.0.3",
|
|
90
|
-
"glob": "=10.3.
|
|
90
|
+
"glob": "=10.3.12",
|
|
91
91
|
"husky": "^9.0.11",
|
|
92
92
|
"inspectpack": "=4.7.1",
|
|
93
93
|
"install": "=0.13.0",
|
|
@@ -110,11 +110,11 @@
|
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
113
|
-
"@swagger-api/apidom-core": ">=0.
|
|
114
|
-
"@swagger-api/apidom-error": ">=0.
|
|
115
|
-
"@swagger-api/apidom-json-pointer": ">=0.
|
|
116
|
-
"@swagger-api/apidom-ns-openapi-3-1": ">=0.
|
|
117
|
-
"@swagger-api/apidom-reference": ">=0.
|
|
113
|
+
"@swagger-api/apidom-core": ">=0.99.0 <1.0.0",
|
|
114
|
+
"@swagger-api/apidom-error": ">=0.99.0 <1.0.0",
|
|
115
|
+
"@swagger-api/apidom-json-pointer": ">=0.99.0 <1.0.0",
|
|
116
|
+
"@swagger-api/apidom-ns-openapi-3-1": ">=0.99.0 <1.0.0",
|
|
117
|
+
"@swagger-api/apidom-reference": ">=0.99.0 <1.0.0",
|
|
118
118
|
"cookie": "~0.6.0",
|
|
119
119
|
"deepmerge": "~4.3.0",
|
|
120
120
|
"fast-json-patch": "^3.0.0-1",
|