Skip to content

Commit 03c0bba

Browse files
authored
chore(deps): replace cookie with @swaggerexpect/cookie (#3761)
This should be a fully backward compatible replacement with benefit of new library being compatible with Node.js 12.20.x. Closes #3714
1 parent 02b40a6 commit 03c0bba

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

package-lock.json

+13-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@swagger-api/apidom-json-pointer": ">=1.0.0-beta.6 <1.0.0-rc.0",
8080
"@swagger-api/apidom-ns-openapi-3-1": ">=1.0.0-beta.6 <1.0.0-rc.0",
8181
"@swagger-api/apidom-reference": ">=1.0.0-beta.6 <1.0.0-rc.0",
82-
"cookie": "~0.7.2",
82+
"@swaggerexpert/cookie": "^1.4.1",
8383
"deepmerge": "~4.3.0",
8484
"fast-json-patch": "^3.0.0-1",
8585
"js-yaml": "^4.1.0",

src/execute/index.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import cookie from 'cookie';
21
import { identity } from 'ramda';
32
import { isPlainObject } from 'ramda-adjunct';
43
import {
54
test as testServerURLTemplate,
65
substitute as substituteServerURLTemplate,
76
} from 'openapi-server-url-templating';
7+
import {
8+
serializeCookie,
9+
cookieValueLenientEncoder,
10+
cookieNameLenientValidator,
11+
cookieValueLenientValidator,
12+
} from '@swaggerexpert/cookie';
813
import { ApiDOMStructuredError } from '@swagger-api/apidom-error';
914
import { url } from '@swagger-api/apidom-reference/configuration/empty';
1015

@@ -297,7 +302,15 @@ export function buildRequest(options) {
297302
const cookieString = Object.keys(req.cookies).reduce((prev, cookieName) => {
298303
const cookieValue = req.cookies[cookieName];
299304
const prefix = prev ? '&' : '';
300-
const stringified = cookie.serialize(cookieName, cookieValue);
305+
const stringified = serializeCookie([[cookieName, cookieValue]], {
306+
encoders: {
307+
value: cookieValueLenientEncoder,
308+
},
309+
validators: {
310+
name: cookieNameLenientValidator,
311+
value: cookieValueLenientValidator,
312+
},
313+
});
301314
return prev + prefix + stringified;
302315
}, '');
303316
req.headers.Cookie = cookieString;

0 commit comments

Comments
 (0)