swagger-client 3.33.1 → 3.34.0
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 +9470 -6279
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +17 -11
- package/es/execute/oas3/parameter-builders.js +25 -6
- package/es/execute/oas3/style-serializer.js +1 -2
- package/es/helpers/cookie-value-encoder.js +5 -0
- package/lib/execute/index.js +16 -10
- package/lib/execute/oas3/parameter-builders.js +25 -6
- package/lib/execute/oas3/style-serializer.js +1 -2
- package/lib/helpers/cookie-value-encoder.js +9 -0
- package/package.json +12 -12
package/es/execute/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import cookie from 'cookie';
|
|
2
1
|
import { identity } from 'ramda';
|
|
3
|
-
import { isPlainObject } from 'ramda-adjunct';
|
|
2
|
+
import { isPlainObject, isNonEmptyString } from 'ramda-adjunct';
|
|
4
3
|
import { test as testServerURLTemplate, substitute as substituteServerURLTemplate } from 'openapi-server-url-templating';
|
|
4
|
+
import { serializeCookie, cookieValueLenientEncoder, cookieNameLenientValidator, cookieValueLenientValidator } from '@swaggerexpert/cookie';
|
|
5
5
|
import { ApiDOMStructuredError } from '@swagger-api/apidom-error';
|
|
6
6
|
import { url } from '@swagger-api/apidom-reference/configuration/empty';
|
|
7
7
|
import { DEFAULT_BASE_URL, DEFAULT_OPENAPI_3_SERVER } from '../constants.js';
|
|
@@ -105,7 +105,6 @@ export function execute({
|
|
|
105
105
|
|
|
106
106
|
// Build a request, which can be handled by the `http.js` implementation.
|
|
107
107
|
export function buildRequest(options) {
|
|
108
|
-
var _baseURL;
|
|
109
108
|
const {
|
|
110
109
|
spec,
|
|
111
110
|
operationId,
|
|
@@ -167,7 +166,7 @@ export function buildRequest(options) {
|
|
|
167
166
|
method,
|
|
168
167
|
pathName
|
|
169
168
|
} = operationRaw;
|
|
170
|
-
baseURL =
|
|
169
|
+
baseURL = baseURL !== null && baseURL !== void 0 ? baseURL : baseUrl({
|
|
171
170
|
spec,
|
|
172
171
|
scheme,
|
|
173
172
|
contextUrl,
|
|
@@ -261,13 +260,20 @@ export function buildRequest(options) {
|
|
|
261
260
|
// If the cookie convenience object exists in our request,
|
|
262
261
|
// serialize its content and then delete the cookie object.
|
|
263
262
|
if (req.cookies && Object.keys(req.cookies).length) {
|
|
264
|
-
const cookieString =
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
263
|
+
const cookieString = serializeCookie(req.cookies, {
|
|
264
|
+
encoders: {
|
|
265
|
+
value: cookieValueLenientEncoder
|
|
266
|
+
},
|
|
267
|
+
validators: {
|
|
268
|
+
name: cookieNameLenientValidator,
|
|
269
|
+
value: cookieValueLenientValidator
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (isNonEmptyString(req.headers.Cookie)) {
|
|
273
|
+
req.headers.Cookie += `; ${cookieString}`;
|
|
274
|
+
} else {
|
|
275
|
+
req.headers.Cookie = cookieString;
|
|
276
|
+
}
|
|
271
277
|
}
|
|
272
278
|
if (req.cookies) {
|
|
273
279
|
// even if no cookies were defined, we need to remove
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { resolve as resolvePathTemplate } from 'openapi-path-templating';
|
|
2
|
+
import { serializeCookie } from '@swaggerexpert/cookie';
|
|
2
3
|
import stylize, { encodeCharacters } from './style-serializer.js';
|
|
3
4
|
import serialize from './content-serializer.js';
|
|
5
|
+
import cookieValueEncoder from '../../helpers/cookie-value-encoder.js';
|
|
4
6
|
export function path({
|
|
5
7
|
req,
|
|
6
8
|
value,
|
|
@@ -31,7 +33,7 @@ export function path({
|
|
|
31
33
|
key: parameter.name,
|
|
32
34
|
value: val,
|
|
33
35
|
style: style || 'simple',
|
|
34
|
-
explode: explode
|
|
36
|
+
explode: explode !== null && explode !== void 0 ? explode : false,
|
|
35
37
|
escape: 'reserved'
|
|
36
38
|
})
|
|
37
39
|
});
|
|
@@ -112,21 +114,38 @@ export function cookie({
|
|
|
112
114
|
parameter,
|
|
113
115
|
value
|
|
114
116
|
}) {
|
|
117
|
+
const {
|
|
118
|
+
name: cookieName
|
|
119
|
+
} = parameter;
|
|
115
120
|
req.headers = req.headers || {};
|
|
116
|
-
const type = typeof value;
|
|
117
121
|
if (value !== undefined && parameter.content) {
|
|
118
122
|
const effectiveMediaType = Object.keys(parameter.content)[0];
|
|
119
|
-
|
|
123
|
+
const cookieValue = serialize(value, effectiveMediaType);
|
|
124
|
+
req.headers.Cookie = serializeCookie({
|
|
125
|
+
[cookieName]: cookieValue
|
|
126
|
+
}, {
|
|
127
|
+
encoders: {
|
|
128
|
+
value: cookieValueEncoder
|
|
129
|
+
}
|
|
130
|
+
});
|
|
120
131
|
return;
|
|
121
132
|
}
|
|
122
133
|
if (value !== undefined && !(Array.isArray(value) && value.length === 0)) {
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
var _parameter$explode;
|
|
135
|
+
const serializedValue = stylize({
|
|
125
136
|
key: parameter.name,
|
|
126
137
|
value,
|
|
127
138
|
escape: false,
|
|
128
139
|
style: parameter.style || 'form',
|
|
129
|
-
explode:
|
|
140
|
+
explode: (_parameter$explode = parameter.explode) !== null && _parameter$explode !== void 0 ? _parameter$explode : false
|
|
141
|
+
});
|
|
142
|
+
const cookieValue = Array.isArray(value) && parameter.explode ? `${cookieName}=${serializedValue}` : serializedValue;
|
|
143
|
+
req.headers.Cookie = serializeCookie({
|
|
144
|
+
[cookieName]: cookieValue
|
|
145
|
+
}, {
|
|
146
|
+
encoders: {
|
|
147
|
+
value: cookieValueEncoder
|
|
148
|
+
}
|
|
130
149
|
});
|
|
131
150
|
}
|
|
132
151
|
}
|
|
@@ -32,7 +32,6 @@ export default function stylize(config) {
|
|
|
32
32
|
return encodePrimitive(config);
|
|
33
33
|
}
|
|
34
34
|
export function valueEncoder(value, escape = false) {
|
|
35
|
-
var _value;
|
|
36
35
|
if (Array.isArray(value) || value !== null && typeof value === 'object') {
|
|
37
36
|
value = JSON.stringify(value);
|
|
38
37
|
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
@@ -41,7 +40,7 @@ export function valueEncoder(value, escape = false) {
|
|
|
41
40
|
if (escape && typeof value === 'string' && value.length > 0) {
|
|
42
41
|
return encodeCharacters(value, escape);
|
|
43
42
|
}
|
|
44
|
-
return
|
|
43
|
+
return value !== null && value !== void 0 ? value : '';
|
|
45
44
|
}
|
|
46
45
|
function encodeArray({
|
|
47
46
|
key,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { cookieValueStrictEncoder } from '@swaggerexpert/cookie';
|
|
2
|
+
const eqSignPE = '%3D';
|
|
3
|
+
const ampersandPE = '%26';
|
|
4
|
+
const cookieValueEncoder = cookieValue => cookieValueStrictEncoder(cookieValue).replace(/[=&]/gu, match => match === '=' ? eqSignPE : ampersandPE);
|
|
5
|
+
export default cookieValueEncoder;
|
package/lib/execute/index.js
CHANGED
|
@@ -7,10 +7,10 @@ exports.baseUrl = baseUrl;
|
|
|
7
7
|
exports.buildRequest = buildRequest;
|
|
8
8
|
exports.execute = execute;
|
|
9
9
|
exports.self = void 0;
|
|
10
|
-
var _cookie = _interopRequireDefault(require("cookie"));
|
|
11
10
|
var _ramda = require("ramda");
|
|
12
11
|
var _ramdaAdjunct = require("ramda-adjunct");
|
|
13
12
|
var _openapiServerUrlTemplating = require("openapi-server-url-templating");
|
|
13
|
+
var _cookie = require("@swaggerexpert/cookie");
|
|
14
14
|
var _apidomError = require("@swagger-api/apidom-error");
|
|
15
15
|
var _empty = require("@swagger-api/apidom-reference/configuration/empty");
|
|
16
16
|
var _constants = require("../constants.js");
|
|
@@ -114,7 +114,6 @@ function execute({
|
|
|
114
114
|
|
|
115
115
|
// Build a request, which can be handled by the `http.js` implementation.
|
|
116
116
|
function buildRequest(options) {
|
|
117
|
-
var _baseURL;
|
|
118
117
|
const {
|
|
119
118
|
spec,
|
|
120
119
|
operationId,
|
|
@@ -176,7 +175,7 @@ function buildRequest(options) {
|
|
|
176
175
|
method,
|
|
177
176
|
pathName
|
|
178
177
|
} = operationRaw;
|
|
179
|
-
baseURL =
|
|
178
|
+
baseURL = baseURL != null ? baseURL : baseUrl({
|
|
180
179
|
spec,
|
|
181
180
|
scheme,
|
|
182
181
|
contextUrl,
|
|
@@ -270,13 +269,20 @@ function buildRequest(options) {
|
|
|
270
269
|
// If the cookie convenience object exists in our request,
|
|
271
270
|
// serialize its content and then delete the cookie object.
|
|
272
271
|
if (req.cookies && Object.keys(req.cookies).length) {
|
|
273
|
-
const cookieString =
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
272
|
+
const cookieString = (0, _cookie.serializeCookie)(req.cookies, {
|
|
273
|
+
encoders: {
|
|
274
|
+
value: _cookie.cookieValueLenientEncoder
|
|
275
|
+
},
|
|
276
|
+
validators: {
|
|
277
|
+
name: _cookie.cookieNameLenientValidator,
|
|
278
|
+
value: _cookie.cookieValueLenientValidator
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
if ((0, _ramdaAdjunct.isNonEmptyString)(req.headers.Cookie)) {
|
|
282
|
+
req.headers.Cookie += `; ${cookieString}`;
|
|
283
|
+
} else {
|
|
284
|
+
req.headers.Cookie = cookieString;
|
|
285
|
+
}
|
|
280
286
|
}
|
|
281
287
|
if (req.cookies) {
|
|
282
288
|
// even if no cookies were defined, we need to remove
|
|
@@ -8,8 +8,10 @@ exports.header = header;
|
|
|
8
8
|
exports.path = path;
|
|
9
9
|
exports.query = query;
|
|
10
10
|
var _openapiPathTemplating = require("openapi-path-templating");
|
|
11
|
+
var _cookie = require("@swaggerexpert/cookie");
|
|
11
12
|
var _styleSerializer = _interopRequireWildcard(require("./style-serializer.js"));
|
|
12
13
|
var _contentSerializer = _interopRequireDefault(require("./content-serializer.js"));
|
|
14
|
+
var _cookieValueEncoder = _interopRequireDefault(require("../../helpers/cookie-value-encoder.js"));
|
|
13
15
|
function path({
|
|
14
16
|
req,
|
|
15
17
|
value,
|
|
@@ -40,7 +42,7 @@ function path({
|
|
|
40
42
|
key: parameter.name,
|
|
41
43
|
value: val,
|
|
42
44
|
style: style || 'simple',
|
|
43
|
-
explode: explode
|
|
45
|
+
explode: explode != null ? explode : false,
|
|
44
46
|
escape: 'reserved'
|
|
45
47
|
})
|
|
46
48
|
});
|
|
@@ -121,21 +123,38 @@ function cookie({
|
|
|
121
123
|
parameter,
|
|
122
124
|
value
|
|
123
125
|
}) {
|
|
126
|
+
const {
|
|
127
|
+
name: cookieName
|
|
128
|
+
} = parameter;
|
|
124
129
|
req.headers = req.headers || {};
|
|
125
|
-
const type = typeof value;
|
|
126
130
|
if (value !== undefined && parameter.content) {
|
|
127
131
|
const effectiveMediaType = Object.keys(parameter.content)[0];
|
|
128
|
-
|
|
132
|
+
const cookieValue = (0, _contentSerializer.default)(value, effectiveMediaType);
|
|
133
|
+
req.headers.Cookie = (0, _cookie.serializeCookie)({
|
|
134
|
+
[cookieName]: cookieValue
|
|
135
|
+
}, {
|
|
136
|
+
encoders: {
|
|
137
|
+
value: _cookieValueEncoder.default
|
|
138
|
+
}
|
|
139
|
+
});
|
|
129
140
|
return;
|
|
130
141
|
}
|
|
131
142
|
if (value !== undefined && !(Array.isArray(value) && value.length === 0)) {
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
var _parameter$explode;
|
|
144
|
+
const serializedValue = (0, _styleSerializer.default)({
|
|
134
145
|
key: parameter.name,
|
|
135
146
|
value,
|
|
136
147
|
escape: false,
|
|
137
148
|
style: parameter.style || 'form',
|
|
138
|
-
explode:
|
|
149
|
+
explode: (_parameter$explode = parameter.explode) != null ? _parameter$explode : false
|
|
150
|
+
});
|
|
151
|
+
const cookieValue = Array.isArray(value) && parameter.explode ? `${cookieName}=${serializedValue}` : serializedValue;
|
|
152
|
+
req.headers.Cookie = (0, _cookie.serializeCookie)({
|
|
153
|
+
[cookieName]: cookieValue
|
|
154
|
+
}, {
|
|
155
|
+
encoders: {
|
|
156
|
+
value: _cookieValueEncoder.default
|
|
157
|
+
}
|
|
139
158
|
});
|
|
140
159
|
}
|
|
141
160
|
}
|
|
@@ -38,7 +38,6 @@ function stylize(config) {
|
|
|
38
38
|
return encodePrimitive(config);
|
|
39
39
|
}
|
|
40
40
|
function valueEncoder(value, escape = false) {
|
|
41
|
-
var _value;
|
|
42
41
|
if (Array.isArray(value) || value !== null && typeof value === 'object') {
|
|
43
42
|
value = JSON.stringify(value);
|
|
44
43
|
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
@@ -47,7 +46,7 @@ function valueEncoder(value, escape = false) {
|
|
|
47
46
|
if (escape && typeof value === 'string' && value.length > 0) {
|
|
48
47
|
return encodeCharacters(value, escape);
|
|
49
48
|
}
|
|
50
|
-
return
|
|
49
|
+
return value != null ? value : '';
|
|
51
50
|
}
|
|
52
51
|
function encodeArray({
|
|
53
52
|
key,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _cookie = require("@swaggerexpert/cookie");
|
|
6
|
+
const eqSignPE = '%3D';
|
|
7
|
+
const ampersandPE = '%26';
|
|
8
|
+
const cookieValueEncoder = cookieValue => (0, _cookie.cookieValueStrictEncoder)(cookieValue).replace(/[=&]/gu, match => match === '=' ? eqSignPE : ampersandPE);
|
|
9
|
+
var _default = exports.default = cookieValueEncoder;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.34.0",
|
|
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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
|
|
51
51
|
"lint": "eslint src/ test/",
|
|
52
52
|
"lint:fix": "npm run lint -- --fix",
|
|
53
|
-
"link:apidom": "npm link @swagger-api/apidom-core @swagger-api/apidom-error @swagger-api/apidom-reference @swagger-api/apidom-ns-openapi-2 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-json-pointer",
|
|
53
|
+
"link:apidom": "npm link @swagger-api/apidom-core @swagger-api/apidom-error @swagger-api/apidom-reference @swagger-api/apidom-ns-openapi-2 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-ns-json-schema-draft-6 @swagger-api/apidom-ns-json-schema-draft-7 @swagger-api/apidom-ns-json-schema-2019-09 @swagger-api/apidom-ns-json-schema-2020-12 @swagger-api/apidom-json-pointer",
|
|
54
54
|
"test": "run-s test:unit:coverage test:artifact",
|
|
55
55
|
"test:unit": "cross-env BABEL_ENV=commonjs jest --runInBand --config ./config/jest/jest.unit.config.js",
|
|
56
56
|
"test:unit:coverage": "cross-env BABEL_ENV=commonjs jest --runInBand --config ./config/jest/jest.unit.coverage.config.js",
|
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
76
76
|
"@scarf/scarf": "=1.4.0",
|
|
77
|
-
"@swagger-api/apidom-core": ">=1.0.0-beta.
|
|
78
|
-
"@swagger-api/apidom-error": ">=1.0.0-beta.
|
|
79
|
-
"@swagger-api/apidom-json-pointer": ">=1.0.0-beta.
|
|
80
|
-
"@swagger-api/apidom-ns-openapi-3-1": ">=1.0.0-beta.
|
|
81
|
-
"@swagger-api/apidom-reference": ">=1.0.0-beta.
|
|
82
|
-
"cookie": "
|
|
77
|
+
"@swagger-api/apidom-core": ">=1.0.0-beta.11 <1.0.0-rc.0",
|
|
78
|
+
"@swagger-api/apidom-error": ">=1.0.0-beta.11 <1.0.0-rc.0",
|
|
79
|
+
"@swagger-api/apidom-json-pointer": ">=1.0.0-beta.11 <1.0.0-rc.0",
|
|
80
|
+
"@swagger-api/apidom-ns-openapi-3-1": ">=1.0.0-beta.11 <1.0.0-rc.0",
|
|
81
|
+
"@swagger-api/apidom-reference": ">=1.0.0-beta.11 <1.0.0-rc.0",
|
|
82
|
+
"@swaggerexpert/cookie": "^1.4.1",
|
|
83
83
|
"deepmerge": "~4.3.0",
|
|
84
84
|
"fast-json-patch": "^3.0.0-1",
|
|
85
85
|
"js-yaml": "^4.1.0",
|
|
@@ -104,11 +104,11 @@
|
|
|
104
104
|
"cross-env": "=7.0.3",
|
|
105
105
|
"eslint": "^8.42.0",
|
|
106
106
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
107
|
-
"eslint-config-prettier": "=
|
|
107
|
+
"eslint-config-prettier": "=10.0.1",
|
|
108
108
|
"eslint-plugin-import": "=2.31.0",
|
|
109
|
-
"eslint-plugin-prettier": "=5.2.
|
|
109
|
+
"eslint-plugin-prettier": "=5.2.3",
|
|
110
110
|
"expect": "^29.0.3",
|
|
111
|
-
"glob": "=11.0.
|
|
111
|
+
"glob": "=11.0.1",
|
|
112
112
|
"husky": "^9.0.11",
|
|
113
113
|
"inspectpack": "=4.7.1",
|
|
114
114
|
"install": "=0.13.0",
|
|
@@ -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.4.2",
|
|
120
120
|
"lodash": "^4.17.21",
|
|
121
121
|
"npm-run-all": "=4.1.5",
|
|
122
122
|
"prettier": "^3.1.1",
|