@readme/oas-to-har 26.0.4 → 27.0.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/{chunk-ZYPAVWY2.cjs → chunk-NZMKP35V.cjs} +1 -1
- package/dist/{chunk-ZYPAVWY2.cjs.map → chunk-NZMKP35V.cjs.map} +1 -1
- package/dist/{chunk-567EY73K.js → chunk-QZNQX2VW.js} +1 -1
- package/dist/{chunk-567EY73K.js.map → chunk-QZNQX2VW.js.map} +1 -1
- package/dist/index.cjs +25 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/configure-security.cjs +2 -2
- package/dist/lib/configure-security.js +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas-to-har/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas-to-har/dist/chunk-NZMKP35V.cjs","../src/lib/configure-security.ts"],"names":[],"mappings":"AAAA;ACGA,kCAAsB;AAEtB,SAAS,QAAA,CACP,IAAA,EACA,KAAA,EACwD;AACxD,EAAA,GAAA,CAAI,CAAC,KAAA,CAAM,KAAA,EAAO,OAAO,KAAA,CAAA;AACzB,EAAA,OAAO,EAAE,IAAA,EAAM,MAAM,CAAA;AACvB;AAEe,SAAR,iBAAA,CACL,aAAA,EACA,MAAA,EACA,MAAA,EACiD;AACjD,EAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,KAAA,CAAA;AAEpB,EAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,OAAA,GAAU,CAAC,CAAC,CAAA,CAAE,OAAA,IAAW,CAAA,EAAG,OAAO,KAAA,CAAA;AAEnD,EAAA,GAAA,CAAI,iBAAC,aAAA,mBAAc,UAAA,6BAAY,eAAA,4BAAA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ACkB,QAAA;AACzB,MAAA;AACH,IAAA;AACF,EAAA;AAEgC,EAAA;AACD,IAAA;AACI,MAAA;AACd,QAAA;AACa,QAAA;AAC7B,MAAA;AACwB,IAAA;AACV,MAAA;AACE,QAAA;AACa,QAAA;AAC9B,MAAA;AAE8B,MAAA;AAEP,QAAA;AACE,QAAA;AACL,QAAA;AACpB,MAAA;AAE2B,MAAA;AACF,IAAA;AACE,MAAA;AACV,QAAA;AACa,QAAA;AAC7B,MAAA;AACH,IAAA;AACF,EAAA;AAEgC,EAAA;AACH,IAAA;AACnB,MAAA;AACyB,MAAA;AAChC,IAAA;AACH,EAAA;AAEO,EAAA;AACT;AD1BqC;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas-to-har/dist/chunk-NZMKP35V.cjs","sourcesContent":[null,"import type { OASDocument, SecuritySchemeObject } from 'oas/types';\nimport type { AuthForHAR } from './types.js';\n\nimport { isRef } from 'oas/types';\n\nfunction harValue(\n type: 'cookies' | 'headers' | 'queryString',\n value: { name: string; value: string },\n): { type: typeof type; value: typeof value } | undefined {\n if (!value.value) return undefined;\n return { type, value };\n}\n\nexport default function configureSecurity(\n apiDefinition: OASDocument,\n values: AuthForHAR,\n scheme: string,\n): ReturnType<typeof harValue> | false | undefined {\n if (!scheme) return undefined;\n\n if (Object.keys(values || {}).length === 0) return undefined;\n\n if (!apiDefinition.components?.securitySchemes?.[scheme]) return undefined;\n const security = apiDefinition.components.securitySchemes[scheme] as SecuritySchemeObject & {\n 'x-bearer-format'?: string;\n };\n\n if (isRef(security)) {\n return undefined;\n } else if (!values[scheme]) {\n // If we don't have any data for this auth scheme then we shouldn't add it.\n return false;\n }\n\n if (security.type === 'http') {\n if (security.scheme === 'basic') {\n const auth = values[scheme];\n if (typeof auth !== 'object') return false;\n if (!auth.user && !auth.pass) return false;\n\n let user = auth.user ?? null;\n if (user === null || user.length === 0) {\n user = '';\n }\n\n let pass = auth.pass ?? null;\n if (pass === null || pass.length === 0) {\n pass = '';\n }\n\n return harValue('headers', {\n name: 'authorization',\n value: `Basic ${Buffer.from(`${user}:${pass}`).toString('base64')}`,\n });\n } else if (security.scheme === 'bearer') {\n return harValue('headers', {\n name: 'authorization',\n value: `Bearer ${values[scheme]}`,\n });\n }\n }\n\n if (security.type === 'apiKey') {\n if (security.in === 'query') {\n return harValue('queryString', {\n name: security.name,\n value: String(values[scheme]),\n });\n } else if (security.in === 'header') {\n const header = {\n name: security.name,\n value: String(values[scheme]),\n };\n\n if (security['x-bearer-format']) {\n // Uppercase: token -> Token\n const bearerFormat = security['x-bearer-format'].charAt(0).toUpperCase() + security['x-bearer-format'].slice(1);\n header.name = security.name;\n header.value = `${bearerFormat} ${header.value}`;\n }\n\n return harValue('headers', header);\n } else if (security.in === 'cookie') {\n return harValue('cookies', {\n name: security.name,\n value: String(values[scheme]),\n });\n }\n }\n\n if (security.type === 'oauth2') {\n return harValue('headers', {\n name: 'authorization',\n value: `Bearer ${values[scheme]}`,\n });\n }\n\n return undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/configure-security.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/lib/configure-security.ts"],"sourcesContent":["import type { OASDocument, SecuritySchemeObject } from 'oas/types';\nimport type { AuthForHAR } from './types.js';\n\nimport { isRef } from 'oas/types';\n\nfunction harValue(\n type: 'cookies' | 'headers' | 'queryString',\n value: { name: string; value: string },\n): { type: typeof type; value: typeof value } | undefined {\n if (!value.value) return undefined;\n return { type, value };\n}\n\nexport default function configureSecurity(\n apiDefinition: OASDocument,\n values: AuthForHAR,\n scheme: string,\n): ReturnType<typeof harValue> | false | undefined {\n if (!scheme) return undefined;\n\n if (Object.keys(values || {}).length === 0) return undefined;\n\n if (!apiDefinition.components?.securitySchemes?.[scheme]) return undefined;\n const security = apiDefinition.components.securitySchemes[scheme] as SecuritySchemeObject & {\n 'x-bearer-format'?: string;\n };\n\n if (isRef(security)) {\n return undefined;\n } else if (!values[scheme]) {\n // If we don't have any data for this auth scheme then we shouldn't add it.\n return false;\n }\n\n if (security.type === 'http') {\n if (security.scheme === 'basic') {\n const auth = values[scheme];\n if (typeof auth !== 'object') return false;\n if (!auth.user && !auth.pass) return false;\n\n let user = auth.user ?? null;\n if (user === null || user.length === 0) {\n user = '';\n }\n\n let pass = auth.pass ?? null;\n if (pass === null || pass.length === 0) {\n pass = '';\n }\n\n return harValue('headers', {\n name: 'authorization',\n value: `Basic ${Buffer.from(`${user}:${pass}`).toString('base64')}`,\n });\n } else if (security.scheme === 'bearer') {\n return harValue('headers', {\n name: 'authorization',\n value: `Bearer ${values[scheme]}`,\n });\n }\n }\n\n if (security.type === 'apiKey') {\n if (security.in === 'query') {\n return harValue('queryString', {\n name: security.name,\n value: String(values[scheme]),\n });\n } else if (security.in === 'header') {\n const header = {\n name: security.name,\n value: String(values[scheme]),\n };\n\n if (security['x-bearer-format']) {\n // Uppercase: token -> Token\n const bearerFormat = security['x-bearer-format'].charAt(0).toUpperCase() + security['x-bearer-format'].slice(1);\n header.name = security.name;\n header.value = `${bearerFormat} ${header.value}`;\n }\n\n return harValue('headers', header);\n } else if (security.in === 'cookie') {\n return harValue('cookies', {\n name: security.name,\n value: String(values[scheme]),\n });\n }\n }\n\n if (security.type === 'oauth2') {\n return harValue('headers', {\n name: 'authorization',\n value: `Bearer ${values[scheme]}`,\n });\n }\n\n return undefined;\n}\n"],"mappings":";AAGA,SAAS,aAAa;AAEtB,SAAS,SACP,MACA,OACwD;AACxD,MAAI,CAAC,MAAM,MAAO,QAAO;AACzB,SAAO,EAAE,MAAM,MAAM;AACvB;AAEe,SAAR,kBACL,eACA,QACA,QACiD;AACjD,MAAI,CAAC,OAAQ,QAAO;AAEpB,MAAI,OAAO,KAAK,UAAU,CAAC,CAAC,EAAE,WAAW,EAAG,QAAO;AAEnD,MAAI,CAAC,cAAc,YAAY,kBAAkB,MAAM,EAAG,QAAO;AACjE,QAAM,WAAW,cAAc,WAAW,g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AAE,MAAM,CAAC;AAC9G,eAAO,OAAO,SAAS;AACvB,eAAO,QAAQ,GAAG,YAAY,IAAI,OAAO,KAAK;AAAA,MAChD;AAEA,aAAO,SAAS,WAAW,MAAM;AAAA,IACnC,WAAW,SAAS,OAAO,UAAU;AACnC,aAAO,SAAS,WAAW;AAAA,QACzB,MAAM,SAAS;AAAA,QACf,OAAO,OAAO,OAAO,MAAM,CAAC;AAAA,MAC9B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,SAAS,SAAS,UAAU;AAC9B,WAAO,SAAS,WAAW;AAAA,MACzB,MAAM;AAAA,MACN,OAAO,UAAU,OAAO,MAAM,CAAC;AAAA,IACjC,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNZMKP35Vcjs = require('./chunk-NZMKP35V.cjs');
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
var _dataurls = require('@readme/data-urls');
|
|
@@ -14,12 +14,12 @@ var _removeundefinedobjects = require('remove-undefined-objects'); var _removeun
|
|
|
14
14
|
function get(object, path) {
|
|
15
15
|
if (!path) return void 0;
|
|
16
16
|
const pathArray = String(path).match(/([^[.\]])+/g);
|
|
17
|
-
const result = _optionalChain([pathArray, 'optionalAccess', _ => _.reduce, 'call', _2 => _2((prevObj, key) => prevObj
|
|
17
|
+
const result = _optionalChain([pathArray, 'optionalAccess', _ => _.reduce, 'call', _2 => _2((prevObj, key) => _optionalChain([prevObj, 'optionalAccess', _3 => _3[key]]), object)]);
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
20
|
function set(object, path, value) {
|
|
21
21
|
const pathArray = Array.isArray(path) ? path : String(path).match(/([^[.\]])+/g);
|
|
22
|
-
return _optionalChain([pathArray, 'optionalAccess',
|
|
22
|
+
return _optionalChain([pathArray, 'optionalAccess', _4 => _4.reduce, 'call', _5 => _5((acc, key, i) => {
|
|
23
23
|
if (acc[key] === void 0) {
|
|
24
24
|
acc[key] = {};
|
|
25
25
|
}
|
|
@@ -375,7 +375,6 @@ function stylizeValue(value, parameter) {
|
|
|
375
375
|
}
|
|
376
376
|
function handleDeepObject(value, parameter) {
|
|
377
377
|
return _qs2.default.stringify(value, {
|
|
378
|
-
// eslint-disable-next-line consistent-return
|
|
379
378
|
encoder(str, defaultEncoder, charset, type) {
|
|
380
379
|
if (type === "key") {
|
|
381
380
|
const prefixedKey = str.split(/[[\]]/g).filter(Boolean).map((k) => `[${k}]`).join("");
|
|
@@ -394,7 +393,7 @@ function handleDeepObject(value, parameter) {
|
|
|
394
393
|
});
|
|
395
394
|
}
|
|
396
395
|
function handleExplode(value, parameter) {
|
|
397
|
-
if (Array.isArray(value) && _optionalChain([parameter, 'access',
|
|
396
|
+
if (Array.isArray(value) && _optionalChain([parameter, 'access', _6 => _6.schema, 'optionalAccess', _7 => _7.type]) === "array" && parameter.style === "deepObject") {
|
|
398
397
|
const newObj = {};
|
|
399
398
|
const deepObjs = handleDeepObject(value, parameter);
|
|
400
399
|
deepObjs.forEach((obj) => {
|
|
@@ -483,7 +482,7 @@ function getSubschemas(schema, opts) {
|
|
|
483
482
|
}
|
|
484
483
|
function getTypedFormatsInSchema(format, schema, opts) {
|
|
485
484
|
try {
|
|
486
|
-
if (_optionalChain([schema, 'optionalAccess',
|
|
485
|
+
if (_optionalChain([schema, 'optionalAccess', _8 => _8.format]) === format) {
|
|
487
486
|
if (opts.parentIsArray) {
|
|
488
487
|
const parentData = get(opts.payload, opts.parentKey || "");
|
|
489
488
|
if (parentData !== void 0 && Array.isArray(parentData)) {
|
|
@@ -506,11 +505,11 @@ function getTypedFormatsInSchema(format, schema, opts) {
|
|
|
506
505
|
if (!subschemas) {
|
|
507
506
|
return false;
|
|
508
507
|
}
|
|
509
|
-
return subschemas.
|
|
508
|
+
return subschemas.flatMap(({ key, schema: subschema }) => {
|
|
510
509
|
if ("properties" in subschema) {
|
|
511
510
|
return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });
|
|
512
511
|
} else if ("items" in subschema) {
|
|
513
|
-
if (_optionalChain([subschema, 'access',
|
|
512
|
+
if (_optionalChain([subschema, 'access', _9 => _9.items, 'optionalAccess', _10 => _10.properties])) {
|
|
514
513
|
return getTypedFormatsInSchema(format, subschema.items.properties, {
|
|
515
514
|
payload: opts.payload,
|
|
516
515
|
parentKey: key,
|
|
@@ -524,7 +523,7 @@ function getTypedFormatsInSchema(format, schema, opts) {
|
|
|
524
523
|
});
|
|
525
524
|
}
|
|
526
525
|
return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });
|
|
527
|
-
}).
|
|
526
|
+
}).filter(Boolean);
|
|
528
527
|
} catch (err) {
|
|
529
528
|
return [];
|
|
530
529
|
}
|
|
@@ -564,7 +563,7 @@ function multipartBodyToFormatterParams(payload, oasMediaTypeObject, schema) {
|
|
|
564
563
|
const encoding = oasMediaTypeObject.encoding;
|
|
565
564
|
if (typeof payload === "object" && payload !== null) {
|
|
566
565
|
return Object.keys(payload).map((key) => {
|
|
567
|
-
if (!_optionalChain([schema, 'access',
|
|
566
|
+
if (!_optionalChain([schema, 'access', _11 => _11.properties, 'optionalAccess', _12 => _12[key]])) {
|
|
568
567
|
return false;
|
|
569
568
|
}
|
|
570
569
|
const paramEncoding = encoding ? encoding[key] : void 0;
|
|
@@ -587,7 +586,7 @@ var defaultFormDataTypes = Object.keys(_utils.jsonSchemaTypes).reduce((prev, cur
|
|
|
587
586
|
}, {});
|
|
588
587
|
function getResponseContentType(content) {
|
|
589
588
|
const types = Object.keys(content) || [];
|
|
590
|
-
if (types
|
|
589
|
+
if (_optionalChain([types, 'optionalAccess', _13 => _13.length])) {
|
|
591
590
|
const jsonType = types.find((t) => _utils.matchesMimeType.json(t));
|
|
592
591
|
if (jsonType) {
|
|
593
592
|
return jsonType;
|
|
@@ -644,8 +643,8 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
644
643
|
if (!operationSchema || typeof operationSchema.getParameters !== "function") {
|
|
645
644
|
operation = new (0, _operation.Operation)(
|
|
646
645
|
oas,
|
|
647
|
-
_optionalChain([operationSchema, 'optionalAccess',
|
|
648
|
-
_optionalChain([operationSchema, 'optionalAccess',
|
|
646
|
+
_optionalChain([operationSchema, 'optionalAccess', _14 => _14.path]) || "",
|
|
647
|
+
_optionalChain([operationSchema, 'optionalAccess', _15 => _15.method]) || "",
|
|
649
648
|
operationSchema || { path: "", method: "" }
|
|
650
649
|
);
|
|
651
650
|
} else {
|
|
@@ -695,15 +694,15 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
695
694
|
}
|
|
696
695
|
return formatter(formData, parameter, "path");
|
|
697
696
|
});
|
|
698
|
-
const queryStrings = parameters
|
|
699
|
-
if (queryStrings
|
|
697
|
+
const queryStrings = _optionalChain([parameters, 'optionalAccess', _16 => _16.filter, 'call', _17 => _17((param) => param.in === "query")]);
|
|
698
|
+
if (_optionalChain([queryStrings, 'optionalAccess', _18 => _18.length])) {
|
|
700
699
|
queryStrings.forEach((queryString) => {
|
|
701
700
|
const value = formatter(formData, queryString, "query", true);
|
|
702
701
|
appendHarValue(har.queryString, queryString.name, value);
|
|
703
702
|
});
|
|
704
703
|
}
|
|
705
|
-
const cookies = parameters
|
|
706
|
-
if (cookies
|
|
704
|
+
const cookies = _optionalChain([parameters, 'optionalAccess', _19 => _19.filter, 'call', _20 => _20((param) => param.in === "cookie")]);
|
|
705
|
+
if (_optionalChain([cookies, 'optionalAccess', _21 => _21.length])) {
|
|
707
706
|
cookies.forEach((cookie) => {
|
|
708
707
|
const value = formatter(formData, cookie, "cookie", true);
|
|
709
708
|
appendHarValue(har.cookies, cookie.name, value);
|
|
@@ -711,8 +710,8 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
711
710
|
}
|
|
712
711
|
if (operation.schema.responses) {
|
|
713
712
|
Object.keys(operation.schema.responses).some((response) => {
|
|
714
|
-
if (_types.isRef.call(void 0, _optionalChain([operation, 'access',
|
|
715
|
-
const content = (_optionalChain([operation, 'access',
|
|
713
|
+
if (_types.isRef.call(void 0, _optionalChain([operation, 'access', _22 => _22.schema, 'access', _23 => _23.responses, 'optionalAccess', _24 => _24[response]]))) return false;
|
|
714
|
+
const content = (_optionalChain([operation, 'access', _25 => _25.schema, 'access', _26 => _26.responses, 'optionalAccess', _27 => _27[response]])).content;
|
|
716
715
|
if (!content) return false;
|
|
717
716
|
if (Object.keys(formData.header || {}).find((h) => h.toLowerCase() === "accept")) return true;
|
|
718
717
|
har.headers.push({
|
|
@@ -724,8 +723,8 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
724
723
|
}
|
|
725
724
|
let hasContentType = false;
|
|
726
725
|
let contentType = operation.getContentType();
|
|
727
|
-
const headers = parameters
|
|
728
|
-
if (headers
|
|
726
|
+
const headers = _optionalChain([parameters, 'optionalAccess', _28 => _28.filter, 'call', _29 => _29((param) => param.in === "header")]);
|
|
727
|
+
if (_optionalChain([headers, 'optionalAccess', _30 => _30.length])) {
|
|
729
728
|
headers.forEach((header) => {
|
|
730
729
|
const value = formatter(formData, header, "header", true);
|
|
731
730
|
if (typeof value === "undefined") return;
|
|
@@ -771,7 +770,7 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
771
770
|
return payload.type === (operation.isFormUrlEncoded() ? "formData" : "body");
|
|
772
771
|
});
|
|
773
772
|
}
|
|
774
|
-
if (requestBody
|
|
773
|
+
if (_optionalChain([requestBody, 'optionalAccess', _31 => _31.schema]) && Object.keys(requestBody.schema).length) {
|
|
775
774
|
const requestBodySchema = requestBody.schema;
|
|
776
775
|
if (operation.isFormUrlEncoded()) {
|
|
777
776
|
if (Object.keys(formData.formData || {}).length) {
|
|
@@ -830,7 +829,7 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
830
829
|
}
|
|
831
830
|
}
|
|
832
831
|
}
|
|
833
|
-
appendHarValue(_optionalChain([har, 'access',
|
|
832
|
+
appendHarValue(_optionalChain([har, 'access', _32 => _32.postData, 'optionalAccess', _33 => _33.params]) || [], name, val, addtlData);
|
|
834
833
|
});
|
|
835
834
|
}
|
|
836
835
|
});
|
|
@@ -870,17 +869,17 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
870
869
|
}
|
|
871
870
|
}
|
|
872
871
|
}
|
|
873
|
-
if ((_optionalChain([har, 'access',
|
|
872
|
+
if ((_optionalChain([har, 'access', _34 => _34.postData, 'optionalAccess', _35 => _35.text]) || _optionalChain([requestBody, 'optionalAccess', _36 => _36.schema]) && Object.keys(requestBody.schema).length) && !hasContentType) {
|
|
874
873
|
har.headers.push({
|
|
875
874
|
name: "content-type",
|
|
876
875
|
value: contentType
|
|
877
876
|
});
|
|
878
877
|
}
|
|
879
878
|
const securityRequirements = operation.getSecurity();
|
|
880
|
-
if (securityRequirements
|
|
879
|
+
if (_optionalChain([securityRequirements, 'optionalAccess', _37 => _37.length])) {
|
|
881
880
|
securityRequirements.forEach((schemes) => {
|
|
882
881
|
Object.keys(schemes).forEach((security) => {
|
|
883
|
-
const securityValue =
|
|
882
|
+
const securityValue = _chunkNZMKP35Vcjs.configureSecurity.call(void 0, apiDefinition, auth, security);
|
|
884
883
|
if (!securityValue) {
|
|
885
884
|
return;
|
|
886
885
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","../src/index.ts","../src/lib/lodash.ts","../src/lib/style-formatting/index.ts","../src/lib/style-formatting/style-serializer.ts","../src/lib/utils.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAAA;AACA;AACA;ACcA,6CAAsC;AACtC,4CAAuC;AACvC,0CAA0B;AAC1B,kCAAsB;AACtB,kCAAiD;AACjD,kJAAmC;ADZnC;AACA;AEHO,SAAS,GAAA,CAAI,MAAA,EAAiB,IAAA,EAAoB;AAEvD,EAAA,GAAA,CAAI,CAAC,IAAA,EAAM,OAAO,KAAA,CAAA;AAGlB,EAAA,MAAM,UAAA,EAAY,MAAA,CAAO,IAAI,CAAA,CAAE,KAAA,CAAM,aAAa,CAAA;AAGlD,EAAA,MAAM,OAAA,kBAAS,SAAA,2BAAW,MAAA,mBAAO,CAAC,OAAA,EAAS,GAAA,EAAA,GAAQ,QAAA,GAAW,OAAA,CAAQ,GAAG,CAAA,EAAG,MAAM,GAAA;AAElF,EAAA,OAAO,MAAA;AACT;AAOO,SAAS,GAAA,CAAa,MAAA,EAAgB,IAAA,EAAoB,KAAA,EAAqB;AAEpF,EAAA,MAAM,UAAA,EAAoD,KAAA,CAAM,OAAA,CAAQ,IAAI,EAAA,EACxE,KAAA,EACA,MAAA,CAAO,IAAI,CAAA,CAAE,KAAA,CAAM,aAAa,CAAA;AAGpC,EAAA,uBAAO,SAAA,6BAAW,MAAA,mBAAO,CAAC,GAAA,EAAK,GAAA,EAAK,CAAA,EAAA,GAAM;AAExC,IAAA,GAAA,CAAI,GAAA,CAAI,GAAG,EAAA,IAAM,KAAA,CAAA,EAAW;AAE1B,MAAA,GAAA,CAAI,GAAG,EAAA,EAAI,CAAC,CAAA;AAAA,IACd;AACA,IAA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;AACA,IAAA;AACM,MAAA;AACP,QAAA;AACW,UAAA;AACX,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACF;ADgRuG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","sourcesContent":[null,"import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\nimport type { PostData, PostDataParams, Request } from 'har-format';\nimport type Oas from 'oas';\nimport type { Extensions } from 'oas/extensions';\nimport type { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n ServerVariable,\n} from 'oas/types';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport { HEADERS, PROXY_ENABLED } from 'oas/extensions';\nimport { Operation } from 'oas/operation';\nimport { isRef } from 'oas/types';\nimport { jsonSchemaTypes, matchesMimeType } from 'oas/utils';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport configureSecurity from './lib/configure-security.js';\nimport { get, set } from './lib/lodash.js';\nimport formatStyle from './lib/style-formatting/index.js';\nimport { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils.js';\n\nfunction formatter(\n values: DataForHAR,\n param: ParameterObject,\n type: 'body' | 'cookie' | 'header' | 'path' | 'query',\n onlyIfExists = false,\n) {\n if (param.style) {\n const value = values[type][param.name];\n // Note: Technically we could send everything through the format style and choose the proper\n // default for each `in` type (e.g. query defaults to form).\n return formatStyle(value, param);\n }\n\n let value;\n\n // Handle missing values\n if (typeof values[type][param.name] !== 'undefined') {\n value = values[type][param.name];\n } else if (onlyIfExists && !param.required) {\n value = undefined;\n } else if (param.required && param.schema && !isRef(param.schema) && param.schema.default) {\n value = param.schema.default;\n } else if (type === 'path') {\n // If we don't have any values for the path parameter, just use the name of the parameter as the\n // value so we don't try try to build a URL to something like `https://example.com/undefined`.\n return param.name;\n }\n\n // Handle file uploads. Specifically arrays of file uploads which need to be formatted very\n // specifically.\n if (\n param.schema &&\n !isRef(param.schema) &&\n param.schema.type === 'array' &&\n param.schema.items &&\n !isRef(param.schema.items) &&\n param.schema.items.format === 'binary'\n ) {\n if (Array.isArray(value)) {\n // If this is array of binary data then we shouldn't do anything because we'll prepare them\n // separately in the HAR in order to preserve `fileName` and `contentType` data within\n // `postData.params`. If we don't then the HAR we generate for this data will be invalid.\n return value;\n }\n\n return JSON.stringify(value);\n }\n\n if (value !== undefined) {\n // Query params should always be formatted, even if they don't have a `style` serialization\n // configured.\n if (type === 'query') {\n return formatStyle(value, param);\n }\n\n return value;\n }\n\n return undefined;\n}\n\nfunction multipartBodyToFormatterParams(payload: unknown, oasMediaTypeObject: MediaTypeObject, schema: SchemaObject) {\n const encoding = oasMediaTypeObject.encoding;\n\n if (typeof payload === 'object' && payload !== null) {\n return Object.keys(payload)\n .map(key => {\n // If we have an incoming parameter, but it's not in the schema ignore it.\n if (!schema.properties?.[key]) {\n return false;\n }\n\n const paramEncoding = encoding ? encoding[key] : undefined;\n\n return {\n name: key,\n // If the style isn't defined, use the default\n style: paramEncoding ? paramEncoding.style : undefined,\n // If explode isn't defined, use the default\n explode: paramEncoding ? paramEncoding.explode : undefined,\n required:\n (schema.required && typeof schema.required === 'boolean' && Boolean(schema.required)) ||\n (Array.isArray(schema.required) && schema.required.includes(key)),\n schema: schema.properties[key],\n in: 'body',\n };\n })\n .filter(Boolean) as ParameterObject[];\n }\n\n // Pretty sure that we'll never have anything but an object for multipart bodies, so returning\n // empty array if we get anything else.\n return [];\n}\n\nconst defaultFormDataTypes = Object.keys(jsonSchemaTypes).reduce((prev, curr) => {\n return Object.assign(prev, { [curr]: {} });\n}, {});\n\nfunction getResponseContentType(content: MediaTypeObject) {\n const types = Object.keys(content) || [];\n\n // If this response content has multiple types available we should always prefer the one that's\n // JSON-compatible. If they don't have one that is we'll return the first available, otherwise\n // if they don't have **any** repsonse content types present we'll assume it's JSON.\n if (types && types.length) {\n const jsonType = types.find(t => matchesMimeType.json(t));\n if (jsonType) {\n return jsonType;\n }\n\n return types[0];\n }\n\n return 'application/json';\n}\n\nfunction isPrimitive(val: unknown) {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n\nfunction stringify(json: Record<string | 'RAW_BODY', unknown>) {\n return JSON.stringify(removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json));\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return param;\n } else if (Array.isArray(param) && param.every(isPrimitive)) {\n return String(param);\n }\n\n return JSON.stringify(param);\n}\n\nfunction appendHarValue(\n harParam: PostDataParams['params'] | Request['cookies'] | Request['headers'] | Request['queryString'],\n name: string,\n value: any,\n addtlData: {\n contentType?: string;\n fileName?: string;\n } = {},\n) {\n if (typeof value === 'undefined') return;\n\n if (Array.isArray(value)) {\n // If the formatter gives us an array, we're expected to add each array value as a new\n // parameter item with the same parameter name\n value.forEach(singleValue => {\n appendHarValue(harParam, name, singleValue);\n });\n } else if (typeof value === 'object' && value !== null) {\n // If the formatter gives us an object, we're expected to add each property value as a new\n // parameter item, each with the name of the property\n Object.keys(value).forEach(key => {\n appendHarValue(harParam, key, value[key]);\n });\n } else {\n // If the formatter gives us a non-array, non-object, we add it as is\n harParam.push({\n ...addtlData,\n name,\n value: String(value),\n });\n }\n}\n\nfunction encodeBodyForHAR(body: any) {\n if (isPrimitive(body)) {\n return body;\n } else if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n typeof body.RAW_BODY !== 'undefined'\n ) {\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload as a\n // raw string. https://docs.readme.com/docs/raw-body-content\n if (isPrimitive(body.RAW_BODY)) {\n return body.RAW_BODY;\n }\n\n return stringify(body.RAW_BODY);\n }\n\n return stringify(body);\n}\n\nexport default function oasToHar(\n oas: Oas,\n operationSchema?: Operation,\n values: DataForHAR = {},\n auth: AuthForHAR = {},\n opts: oasToHarOptions = { proxyUrl: '' },\n): {\n log: {\n entries: readonly [\n {\n readonly request: Request;\n },\n ];\n };\n} {\n let operation: Operation;\n if (!operationSchema || typeof operationSchema.getParameters !== 'function') {\n /**\n * If `operationSchema` was supplied as a plain object instead of an instance of `Operation`\n * then we should create a new instance of it. We're doing it with a check on `getParameters`\n * instead of checking `instanceof Operation` because JS is very weird when it comes to\n * checking `instanceof` against classes. One instance of `Operation` may not always match up\n * with another if they're being loaded between two different libraries.\n *\n * It's weird. This is easier.\n */\n operation = new Operation(\n oas as unknown as OASDocument,\n operationSchema?.path || '',\n operationSchema?.method || ('' as HttpMethods),\n (operationSchema as unknown as OperationObject) || { path: '', method: '' },\n );\n } else {\n operation = operationSchema;\n }\n\n const apiDefinition = oas.getDefinition();\n\n const formData: DataForHAR = {\n ...defaultFormDataTypes,\n ...values,\n };\n\n if (!formData.server) {\n formData.server = {\n selected: 0,\n variables: oas.defaultVariables(0),\n };\n }\n\n // If the incoming `server.variables` is missing variables let's pad it out with defaults.\n formData.server.variables = {\n ...oas.defaultVariables(formData.server.selected),\n ...(formData.server.variables ? formData.server.variables : {}),\n };\n\n const har: Request = {\n cookies: [],\n headers: [],\n headersSize: 0,\n queryString: [],\n // @ts-expect-error This is fine because we're fleshing `postData` out further down.\n postData: {},\n bodySize: 0,\n method: operation.method.toUpperCase(),\n url: `${oas.url(formData.server.selected, formData.server.variables as ServerVariable)}${operation.path}`.replace(\n /\\s/g,\n '%20',\n ),\n httpVersion: 'HTTP/1.1',\n };\n\n if (opts.proxyUrl) {\n if (oas.getExtension(PROXY_ENABLED, operation)) {\n har.url = `${opts.proxyUrl}/${har.url}`;\n }\n }\n\n const parameters = operation.getParameters();\n\n har.url = har.url.replace(/{([-_a-zA-Z0-9[\\]]+)}/g, (full, key) => {\n if (!operation || !parameters) return key; // No path params at all\n\n // Find the path parameter or set a default value if it does not exist\n const parameter = parameters.find(param => param.name === key) || ({ name: key } as ParameterObject);\n\n // The library that handles our style processing already encodes uri elements. For everything\n // else we need to handle it here.\n if (!('style' in parameter) || !parameter.style) {\n return encodeURIComponent(formatter(formData, parameter, 'path'));\n }\n\n return formatter(formData, parameter, 'path');\n });\n\n const queryStrings = parameters && parameters.filter(param => param.in === 'query');\n if (queryStrings && queryStrings.length) {\n queryStrings.forEach(queryString => {\n const value = formatter(formData, queryString, 'query', true);\n appendHarValue(har.queryString, queryString.name, value);\n });\n }\n\n // Do we have any `cookie` parameters on the operation?\n const cookies = parameters && parameters.filter(param => param.in === 'cookie');\n if (cookies && cookies.length) {\n cookies.forEach(cookie => {\n const value = formatter(formData, cookie, 'cookie', true);\n appendHarValue(har.cookies, cookie.name, value);\n });\n }\n\n // Does this response have any documented content types?\n if (operation.schema.responses) {\n Object.keys(operation.schema.responses).some(response => {\n if (isRef(operation.schema.responses?.[response])) return false;\n\n const content = (operation.schema.responses?.[response] as ResponseObject).content;\n if (!content) return false;\n\n // If there's no `accept` header present we should add one so their eventual code snippet\n // follows best practices.\n if (Object.keys(formData.header || {}).find(h => h.toLowerCase() === 'accept')) return true;\n\n har.headers.push({\n name: 'accept',\n value: getResponseContentType(content),\n });\n\n return true;\n });\n }\n\n // Do we have any `header` parameters on the operation?\n let hasContentType = false;\n let contentType = operation.getContentType();\n const headers = parameters && parameters.filter(param => param.in === 'header');\n if (headers && headers.length) {\n headers.forEach(header => {\n const value = formatter(formData, header, 'header', true);\n if (typeof value === 'undefined') return;\n\n if (header.name.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(value);\n }\n\n appendHarValue(har.headers, header.name, value);\n });\n }\n\n // Are there `x-headers` static headers configured for this OAS?\n const userDefinedHeaders = oas.getExtension(HEADERS, operation) as Extensions['headers'];\n if (userDefinedHeaders) {\n userDefinedHeaders.forEach(header => {\n if (typeof header.key === 'string' && header.key.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(header.value);\n }\n\n har.headers.push({\n name: String(header.key),\n value: String(header.value),\n });\n });\n }\n\n if (formData.header) {\n // Do we have an `accept` header set up in the form data, but it hasn't been added yet?\n const acceptHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'accept');\n if (acceptHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'accept')) {\n har.headers.push({\n name: 'accept',\n value: String(formData.header[acceptHeader]),\n });\n }\n\n // Do we have a manually-defined `authorization` header set up in the form data?\n const authorizationHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'authorization');\n if (authorizationHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'authorization')) {\n har.headers.push({\n name: 'authorization',\n value: String(formData.header[authorizationHeader]),\n });\n }\n }\n\n let requestBody: SchemaWrapper | undefined;\n if (operation.hasRequestBody()) {\n requestBody = operation.getParametersAsJSONSchema().find(payload => {\n // `formData` is used in our API Explorer for `application/x-www-form-urlencoded` endpoints\n // and if you have an operation with that, it will only ever have a `formData`. `body` is\n // used for all other payload shapes.\n return payload.type === (operation.isFormUrlEncoded() ? 'formData' : 'body');\n });\n }\n\n if (requestBody && requestBody.schema && Object.keys(requestBody.schema).length) {\n const requestBodySchema = requestBody.schema as SchemaObject;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n // eslint-disable-next-line try-catch-failsafe/json-parse\n const cleanFormData = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.formData)));\n if (cleanFormData !== undefined) {\n const postData: PostData = { params: [], mimeType: 'application/x-www-form-urlencoded' };\n\n Object.keys(cleanFormData).forEach(name => {\n postData.params.push({\n name,\n value: stringifyParameter(cleanFormData[name]),\n });\n });\n\n har.postData = postData;\n }\n }\n } else if (\n 'body' in formData &&\n formData.body !== undefined &&\n (isPrimitive(formData.body) || Object.keys(formData.body).length)\n ) {\n const isMultipart = operation.isMultipart();\n const isJSON = operation.isJson();\n\n if (isMultipart || isJSON) {\n try {\n let cleanBody = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.body)));\n\n if (isMultipart) {\n har.postData = { params: [], mimeType: 'multipart/form-data' };\n\n // Because some request body schema shapes might not always be a top-level `properties`,\n // instead nesting it in an `oneOf` or `anyOf` we need to extract the first usable\n // schema that we have in order to process this multipart payload.\n const safeBodySchema = getSafeRequestBody(requestBodySchema);\n\n /**\n * Discover all `{ type: string, format: binary }` properties, or arrays containing the\n * same, within the request body. If there are any, then that means that we're dealing\n * with a `multipart/form-data` request and need to treat the payload as\n * `postData.params` and supply filenames and content types for the files (if they're\n * available).\n *\n * @todo It'd be nice to replace this with `getTypedFormatsInSchema` instead.\n * @example `{ type: string, format: binary }`\n * @example `{ type: array, items: { type: string, format: binary } }`\n */\n const binaryTypes = Object.keys(safeBodySchema.properties).filter(key => {\n const propData = safeBodySchema.properties[key] as JSONSchema;\n if (propData.format === 'binary') {\n return true;\n } else if (\n propData.type === 'array' &&\n propData.items &&\n typeof propData.items === 'object' &&\n propData.items !== null &&\n (propData.items as JSONSchema).format === 'binary'\n ) {\n return true;\n }\n\n return false;\n });\n\n if (cleanBody !== undefined) {\n const multipartParams = multipartBodyToFormatterParams(\n formData.body,\n (operation.schema.requestBody as RequestBodyObject).content['multipart/form-data'],\n safeBodySchema,\n );\n\n if (multipartParams.length) {\n Object.keys(cleanBody).forEach(name => {\n const param = multipartParams.find(multipartParam => multipartParam.name === name);\n\n if (param) {\n // If we're dealing with a binary type, and the value is a valid data URL we should\n // parse out any available filename and content type to send along with the\n // parameter to interpreters like `fetch-har` can make sense of it and send a usable\n // payload.\n const addtlData: { contentType?: string; fileName?: string } = {};\n\n let value = formatter(formData, param, 'body', true);\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n value.forEach((val: string) => {\n if (binaryTypes.includes(name)) {\n const parsed = parseDataUrl(val);\n if (parsed) {\n addtlData.fileName = 'name' in parsed ? parsed.name : 'unknown';\n if ('contentType' in parsed) {\n addtlData.contentType = parsed.contentType;\n }\n }\n }\n\n appendHarValue(har.postData?.params || [], name, val, addtlData);\n });\n }\n });\n }\n }\n } else {\n har.postData = { mimeType: contentType, text: '' };\n\n if (\n hasSchemaType(requestBody.schema, 'string') ||\n hasSchemaType(requestBody.schema, 'integer') ||\n hasSchemaType(requestBody.schema, 'number') ||\n hasSchemaType(requestBody.schema, 'boolean')\n ) {\n har.postData.text = JSON.stringify(JSON.parse(cleanBody));\n } else {\n /**\n * Handle formatted JSON objects that have properties that accept arbitrary JSON.\n *\n * Find all `{ type: string, format: json }` properties in the schema because we need\n * to manually `JSON.parse` them before submit, otherwise they'll be escaped instead\n * of actual objects. We also only want values that the user has entered, so we drop\n * any `undefined` `cleanBody` keys.\n */\n const jsonTypes = getTypedFormatsInSchema('json', requestBodySchema.properties, { payload: cleanBody });\n\n if (Array.isArray(jsonTypes) && jsonTypes.length) {\n try {\n jsonTypes.forEach((prop: boolean | string) => {\n try {\n set(cleanBody, String(prop), JSON.parse(get(cleanBody, String(prop))));\n } catch (e) {\n // leave the prop as a string value\n }\n });\n\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload\n // as a raw string. https://docs.readme.com/docs/raw-body-content\n if (typeof cleanBody.RAW_BODY !== 'undefined') {\n cleanBody = cleanBody.RAW_BODY;\n }\n\n har.postData.text = JSON.stringify(cleanBody);\n } catch (e) {\n har.postData.text = stringify(formData.body);\n }\n } else {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n } catch (e) {\n // If anything above fails for whatever reason, assume that whatever we had is invalid\n // JSON and just treat it as raw text.\n har.postData = { mimeType: contentType, text: stringify(formData.body) };\n }\n } else {\n har.postData = { mimeType: contentType, text: encodeBodyForHAR(formData.body) };\n }\n }\n }\n\n // Add a `content-type` header if there are any body values setup above or if there is a schema\n // defined, but only do so if we don't already have a `content-type` present as it's impossible\n // for a request to have multiple.\n if (\n (har.postData?.text || (requestBody && requestBody.schema && Object.keys(requestBody.schema).length)) &&\n !hasContentType\n ) {\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\n const securityRequirements = operation.getSecurity();\n\n if (securityRequirements && securityRequirements.length) {\n // TODO pass these values through the formatter?\n securityRequirements.forEach(schemes => {\n Object.keys(schemes).forEach(security => {\n const securityValue = configureSecurity(apiDefinition, auth, security);\n if (!securityValue) {\n return;\n }\n\n // If this is an `authorization` header and we've already added one (maybe one was manually\n // specified), then we shouldn't add another.\n if (securityValue.value.name === 'authorization') {\n if (har[securityValue.type].find(v => v.name === securityValue.value.name)) {\n return;\n }\n }\n\n // If we've already added this **specific** security value then don't add it again.\n if (\n har[securityValue.type].find(\n v => v.name === securityValue.value.name && v.value === securityValue.value.value,\n )\n ) {\n return;\n }\n\n har[securityValue.type].push(securityValue.value);\n });\n });\n }\n\n // If we didn't end up filling the `postData` object then we don't need it.\n if (Object.keys(har.postData || {}).length === 0) {\n delete har.postData;\n }\n\n return {\n log: {\n entries: [\n {\n request: har,\n },\n ] as const,\n },\n };\n}\n","type Many<T> = T | readonly T[];\ntype PropertyName = number | string | symbol;\ntype PropertyPath = Many<PropertyName>;\n\n/**\n * A janky, poorly typed replacement for `lodash.get`.\n *\n * @see {@link https://youmightnotneed.com/lodash#get}\n */\nexport function get(object: unknown, path?: string): any {\n // If path is not defined or it has false value\n if (!path) return undefined;\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n // Regex explained: https://regexr.com/58j0k\n const pathArray = String(path).match(/([^[.\\]])+/g);\n // Find value\n // @ts-expect-error idk man\n const result = pathArray?.reduce((prevObj, key) => prevObj && prevObj[key], object);\n // If found value is undefined return default value; otherwise return the value\n return result;\n}\n\n/**\n * A janky, poorly typed replacement for `lodash.set`.\n *\n * @see {@link https://youmightnotneed.com/lodash#set}\n */\nexport function set<TResult>(object: object, path: PropertyPath, value: any): TResult {\n // Regex explained: https://regexr.com/58j0k\n const pathArray: PropertyPath | RegExpMatchArray | null = Array.isArray(path)\n ? path\n : String(path).match(/([^[.\\]])+/g);\n\n // @ts-expect-error idk man\n return pathArray?.reduce((acc, key, i) => {\n // @ts-expect-error idk man\n if (acc[key] === undefined) {\n // @ts-expect-error idk man\n acc[key] = {};\n }\n if (i === pathArray.length - 1) {\n // @ts-expect-error idk man\n acc[key] = value;\n }\n // @ts-expect-error idk man\n return acc[key];\n }, object);\n}\n","import type { StylizerConfig } from './style-serializer.js';\nimport type { ParameterObject, SchemaObject } from 'oas/types';\n\nimport qs from 'qs';\n\nimport { stylize } from './style-serializer.js';\n\n// Certain styles don't support empty values.\nfunction shouldNotStyleEmptyValues(parameter: ParameterObject) {\n return ['simple', 'spaceDelimited', 'pipeDelimited', 'deepObject'].includes(parameter.style || '');\n}\n\nfunction shouldNotStyleReservedHeader(parameter: ParameterObject) {\n return ['accept', 'authorization', 'content-type'].includes(parameter.name.toLowerCase());\n}\n\n/**\n * Note: This isn't necessarily part of the spec. Behavior for the value 'undefined' is, well,\n * undefined. This code makes our system look better. If we wanted to be more accurate, we might\n * want to remove this, restore the un-fixed behavior for undefined and have our UI pass in empty\n * string instead of undefined.\n */\nfunction removeUndefinedForPath(value: any) {\n let finalValue = value;\n\n if (typeof finalValue === 'undefined') {\n return '';\n }\n\n if (Array.isArray(finalValue)) {\n finalValue = finalValue.filter(val => (val === undefined ? '' : val));\n\n if (finalValue.length === 0) {\n finalValue = '';\n }\n }\n\n if (typeof finalValue === 'object') {\n Object.keys(finalValue).forEach(key => {\n finalValue[key] = finalValue[key] === undefined ? '' : finalValue[key];\n });\n }\n\n return finalValue;\n}\n\nfunction stylizeValue(value: unknown, parameter: ParameterObject) {\n let finalValue = value;\n\n // Some styles don't work with empty values. We catch those there\n if (shouldNotStyleEmptyValues(parameter) && (typeof finalValue === 'undefined' || finalValue === '')) {\n // Paths need return an unstyled empty string instead of undefined so it's ignored in the final\n // path string.\n if (parameter.in === 'path') {\n return '';\n }\n\n // Everything but path should return undefined when unstyled so it's ignored in the final\n // parameter array.\n return undefined;\n }\n\n // Every style that adds their style to empty values should use emptystring for path parameters\n // instead of undefined to avoid the string `undefined`.\n if (parameter.in === 'path') {\n finalValue = removeUndefinedForPath(finalValue);\n }\n\n /**\n * Eventhough `accept`, `authorization`, and `content-type` headers can be defined as parameters,\n * they should be completely ignored when it comes to serialization.\n *\n * > If `in` is \"header\" and the `name` field is \"Accept\", \"Content-Type\" or \"Authorization\", the\n * > parameter definition SHALL be ignored.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10}\n */\n if (parameter.in === 'header' && shouldNotStyleReservedHeader(parameter)) {\n return value;\n }\n\n /**\n * All parameter types have a default `style` format so if they don't have one prescribed we\n * should still conform to what the spec defines.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterstyle}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterstyle}\n */\n let style = parameter.style;\n if (!style) {\n if (parameter.in === 'query') {\n style = 'form';\n } else if (parameter.in === 'path') {\n style = 'simple';\n } else if (parameter.in === 'header') {\n style = 'simple';\n } else if (parameter.in === 'cookie') {\n style = 'form';\n }\n }\n\n let explode = parameter.explode;\n if (explode === undefined && style === 'form') {\n /**\n * Per the spec if no `explode` is present but `style` is `form` then `explode` should default to `true`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterexplode}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterexplode}\n */\n explode = true;\n }\n\n return stylize({\n location: parameter.in as StylizerConfig['location'],\n value: finalValue,\n key: parameter.name,\n style: style as StylizerConfig['style'],\n explode,\n /**\n * @todo this parameter is optional to stylize. It defaults to false, and can accept falsy, truthy, or \"unsafe\".\n * I do not know if it is correct for query to use this. See style-serializer for more info\n */\n escape: true,\n ...(parameter.in === 'query' ? { isAllowedReserved: parameter.allowReserved || false } : {}),\n });\n}\n\nfunction handleDeepObject(value: any, parameter: ParameterObject) {\n return qs\n .stringify(value, {\n // eslint-disable-next-line consistent-return\n encoder(str, defaultEncoder, charset, type) {\n if (type === 'key') {\n // `str` will be here as `dog[treats][0]` but because the `qs` library doesn't have any\n // awareness of our OpenAPI parameters we need to rewrite it to slap the `parameter.name`\n // to the top, like `pets[dog][treats][0]`.\n const prefixedKey = str\n .split(/[[\\]]/g)\n .filter(Boolean)\n .map((k: string) => `[${k}]`)\n .join('');\n\n return `${parameter.name}${prefixedKey}`;\n } else if (type === 'value') {\n return stylizeValue(str, parameter);\n }\n },\n })\n .split('&')\n .map(item => {\n const split = item.split('=');\n return {\n label: split[0],\n // `qs` will coerce null values into being `undefined` string but we want to preserve them.\n value: split[1] === 'undefined' ? null : split[1],\n };\n });\n}\n\n// Explode is handled on its own, because style-serializer doesn't return what we expect for proper\n// HAR output.\nfunction handleExplode(value: any, parameter: ParameterObject) {\n // This is to handle the case of arrays of objects in the querystring\n // which is something that's not technically in the spec but since we're\n // using the `qs` module already, it's fairly easy for us to add support\n // for this use case.\n //\n // An example URL would be something like this:\n // https://example.com/?line_items[0][a_string]=abc&line_items[0][quantity]=1&line_items[1][a_string]=def&line_items[1][quantity]=2\n //\n // Some open issues discussing this here:\n // https://github.com/OAI/OpenAPI-Specification/issues/1706\n // https://github.com/OAI/OpenAPI-Specification/issues/1006\n //\n // Link to the spec for this:\n // https://github.com/OAI/OpenAPI-Specification/blob/36a3a67264cc1c4f1eff110cea3ebfe679435108/versions/3.1.0.md#style-examples\n if (\n Array.isArray(value) &&\n (parameter.schema as SchemaObject)?.type === 'array' &&\n parameter.style === 'deepObject'\n ) {\n const newObj: Record<string, unknown> = {};\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n return newObj;\n }\n\n if (Array.isArray(value)) {\n return value.map(val => {\n return stylizeValue(val, parameter);\n });\n }\n\n if (typeof value === 'object' && value !== null) {\n const newObj: Record<string, unknown> = {};\n\n Object.keys(value).forEach(key => {\n if (parameter.style === 'deepObject') {\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n } else {\n newObj[key] = stylizeValue(value[key], parameter);\n }\n });\n\n return newObj;\n }\n\n return stylizeValue(value, parameter);\n}\n\nfunction shouldExplode(parameter: ParameterObject) {\n return (\n (parameter.explode ||\n (parameter.explode !== false && parameter.style === 'form') ||\n // style: deepObject && explode: false doesn't exist so explode it always\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples\n parameter.style === 'deepObject') &&\n // header and path doesn't explode into separate parameters like query and cookie do\n parameter.in !== 'header' &&\n parameter.in !== 'path'\n );\n}\n\nexport default function formatStyle(value: unknown, parameter: ParameterObject): any {\n // Deep object style only works on objects and arrays, and only works with explode=true.\n if (parameter.style === 'deepObject' && (!value || typeof value !== 'object' || parameter.explode === false)) {\n return undefined;\n }\n\n // This custom explode logic allows us to bubble up arrays and objects to be handled differently\n // by our HAR transformer. We need this because the `stylizeValue` function assumes we're building\n // strings, not richer data types.\n //\n // The first part of this conditional checks if `explode` is enabled. Explode is disabled for\n // everything by default except for forms.\n //\n // The second part of this conditional bypasses the custom explode logic for headers, because they\n // work differently, and `stylizeValue` is accurate.\n if (shouldExplode(parameter)) {\n return handleExplode(value, parameter);\n }\n\n return stylizeValue(value, parameter);\n}\n","/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable no-param-reassign */\n\n/**\n * This file has been extracted and modified from `swagger-client`.\n *\n * @license Apache 2.0\n * @link https://npm.im/swagger-client\n * @link https://github.com/swagger-api/swagger-js/blob/master/src/execute/oas3/style-serializer.js\n */\n\nconst isRfc3986Reserved = (char: string) => \":/?#[]@!$&'()*+,;=\".indexOf(char) > -1;\nconst isRfc3986Unreserved = (char: string) => /^[a-z0-9\\-._~]+$/i.test(char);\n\nfunction isURIEncoded(value: string) {\n try {\n return decodeURIComponent(value) !== value;\n } catch (err) {\n // `decodeURIComponent` will throw an exception if a string that has an un-encoded percent sign\n // in it (like 20%), o if it's throwing we can just assume that the value hasn't been encoded.\n return false;\n }\n}\n\nfunction isObject(value: unknown) {\n return typeof value === 'object' && value !== null;\n}\n\nfunction encodeDisallowedCharacters(\n str: string,\n {\n escape,\n returnIfEncoded = false,\n isAllowedReserved,\n }: {\n escape?: boolean | 'unsafe';\n isAllowedReserved?: boolean;\n returnIfEncoded?: boolean;\n } = {},\n parse?: boolean,\n): any {\n if (typeof str === 'number') {\n str = (str as number).toString();\n }\n\n if (returnIfEncoded) {\n if (isURIEncoded(str)) {\n return str;\n }\n }\n\n if (typeof str !== 'string' || !str.length) {\n return str;\n }\n\n if (!escape) {\n return str;\n }\n\n if (parse) {\n // eslint-disable-next-line try-catch-failsafe/json-parse\n return JSON.parse(str);\n }\n\n // In ES6 you can do this quite easily by using the new ... spread operator. This causes the\n // string iterator (another new ES6 feature) to be used internally, and because that iterator is\n // designed to deal with code points rather than UCS-2/UTF-16 code units.\n return [...str]\n .map(char => {\n if (isRfc3986Unreserved(char)) {\n return char;\n }\n\n if (isRfc3986Reserved(char) && (escape === 'unsafe' || isAllowedReserved)) {\n return char;\n }\n\n const encoder = new TextEncoder();\n const encoded = Array.from(encoder.encode(char))\n .map(byte => `0${byte.toString(16).toUpperCase()}`.slice(-2))\n .map(encodedByte => `%${encodedByte}`)\n .join('');\n\n return encoded;\n })\n .join('');\n}\n\nexport interface StylizerConfig {\n escape: boolean | 'unsafe';\n explode?: boolean;\n isAllowedReserved?: boolean;\n key: string;\n location: 'body' | 'query';\n style: 'deepObject' | 'form' | 'label' | 'matrix' | 'pipeDelimited' | 'simple' | 'spaceDelimited';\n value: any;\n}\n\nexport function stylize(config: StylizerConfig): any {\n const { value } = config;\n\n if (Array.isArray(value)) {\n return encodeArray(config);\n }\n\n if (isObject(value)) {\n return encodeObject(config);\n }\n\n return encodePrimitive(config);\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeArray({\n location,\n key,\n value,\n style,\n explode,\n escape,\n isAllowedReserved = false,\n}: Omit<StylizerConfig, 'value'> & { value: string[] }) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue,black,brown`\n */\n case 'simple':\n return value.map(val => valueEncoder(val)).join(',');\n\n /**\n * @example <caption>`style: label`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `.blue.black.brown`\n */\n case 'label':\n return `.${value.map(val => valueEncoder(val)).join('.')}`;\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue;color=black;color=brown`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue,black,brown\t`\n */\n case 'matrix':\n return value\n .map(val => valueEncoder(val))\n .reduce((prev, curr) => {\n if (!prev || explode) {\n return `${prev || ''};${key}=${curr}`;\n }\n return `${prev},${curr}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue&color=black&color=brown`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue,black,brown`\n */\n case 'form':\n return value.map(val => valueEncoder(val)).join(explode ? `&${key}=` : ',');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue%20black%20brown`\n */\n case 'spaceDelimited':\n return value.map(val => valueEncoder(val)).join(` ${explode ? `${key}=` : ''}`);\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue|black|brown`\n */\n case 'pipeDelimited':\n return value.map(val => valueEncoder(val)).join(`|${explode ? `${key}=` : ''}`);\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeObject({ location, key, value, style, explode, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n const valueKeys = Object.keys(value);\n\n switch (style) {\n /**\n * @example <caption>`style: simple` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100,G=200,B=150`\n *\n * @example <caption>`style: simple` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R,100,G,200,B,150`\n */\n case 'simple':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : ',';\n const prefix = prev ? `${prev},` : '';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: label` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R=100.G=200.B=150`\n *\n * @example <caption>`style: label` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R.100.G.200.B.150`\n */\n case 'label':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : '.';\n const prefix = prev ? `${prev}.` : '.';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;R=100;G=200;B=150`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;color=R,100,G,200,B,150`\n */\n case 'matrix':\n if (explode) {\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev};` : ';';\n\n return `${prefix}${curr}=${val}`;\n }, '');\n }\n\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev},` : `;${key}=`;\n\n return `${prefix}${curr},${val}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100&G=200&B=150`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color=R,100,G,200,B,150`\n */\n case 'form':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';\n const separator = explode ? '=' : ',';\n\n return `${prefix}${curr}${separator}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R%20100%20G%20200%20B%20150`\n */\n case 'spaceDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev} ` : '';\n\n return `${prefix}${curr} ${val}`;\n }, '');\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R|100|G|200|B|150`\n */\n case 'pipeDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}|` : '';\n\n return `${prefix}${curr}|${val}`;\n }, '');\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color[R]=100&color[G]=200&color[B]=150`\n */\n case 'deepObject':\n return valueKeys.reduce(curr => {\n const val = valueEncoder(value[curr]);\n return `${val}`;\n }, '');\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodePrimitive({ location, key, value, style, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query' || location === 'body',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `blue` → `blue`\n */\n case 'simple':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: label`</caption>\n * `blue` → `.blue`\n */\n case 'label':\n return `.${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: matrix`</caption>\n * `blue` → `;color=blue`\n */\n case 'matrix':\n if (value === '') {\n return `;${key}`;\n }\n\n return `;${key}=${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: form`</caption>\n * `blue` → `color=blue`\n */\n case 'form':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `blue` → n/a\n */\n case 'deepObject':\n return valueEncoder(value);\n\n default:\n return undefined;\n }\n}\n","import type { JSONSchema, SchemaObject } from 'oas/types';\n\nimport { get } from './lodash.js';\n\n/**\n * Determine if a schema `type` is, or contains, a specific discriminator.\n *\n */\nexport function hasSchemaType(\n schema: SchemaObject,\n discriminator: 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string',\n): boolean {\n if (Array.isArray(schema.type)) {\n return schema.type.includes(discriminator);\n }\n\n return schema.type === discriminator;\n}\n\n/**\n * Because some request body schema shapes might not always be a top-level `properties`, instead\n * nesting it in an `oneOf` or `anyOf` we need to extract the first usable schema that we have. If\n * we don't do this then these non-conventional request body schema payloads may not be properly\n * represented in the HAR that we generate.\n *\n */\nexport function getSafeRequestBody(obj: any): any {\n if ('oneOf' in obj) {\n return getSafeRequestBody(obj.oneOf[0]);\n } else if ('anyOf' in obj) {\n return getSafeRequestBody(obj.anyOf[0]);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\nfunction getSubschemas(schema: any, opts: Options) {\n let subSchemaDataSize = 0;\n if (opts.parentIsArray) {\n // If we don't have data for this parent schema in our body payload then we\n // shouldn't bother spidering further into the schema looking for more `format`s\n // for data that definitely doesn't exist.\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData === undefined || !Array.isArray(parentData)) {\n return false;\n }\n\n subSchemaDataSize = parentData.length;\n }\n\n let subschemas: any[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n subschemas = subschemas.concat(\n Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, idx, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n })),\n );\n }\n } else {\n subschemas = Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n }));\n }\n\n return subschemas;\n}\n\n/**\n * With a supplied JSON Schema object, spider through it for any schemas that may contain specific\n * kind of `format` that also happen to be within the current `requestBody` payload that we're\n * creating a HAR representation for.\n *\n */\nexport function getTypedFormatsInSchema(\n format: 'binary' | 'json',\n schema: any,\n opts: Options,\n): (boolean | string)[] | boolean | string {\n try {\n if (schema?.format === format) {\n if (opts.parentIsArray) {\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData !== undefined && Array.isArray(parentData)) {\n return Object.keys(parentData)\n .map(pdk => {\n const currentKey = [opts.parentKey, pdk].join('.');\n if (get(opts.payload, currentKey) !== undefined) {\n return currentKey;\n }\n\n return false;\n })\n .filter(Boolean);\n }\n } else if (opts.parentKey && get(opts.payload, opts.parentKey) !== undefined) {\n return opts.parentKey;\n } else if (opts.payload !== undefined) {\n // If this payload is present and we're looking for a specific format then we should assume\n // that the **root** schema of the request body is that format, and we aren't trafficking in\n // a nested object or array schema.\n return true;\n }\n\n return false;\n }\n\n const subschemas = getSubschemas(schema, opts);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .map(({ key, schema: subschema }) => {\n if ('properties' in subschema) {\n return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });\n } else if ('items' in subschema) {\n if ((subschema.items as JSONSchema)?.properties) {\n return getTypedFormatsInSchema(format, (subschema.items as JSONSchema).properties, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n return getTypedFormatsInSchema(format, subschema.items, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n // If this schema has neither `properties` or `items` then it's a regular schema\n // we can re-run.\n return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });\n })\n .flat()\n .filter(Boolean);\n } catch (err) {\n // If this fails for whatever reason then we should act as if we didn't find any `format`'d\n // schemas.\n return [];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","../src/index.ts","../src/lib/lodash.ts","../src/lib/style-formatting/index.ts","../src/lib/style-formatting/style-serializer.ts","../src/lib/utils.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAAA;AACA;AACA;ACcA,6CAAsC;AACtC,4CAAuC;AACvC,0CAA0B;AAC1B,kCAAsB;AACtB,kCAAiD;AACjD,kJAAmC;ADZnC;AACA;AEHO,SAAS,GAAA,CAAI,MAAA,EAAiB,IAAA,EAAoB;AAEvD,EAAA,GAAA,CAAI,CAAC,IAAA,EAAM,OAAO,KAAA,CAAA;AAGlB,EAAA,MAAM,UAAA,EAAY,MAAA,CAAO,IAAI,CAAA,CAAE,KAAA,CAAM,aAAa,CAAA;AAGlD,EAAA,MAAM,OAAA,kBAAS,SAAA,2BAAW,MAAA,mBAAO,CAAC,OAAA,EAAS,GAAA,EAAA,mBAAQ,OAAA,4BAAA,CAAU,GAAG,GAAA,EAAG,MAAM,GAAA;AAEzE,EAAA,OAAO,MAAA;AACT;AAOO,SAAS,GAAA,CAAa,MAAA,EAAgB,IAAA,EAAoB,KAAA,EAAqB;AAEpF,EAAA,MAAM,UAAA,EAAoD,KAAA,CAAM,OAAA,CAAQ,IAAI,EAAA,EACx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AAA;AAEjB,EAAA;AAEQ,IAAA;AACG,MAAA;AAC8B,QAAA;AACjD,QAAA;AAClB,UAAA;AACF,QAAA;AAIkD,QAAA;AAC4B,UAAA;AAC1E,YAAA;AACF,UAAA;AACF,QAAA;AAI0B,QAAA;AACsD,UAAA;AAE9E,QAAA;AACA,UAAA;AACF,QAAA;AAEgD,QAAA;AACjD,MAAA;AACF,IAAA;AACH,EAAA;AAGkD,EAAA;AACrC,IAAA;AACb,EAAA;AAEO,EAAA;AACA,IAAA;AACM,MAAA;AACP,QAAA;AACW,UAAA;AACX,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACF;ADmRuG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","sourcesContent":[null,"import type { PostData, PostDataParams, Request } from 'har-format';\nimport type Oas from 'oas';\nimport type { Extensions } from 'oas/extensions';\nimport type { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n ServerVariable,\n} from 'oas/types';\nimport type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport { HEADERS, PROXY_ENABLED } from 'oas/extensions';\nimport { Operation } from 'oas/operation';\nimport { isRef } from 'oas/types';\nimport { jsonSchemaTypes, matchesMimeType } from 'oas/utils';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport configureSecurity from './lib/configure-security.js';\nimport { get, set } from './lib/lodash.js';\nimport formatStyle from './lib/style-formatting/index.js';\nimport { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils.js';\n\nfunction formatter(\n values: DataForHAR,\n param: ParameterObject,\n type: 'body' | 'cookie' | 'header' | 'path' | 'query',\n onlyIfExists = false,\n) {\n if (param.style) {\n const value = values[type][param.name];\n // Note: Technically we could send everything through the format style and choose the proper\n // default for each `in` type (e.g. query defaults to form).\n return formatStyle(value, param);\n }\n\n let value: string | number | boolean | undefined;\n\n // Handle missing values\n if (typeof values[type][param.name] !== 'undefined') {\n value = values[type][param.name];\n } else if (onlyIfExists && !param.required) {\n value = undefined;\n } else if (param.required && param.schema && !isRef(param.schema) && param.schema.default) {\n value = param.schema.default;\n } else if (type === 'path') {\n // If we don't have any values for the path parameter, just use the name of the parameter as the\n // value so we don't try try to build a URL to something like `https://example.com/undefined`.\n return param.name;\n }\n\n // Handle file uploads. Specifically arrays of file uploads which need to be formatted very\n // specifically.\n if (\n param.schema &&\n !isRef(param.schema) &&\n param.schema.type === 'array' &&\n param.schema.items &&\n !isRef(param.schema.items) &&\n param.schema.items.format === 'binary'\n ) {\n if (Array.isArray(value)) {\n // If this is array of binary data then we shouldn't do anything because we'll prepare them\n // separately in the HAR in order to preserve `fileName` and `contentType` data within\n // `postData.params`. If we don't then the HAR we generate for this data will be invalid.\n return value;\n }\n\n return JSON.stringify(value);\n }\n\n if (value !== undefined) {\n // Query params should always be formatted, even if they don't have a `style` serialization\n // configured.\n if (type === 'query') {\n return formatStyle(value, param);\n }\n\n return value;\n }\n\n return undefined;\n}\n\nfunction multipartBodyToFormatterParams(payload: unknown, oasMediaTypeObject: MediaTypeObject, schema: SchemaObject) {\n const encoding = oasMediaTypeObject.encoding;\n\n if (typeof payload === 'object' && payload !== null) {\n return Object.keys(payload)\n .map(key => {\n // If we have an incoming parameter, but it's not in the schema ignore it.\n if (!schema.properties?.[key]) {\n return false;\n }\n\n const paramEncoding = encoding ? encoding[key] : undefined;\n\n return {\n name: key,\n // If the style isn't defined, use the default\n style: paramEncoding ? paramEncoding.style : undefined,\n // If explode isn't defined, use the default\n explode: paramEncoding ? paramEncoding.explode : undefined,\n required:\n (schema.required && typeof schema.required === 'boolean' && Boolean(schema.required)) ||\n (Array.isArray(schema.required) && schema.required.includes(key)),\n schema: schema.properties[key],\n in: 'body',\n };\n })\n .filter(Boolean) as ParameterObject[];\n }\n\n // Pretty sure that we'll never have anything but an object for multipart bodies, so returning\n // empty array if we get anything else.\n return [];\n}\n\nconst defaultFormDataTypes = Object.keys(jsonSchemaTypes).reduce((prev, curr) => {\n return Object.assign(prev, { [curr]: {} });\n}, {});\n\nfunction getResponseContentType(content: MediaTypeObject) {\n const types = Object.keys(content) || [];\n\n // If this response content has multiple types available we should always prefer the one that's\n // JSON-compatible. If they don't have one that is we'll return the first available, otherwise\n // if they don't have **any** repsonse content types present we'll assume it's JSON.\n if (types?.length) {\n const jsonType = types.find(t => matchesMimeType.json(t));\n if (jsonType) {\n return jsonType;\n }\n\n return types[0];\n }\n\n return 'application/json';\n}\n\nfunction isPrimitive(val: unknown) {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n\nfunction stringify(json: Record<string | 'RAW_BODY', unknown>) {\n return JSON.stringify(removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json));\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return param;\n } else if (Array.isArray(param) && param.every(isPrimitive)) {\n return String(param);\n }\n\n return JSON.stringify(param);\n}\n\nfunction appendHarValue(\n harParam: PostDataParams['params'] | Request['cookies'] | Request['headers'] | Request['queryString'],\n name: string,\n value: any,\n addtlData: {\n contentType?: string;\n fileName?: string;\n } = {},\n) {\n if (typeof value === 'undefined') return;\n\n if (Array.isArray(value)) {\n // If the formatter gives us an array, we're expected to add each array value as a new\n // parameter item with the same parameter name\n value.forEach(singleValue => {\n appendHarValue(harParam, name, singleValue);\n });\n } else if (typeof value === 'object' && value !== null) {\n // If the formatter gives us an object, we're expected to add each property value as a new\n // parameter item, each with the name of the property\n Object.keys(value).forEach(key => {\n appendHarValue(harParam, key, value[key]);\n });\n } else {\n // If the formatter gives us a non-array, non-object, we add it as is\n harParam.push({\n ...addtlData,\n name,\n value: String(value),\n });\n }\n}\n\nfunction encodeBodyForHAR(body: any) {\n if (isPrimitive(body)) {\n return body;\n } else if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n typeof body.RAW_BODY !== 'undefined'\n ) {\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload as a\n // raw string. https://docs.readme.com/docs/raw-body-content\n if (isPrimitive(body.RAW_BODY)) {\n return body.RAW_BODY;\n }\n\n return stringify(body.RAW_BODY);\n }\n\n return stringify(body);\n}\n\nexport default function oasToHar(\n oas: Oas,\n operationSchema?: Operation,\n values: DataForHAR = {},\n auth: AuthForHAR = {},\n opts: oasToHarOptions = { proxyUrl: '' },\n): {\n log: {\n entries: readonly [\n {\n readonly request: Request;\n },\n ];\n };\n} {\n let operation: Operation;\n if (!operationSchema || typeof operationSchema.getParameters !== 'function') {\n /**\n * If `operationSchema` was supplied as a plain object instead of an instance of `Operation`\n * then we should create a new instance of it. We're doing it with a check on `getParameters`\n * instead of checking `instanceof Operation` because JS is very weird when it comes to\n * checking `instanceof` against classes. One instance of `Operation` may not always match up\n * with another if they're being loaded between two different libraries.\n *\n * It's weird. This is easier.\n */\n operation = new Operation(\n oas as unknown as OASDocument,\n operationSchema?.path || '',\n operationSchema?.method || ('' as HttpMethods),\n (operationSchema as unknown as OperationObject) || { path: '', method: '' },\n );\n } else {\n operation = operationSchema;\n }\n\n const apiDefinition = oas.getDefinition();\n\n const formData: DataForHAR = {\n ...defaultFormDataTypes,\n ...values,\n };\n\n if (!formData.server) {\n formData.server = {\n selected: 0,\n variables: oas.defaultVariables(0),\n };\n }\n\n // If the incoming `server.variables` is missing variables let's pad it out with defaults.\n formData.server.variables = {\n ...oas.defaultVariables(formData.server.selected),\n ...(formData.server.variables ? formData.server.variables : {}),\n };\n\n const har: Request = {\n cookies: [],\n headers: [],\n headersSize: 0,\n queryString: [],\n // @ts-expect-error This is fine because we're fleshing `postData` out further down.\n postData: {},\n bodySize: 0,\n method: operation.method.toUpperCase(),\n url: `${oas.url(formData.server.selected, formData.server.variables as ServerVariable)}${operation.path}`.replace(\n /\\s/g,\n '%20',\n ),\n httpVersion: 'HTTP/1.1',\n };\n\n if (opts.proxyUrl) {\n if (oas.getExtension(PROXY_ENABLED, operation)) {\n har.url = `${opts.proxyUrl}/${har.url}`;\n }\n }\n\n const parameters = operation.getParameters();\n\n har.url = har.url.replace(/{([-_a-zA-Z0-9[\\]]+)}/g, (full, key) => {\n if (!operation || !parameters) return key; // No path params at all\n\n // Find the path parameter or set a default value if it does not exist\n const parameter = parameters.find(param => param.name === key) || ({ name: key } as ParameterObject);\n\n // The library that handles our style processing already encodes uri elements. For everything\n // else we need to handle it here.\n if (!('style' in parameter) || !parameter.style) {\n return encodeURIComponent(formatter(formData, parameter, 'path'));\n }\n\n return formatter(formData, parameter, 'path');\n });\n\n const queryStrings = parameters?.filter(param => param.in === 'query');\n if (queryStrings?.length) {\n queryStrings.forEach(queryString => {\n const value = formatter(formData, queryString, 'query', true);\n appendHarValue(har.queryString, queryString.name, value);\n });\n }\n\n // Do we have any `cookie` parameters on the operation?\n const cookies = parameters?.filter(param => param.in === 'cookie');\n if (cookies?.length) {\n cookies.forEach(cookie => {\n const value = formatter(formData, cookie, 'cookie', true);\n appendHarValue(har.cookies, cookie.name, value);\n });\n }\n\n // Does this response have any documented content types?\n if (operation.schema.responses) {\n Object.keys(operation.schema.responses).some(response => {\n if (isRef(operation.schema.responses?.[response])) return false;\n\n const content = (operation.schema.responses?.[response] as ResponseObject).content;\n if (!content) return false;\n\n // If there's no `accept` header present we should add one so their eventual code snippet\n // follows best practices.\n if (Object.keys(formData.header || {}).find(h => h.toLowerCase() === 'accept')) return true;\n\n har.headers.push({\n name: 'accept',\n value: getResponseContentType(content),\n });\n\n return true;\n });\n }\n\n // Do we have any `header` parameters on the operation?\n let hasContentType = false;\n let contentType = operation.getContentType();\n const headers = parameters?.filter(param => param.in === 'header');\n if (headers?.length) {\n headers.forEach(header => {\n const value = formatter(formData, header, 'header', true);\n if (typeof value === 'undefined') return;\n\n if (header.name.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(value);\n }\n\n appendHarValue(har.headers, header.name, value);\n });\n }\n\n // Are there `x-headers` static headers configured for this OAS?\n const userDefinedHeaders = oas.getExtension(HEADERS, operation) as Extensions['headers'];\n if (userDefinedHeaders) {\n userDefinedHeaders.forEach(header => {\n if (typeof header.key === 'string' && header.key.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(header.value);\n }\n\n har.headers.push({\n name: String(header.key),\n value: String(header.value),\n });\n });\n }\n\n if (formData.header) {\n // Do we have an `accept` header set up in the form data, but it hasn't been added yet?\n const acceptHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'accept');\n if (acceptHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'accept')) {\n har.headers.push({\n name: 'accept',\n value: String(formData.header[acceptHeader]),\n });\n }\n\n // Do we have a manually-defined `authorization` header set up in the form data?\n const authorizationHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'authorization');\n if (authorizationHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'authorization')) {\n har.headers.push({\n name: 'authorization',\n value: String(formData.header[authorizationHeader]),\n });\n }\n }\n\n let requestBody: SchemaWrapper | undefined;\n if (operation.hasRequestBody()) {\n requestBody = operation.getParametersAsJSONSchema().find(payload => {\n // `formData` is used in our API Explorer for `application/x-www-form-urlencoded` endpoints\n // and if you have an operation with that, it will only ever have a `formData`. `body` is\n // used for all other payload shapes.\n return payload.type === (operation.isFormUrlEncoded() ? 'formData' : 'body');\n });\n }\n\n if (requestBody?.schema && Object.keys(requestBody.schema).length) {\n const requestBodySchema = requestBody.schema as SchemaObject;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.formData)));\n if (cleanFormData !== undefined) {\n const postData: PostData = { params: [], mimeType: 'application/x-www-form-urlencoded' };\n\n Object.keys(cleanFormData).forEach(name => {\n postData.params.push({\n name,\n value: stringifyParameter(cleanFormData[name]),\n });\n });\n\n har.postData = postData;\n }\n }\n } else if (\n 'body' in formData &&\n formData.body !== undefined &&\n (isPrimitive(formData.body) || Object.keys(formData.body).length)\n ) {\n const isMultipart = operation.isMultipart();\n const isJSON = operation.isJson();\n\n if (isMultipart || isJSON) {\n try {\n let cleanBody = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.body)));\n\n if (isMultipart) {\n har.postData = { params: [], mimeType: 'multipart/form-data' };\n\n // Because some request body schema shapes might not always be a top-level `properties`,\n // instead nesting it in an `oneOf` or `anyOf` we need to extract the first usable\n // schema that we have in order to process this multipart payload.\n const safeBodySchema = getSafeRequestBody(requestBodySchema);\n\n /**\n * Discover all `{ type: string, format: binary }` properties, or arrays containing the\n * same, within the request body. If there are any, then that means that we're dealing\n * with a `multipart/form-data` request and need to treat the payload as\n * `postData.params` and supply filenames and content types for the files (if they're\n * available).\n *\n * @todo It'd be nice to replace this with `getTypedFormatsInSchema` instead.\n * @example `{ type: string, format: binary }`\n * @example `{ type: array, items: { type: string, format: binary } }`\n */\n const binaryTypes = Object.keys(safeBodySchema.properties).filter(key => {\n const propData = safeBodySchema.properties[key] as JSONSchema;\n if (propData.format === 'binary') {\n return true;\n } else if (\n propData.type === 'array' &&\n propData.items &&\n typeof propData.items === 'object' &&\n propData.items !== null &&\n (propData.items as JSONSchema).format === 'binary'\n ) {\n return true;\n }\n\n return false;\n });\n\n if (cleanBody !== undefined) {\n const multipartParams = multipartBodyToFormatterParams(\n formData.body,\n (operation.schema.requestBody as RequestBodyObject).content['multipart/form-data'],\n safeBodySchema,\n );\n\n if (multipartParams.length) {\n Object.keys(cleanBody).forEach(name => {\n const param = multipartParams.find(multipartParam => multipartParam.name === name);\n\n if (param) {\n // If we're dealing with a binary type, and the value is a valid data URL we should\n // parse out any available filename and content type to send along with the\n // parameter to interpreters like `fetch-har` can make sense of it and send a usable\n // payload.\n const addtlData: { contentType?: string; fileName?: string } = {};\n\n let value = formatter(formData, param, 'body', true);\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n value.forEach((val: string) => {\n if (binaryTypes.includes(name)) {\n const parsed = parseDataUrl(val);\n if (parsed) {\n addtlData.fileName = 'name' in parsed ? parsed.name : 'unknown';\n if ('contentType' in parsed) {\n addtlData.contentType = parsed.contentType;\n }\n }\n }\n\n appendHarValue(har.postData?.params || [], name, val, addtlData);\n });\n }\n });\n }\n }\n } else {\n har.postData = { mimeType: contentType, text: '' };\n\n if (\n hasSchemaType(requestBody.schema, 'string') ||\n hasSchemaType(requestBody.schema, 'integer') ||\n hasSchemaType(requestBody.schema, 'number') ||\n hasSchemaType(requestBody.schema, 'boolean')\n ) {\n har.postData.text = JSON.stringify(JSON.parse(cleanBody));\n } else {\n /**\n * Handle formatted JSON objects that have properties that accept arbitrary JSON.\n *\n * Find all `{ type: string, format: json }` properties in the schema because we need\n * to manually `JSON.parse` them before submit, otherwise they'll be escaped instead\n * of actual objects. We also only want values that the user has entered, so we drop\n * any `undefined` `cleanBody` keys.\n */\n const jsonTypes = getTypedFormatsInSchema('json', requestBodySchema.properties, { payload: cleanBody });\n\n if (Array.isArray(jsonTypes) && jsonTypes.length) {\n try {\n jsonTypes.forEach((prop: boolean | string) => {\n try {\n set(cleanBody, String(prop), JSON.parse(get(cleanBody, String(prop))));\n } catch (e) {\n // leave the prop as a string value\n }\n });\n\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload\n // as a raw string. https://docs.readme.com/docs/raw-body-content\n if (typeof cleanBody.RAW_BODY !== 'undefined') {\n cleanBody = cleanBody.RAW_BODY;\n }\n\n har.postData.text = JSON.stringify(cleanBody);\n } catch (e) {\n har.postData.text = stringify(formData.body);\n }\n } else {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n } catch (e) {\n // If anything above fails for whatever reason, assume that whatever we had is invalid\n // JSON and just treat it as raw text.\n har.postData = { mimeType: contentType, text: stringify(formData.body) };\n }\n } else {\n har.postData = { mimeType: contentType, text: encodeBodyForHAR(formData.body) };\n }\n }\n }\n\n // Add a `content-type` header if there are any body values setup above or if there is a schema\n // defined, but only do so if we don't already have a `content-type` present as it's impossible\n // for a request to have multiple.\n if ((har.postData?.text || (requestBody?.schema && Object.keys(requestBody.schema).length)) && !hasContentType) {\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\n const securityRequirements = operation.getSecurity();\n\n if (securityRequirements?.length) {\n // TODO pass these values through the formatter?\n securityRequirements.forEach(schemes => {\n Object.keys(schemes).forEach(security => {\n const securityValue = configureSecurity(apiDefinition, auth, security);\n if (!securityValue) {\n return;\n }\n\n // If this is an `authorization` header and we've already added one (maybe one was manually\n // specified), then we shouldn't add another.\n if (securityValue.value.name === 'authorization') {\n if (har[securityValue.type].find(v => v.name === securityValue.value.name)) {\n return;\n }\n }\n\n // If we've already added this **specific** security value then don't add it again.\n if (\n har[securityValue.type].find(\n v => v.name === securityValue.value.name && v.value === securityValue.value.value,\n )\n ) {\n return;\n }\n\n har[securityValue.type].push(securityValue.value);\n });\n });\n }\n\n // If we didn't end up filling the `postData` object then we don't need it.\n if (Object.keys(har.postData || {}).length === 0) {\n delete har.postData;\n }\n\n return {\n log: {\n entries: [\n {\n request: har,\n },\n ] as const,\n },\n };\n}\n","type Many<T> = T | readonly T[];\ntype PropertyName = number | string | symbol;\ntype PropertyPath = Many<PropertyName>;\n\n/**\n * A janky, poorly typed replacement for `lodash.get`.\n *\n * @see {@link https://youmightnotneed.com/lodash#get}\n */\nexport function get(object: unknown, path?: string): any {\n // If path is not defined or it has false value\n if (!path) return undefined;\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n // Regex explained: https://regexr.com/58j0k\n const pathArray = String(path).match(/([^[.\\]])+/g);\n // Find value\n // @ts-expect-error idk man\n const result = pathArray?.reduce((prevObj, key) => prevObj?.[key], object);\n // If found value is undefined return default value; otherwise return the value\n return result;\n}\n\n/**\n * A janky, poorly typed replacement for `lodash.set`.\n *\n * @see {@link https://youmightnotneed.com/lodash#set}\n */\nexport function set<TResult>(object: object, path: PropertyPath, value: any): TResult {\n // Regex explained: https://regexr.com/58j0k\n const pathArray: PropertyPath | RegExpMatchArray | null = Array.isArray(path)\n ? path\n : String(path).match(/([^[.\\]])+/g);\n\n // @ts-expect-error idk man\n return pathArray?.reduce((acc, key, i) => {\n // @ts-expect-error idk man\n if (acc[key] === undefined) {\n // @ts-expect-error idk man\n acc[key] = {};\n }\n if (i === pathArray.length - 1) {\n // @ts-expect-error idk man\n acc[key] = value;\n }\n // @ts-expect-error idk man\n return acc[key];\n }, object);\n}\n","import type { ParameterObject, SchemaObject } from 'oas/types';\nimport type { StylizerConfig } from './style-serializer.js';\n\nimport qs from 'qs';\n\nimport { stylize } from './style-serializer.js';\n\n// Certain styles don't support empty values.\nfunction shouldNotStyleEmptyValues(parameter: ParameterObject) {\n return ['simple', 'spaceDelimited', 'pipeDelimited', 'deepObject'].includes(parameter.style || '');\n}\n\nfunction shouldNotStyleReservedHeader(parameter: ParameterObject) {\n return ['accept', 'authorization', 'content-type'].includes(parameter.name.toLowerCase());\n}\n\n/**\n * Note: This isn't necessarily part of the spec. Behavior for the value 'undefined' is, well,\n * undefined. This code makes our system look better. If we wanted to be more accurate, we might\n * want to remove this, restore the un-fixed behavior for undefined and have our UI pass in empty\n * string instead of undefined.\n */\nfunction removeUndefinedForPath(value: any) {\n let finalValue = value;\n\n if (typeof finalValue === 'undefined') {\n return '';\n }\n\n if (Array.isArray(finalValue)) {\n finalValue = finalValue.filter(val => (val === undefined ? '' : val));\n\n if (finalValue.length === 0) {\n finalValue = '';\n }\n }\n\n if (typeof finalValue === 'object') {\n Object.keys(finalValue).forEach(key => {\n finalValue[key] = finalValue[key] === undefined ? '' : finalValue[key];\n });\n }\n\n return finalValue;\n}\n\nfunction stylizeValue(value: unknown, parameter: ParameterObject) {\n let finalValue = value;\n\n // Some styles don't work with empty values. We catch those there\n if (shouldNotStyleEmptyValues(parameter) && (typeof finalValue === 'undefined' || finalValue === '')) {\n // Paths need return an unstyled empty string instead of undefined so it's ignored in the final\n // path string.\n if (parameter.in === 'path') {\n return '';\n }\n\n // Everything but path should return undefined when unstyled so it's ignored in the final\n // parameter array.\n return undefined;\n }\n\n // Every style that adds their style to empty values should use emptystring for path parameters\n // instead of undefined to avoid the string `undefined`.\n if (parameter.in === 'path') {\n finalValue = removeUndefinedForPath(finalValue);\n }\n\n /**\n * Eventhough `accept`, `authorization`, and `content-type` headers can be defined as parameters,\n * they should be completely ignored when it comes to serialization.\n *\n * > If `in` is \"header\" and the `name` field is \"Accept\", \"Content-Type\" or \"Authorization\", the\n * > parameter definition SHALL be ignored.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10}\n */\n if (parameter.in === 'header' && shouldNotStyleReservedHeader(parameter)) {\n return value;\n }\n\n /**\n * All parameter types have a default `style` format so if they don't have one prescribed we\n * should still conform to what the spec defines.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterstyle}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterstyle}\n */\n let style = parameter.style;\n if (!style) {\n if (parameter.in === 'query') {\n style = 'form';\n } else if (parameter.in === 'path') {\n style = 'simple';\n } else if (parameter.in === 'header') {\n style = 'simple';\n } else if (parameter.in === 'cookie') {\n style = 'form';\n }\n }\n\n let explode = parameter.explode;\n if (explode === undefined && style === 'form') {\n /**\n * Per the spec if no `explode` is present but `style` is `form` then `explode` should default to `true`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterexplode}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterexplode}\n */\n explode = true;\n }\n\n return stylize({\n location: parameter.in as StylizerConfig['location'],\n value: finalValue,\n key: parameter.name,\n style: style as StylizerConfig['style'],\n explode,\n /**\n * @todo this parameter is optional to stylize. It defaults to false, and can accept falsy, truthy, or \"unsafe\".\n * I do not know if it is correct for query to use this. See style-serializer for more info\n */\n escape: true,\n ...(parameter.in === 'query' ? { isAllowedReserved: parameter.allowReserved || false } : {}),\n });\n}\n\nfunction handleDeepObject(value: any, parameter: ParameterObject) {\n return qs\n .stringify(value, {\n encoder(str, defaultEncoder, charset, type) {\n if (type === 'key') {\n // `str` will be here as `dog[treats][0]` but because the `qs` library doesn't have any\n // awareness of our OpenAPI parameters we need to rewrite it to slap the `parameter.name`\n // to the top, like `pets[dog][treats][0]`.\n const prefixedKey = str\n .split(/[[\\]]/g)\n .filter(Boolean)\n .map((k: string) => `[${k}]`)\n .join('');\n\n return `${parameter.name}${prefixedKey}`;\n } else if (type === 'value') {\n return stylizeValue(str, parameter);\n }\n },\n })\n .split('&')\n .map(item => {\n const split = item.split('=');\n return {\n label: split[0],\n // `qs` will coerce null values into being `undefined` string but we want to preserve them.\n value: split[1] === 'undefined' ? null : split[1],\n };\n });\n}\n\n// Explode is handled on its own, because style-serializer doesn't return what we expect for proper\n// HAR output.\nfunction handleExplode(value: any, parameter: ParameterObject) {\n // This is to handle the case of arrays of objects in the querystring\n // which is something that's not technically in the spec but since we're\n // using the `qs` module already, it's fairly easy for us to add support\n // for this use case.\n //\n // An example URL would be something like this:\n // https://example.com/?line_items[0][a_string]=abc&line_items[0][quantity]=1&line_items[1][a_string]=def&line_items[1][quantity]=2\n //\n // Some open issues discussing this here:\n // https://github.com/OAI/OpenAPI-Specification/issues/1706\n // https://github.com/OAI/OpenAPI-Specification/issues/1006\n //\n // Link to the spec for this:\n // https://github.com/OAI/OpenAPI-Specification/blob/36a3a67264cc1c4f1eff110cea3ebfe679435108/versions/3.1.0.md#style-examples\n if (\n Array.isArray(value) &&\n (parameter.schema as SchemaObject)?.type === 'array' &&\n parameter.style === 'deepObject'\n ) {\n const newObj: Record<string, unknown> = {};\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n return newObj;\n }\n\n if (Array.isArray(value)) {\n return value.map(val => {\n return stylizeValue(val, parameter);\n });\n }\n\n if (typeof value === 'object' && value !== null) {\n const newObj: Record<string, unknown> = {};\n\n Object.keys(value).forEach(key => {\n if (parameter.style === 'deepObject') {\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n } else {\n newObj[key] = stylizeValue(value[key], parameter);\n }\n });\n\n return newObj;\n }\n\n return stylizeValue(value, parameter);\n}\n\nfunction shouldExplode(parameter: ParameterObject) {\n return (\n (parameter.explode ||\n (parameter.explode !== false && parameter.style === 'form') ||\n // style: deepObject && explode: false doesn't exist so explode it always\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples\n parameter.style === 'deepObject') &&\n // header and path doesn't explode into separate parameters like query and cookie do\n parameter.in !== 'header' &&\n parameter.in !== 'path'\n );\n}\n\nexport default function formatStyle(value: unknown, parameter: ParameterObject): any {\n // Deep object style only works on objects and arrays, and only works with explode=true.\n if (parameter.style === 'deepObject' && (!value || typeof value !== 'object' || parameter.explode === false)) {\n return undefined;\n }\n\n // This custom explode logic allows us to bubble up arrays and objects to be handled differently\n // by our HAR transformer. We need this because the `stylizeValue` function assumes we're building\n // strings, not richer data types.\n //\n // The first part of this conditional checks if `explode` is enabled. Explode is disabled for\n // everything by default except for forms.\n //\n // The second part of this conditional bypasses the custom explode logic for headers, because they\n // work differently, and `stylizeValue` is accurate.\n if (shouldExplode(parameter)) {\n return handleExplode(value, parameter);\n }\n\n return stylizeValue(value, parameter);\n}\n","/**\n * This file has been extracted and modified from `swagger-client`.\n *\n * @license Apache 2.0\n * @link https://npm.im/swagger-client\n * @link https://github.com/swagger-api/swagger-js/blob/master/src/execute/oas3/style-serializer.js\n */\n\nconst isRfc3986Reserved = (char: string) => \":/?#[]@!$&'()*+,;=\".indexOf(char) > -1;\nconst isRfc3986Unreserved = (char: string) => /^[a-z0-9\\-._~]+$/i.test(char);\n\nfunction isURIEncoded(value: string) {\n try {\n return decodeURIComponent(value) !== value;\n } catch (err) {\n // `decodeURIComponent` will throw an exception if a string that has an un-encoded percent sign\n // in it (like 20%), o if it's throwing we can just assume that the value hasn't been encoded.\n return false;\n }\n}\n\nfunction isObject(value: unknown) {\n return typeof value === 'object' && value !== null;\n}\n\nfunction encodeDisallowedCharacters(\n str: string,\n {\n escape,\n returnIfEncoded = false,\n isAllowedReserved,\n }: {\n escape?: boolean | 'unsafe';\n isAllowedReserved?: boolean;\n returnIfEncoded?: boolean;\n } = {},\n parse?: boolean,\n): any {\n if (typeof str === 'number') {\n // biome-ignore lint/style/noParameterAssign: It is what it is.\n str = (str as number).toString();\n }\n\n if (returnIfEncoded) {\n if (isURIEncoded(str)) {\n return str;\n }\n }\n\n if (typeof str !== 'string' || !str.length) {\n return str;\n }\n\n if (!escape) {\n return str;\n }\n\n if (parse) {\n return JSON.parse(str);\n }\n\n // In ES6 you can do this quite easily by using the new ... spread operator. This causes the\n // string iterator (another new ES6 feature) to be used internally, and because that iterator is\n // designed to deal with code points rather than UCS-2/UTF-16 code units.\n return [...str]\n .map(char => {\n if (isRfc3986Unreserved(char)) {\n return char;\n }\n\n if (isRfc3986Reserved(char) && (escape === 'unsafe' || isAllowedReserved)) {\n return char;\n }\n\n const encoder = new TextEncoder();\n const encoded = Array.from(encoder.encode(char))\n .map(byte => `0${byte.toString(16).toUpperCase()}`.slice(-2))\n .map(encodedByte => `%${encodedByte}`)\n .join('');\n\n return encoded;\n })\n .join('');\n}\n\nexport interface StylizerConfig {\n escape: boolean | 'unsafe';\n explode?: boolean;\n isAllowedReserved?: boolean;\n key: string;\n location: 'body' | 'query';\n style: 'deepObject' | 'form' | 'label' | 'matrix' | 'pipeDelimited' | 'simple' | 'spaceDelimited';\n value: any;\n}\n\nexport function stylize(config: StylizerConfig): any {\n const { value } = config;\n\n if (Array.isArray(value)) {\n return encodeArray(config);\n }\n\n if (isObject(value)) {\n return encodeObject(config);\n }\n\n return encodePrimitive(config);\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeArray({\n location,\n key,\n value,\n style,\n explode,\n escape,\n isAllowedReserved = false,\n}: Omit<StylizerConfig, 'value'> & { value: string[] }) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue,black,brown`\n */\n case 'simple':\n return value.map(val => valueEncoder(val)).join(',');\n\n /**\n * @example <caption>`style: label`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `.blue.black.brown`\n */\n case 'label':\n return `.${value.map(val => valueEncoder(val)).join('.')}`;\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue;color=black;color=brown`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue,black,brown\t`\n */\n case 'matrix':\n return value\n .map(val => valueEncoder(val))\n .reduce((prev, curr) => {\n if (!prev || explode) {\n return `${prev || ''};${key}=${curr}`;\n }\n return `${prev},${curr}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue&color=black&color=brown`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue,black,brown`\n */\n case 'form':\n return value.map(val => valueEncoder(val)).join(explode ? `&${key}=` : ',');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue%20black%20brown`\n */\n case 'spaceDelimited':\n return value.map(val => valueEncoder(val)).join(` ${explode ? `${key}=` : ''}`);\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue|black|brown`\n */\n case 'pipeDelimited':\n return value.map(val => valueEncoder(val)).join(`|${explode ? `${key}=` : ''}`);\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeObject({ location, key, value, style, explode, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n const valueKeys = Object.keys(value);\n\n switch (style) {\n /**\n * @example <caption>`style: simple` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100,G=200,B=150`\n *\n * @example <caption>`style: simple` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R,100,G,200,B,150`\n */\n case 'simple':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : ',';\n const prefix = prev ? `${prev},` : '';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: label` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R=100.G=200.B=150`\n *\n * @example <caption>`style: label` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R.100.G.200.B.150`\n */\n case 'label':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : '.';\n const prefix = prev ? `${prev}.` : '.';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;R=100;G=200;B=150`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;color=R,100,G,200,B,150`\n */\n case 'matrix':\n if (explode) {\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev};` : ';';\n\n return `${prefix}${curr}=${val}`;\n }, '');\n }\n\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev},` : `;${key}=`;\n\n return `${prefix}${curr},${val}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100&G=200&B=150`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color=R,100,G,200,B,150`\n */\n case 'form':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';\n const separator = explode ? '=' : ',';\n\n return `${prefix}${curr}${separator}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R%20100%20G%20200%20B%20150`\n */\n case 'spaceDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev} ` : '';\n\n return `${prefix}${curr} ${val}`;\n }, '');\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R|100|G|200|B|150`\n */\n case 'pipeDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}|` : '';\n\n return `${prefix}${curr}|${val}`;\n }, '');\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color[R]=100&color[G]=200&color[B]=150`\n */\n case 'deepObject':\n return valueKeys.reduce(curr => {\n const val = valueEncoder(value[curr]);\n return `${val}`;\n }, '');\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodePrimitive({ location, key, value, style, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query' || location === 'body',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `blue` → `blue`\n */\n case 'simple':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: label`</caption>\n * `blue` → `.blue`\n */\n case 'label':\n return `.${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: matrix`</caption>\n * `blue` → `;color=blue`\n */\n case 'matrix':\n if (value === '') {\n return `;${key}`;\n }\n\n return `;${key}=${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: form`</caption>\n * `blue` → `color=blue`\n */\n case 'form':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `blue` → n/a\n */\n case 'deepObject':\n return valueEncoder(value);\n\n default:\n return undefined;\n }\n}\n","import type { JSONSchema, SchemaObject } from 'oas/types';\n\nimport { get } from './lodash.js';\n\n/**\n * Determine if a schema `type` is, or contains, a specific discriminator.\n *\n */\nexport function hasSchemaType(\n schema: SchemaObject,\n discriminator: 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string',\n): boolean {\n if (Array.isArray(schema.type)) {\n return schema.type.includes(discriminator);\n }\n\n return schema.type === discriminator;\n}\n\n/**\n * Because some request body schema shapes might not always be a top-level `properties`, instead\n * nesting it in an `oneOf` or `anyOf` we need to extract the first usable schema that we have. If\n * we don't do this then these non-conventional request body schema payloads may not be properly\n * represented in the HAR that we generate.\n *\n */\nexport function getSafeRequestBody(obj: any): any {\n if ('oneOf' in obj) {\n return getSafeRequestBody(obj.oneOf[0]);\n } else if ('anyOf' in obj) {\n return getSafeRequestBody(obj.anyOf[0]);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\nfunction getSubschemas(schema: any, opts: Options) {\n let subSchemaDataSize = 0;\n if (opts.parentIsArray) {\n // If we don't have data for this parent schema in our body payload then we\n // shouldn't bother spidering further into the schema looking for more `format`s\n // for data that definitely doesn't exist.\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData === undefined || !Array.isArray(parentData)) {\n return false;\n }\n\n subSchemaDataSize = parentData.length;\n }\n\n let subschemas: any[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n subschemas = subschemas.concat(\n Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, idx, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n })),\n );\n }\n } else {\n subschemas = Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n }));\n }\n\n return subschemas;\n}\n\n/**\n * With a supplied JSON Schema object, spider through it for any schemas that may contain specific\n * kind of `format` that also happen to be within the current `requestBody` payload that we're\n * creating a HAR representation for.\n *\n */\nexport function getTypedFormatsInSchema(\n format: 'binary' | 'json',\n schema: any,\n opts: Options,\n): (boolean | string)[] | boolean | string {\n try {\n if (schema?.format === format) {\n if (opts.parentIsArray) {\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData !== undefined && Array.isArray(parentData)) {\n return Object.keys(parentData)\n .map(pdk => {\n const currentKey = [opts.parentKey, pdk].join('.');\n if (get(opts.payload, currentKey) !== undefined) {\n return currentKey;\n }\n\n return false;\n })\n .filter(Boolean);\n }\n } else if (opts.parentKey && get(opts.payload, opts.parentKey) !== undefined) {\n return opts.parentKey;\n } else if (opts.payload !== undefined) {\n // If this payload is present and we're looking for a specific format then we should assume\n // that the **root** schema of the request body is that format, and we aren't trafficking in\n // a nested object or array schema.\n return true;\n }\n\n return false;\n }\n\n const subschemas = getSubschemas(schema, opts);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema }) => {\n if ('properties' in subschema) {\n return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });\n } else if ('items' in subschema) {\n if ((subschema.items as JSONSchema)?.properties) {\n return getTypedFormatsInSchema(format, (subschema.items as JSONSchema).properties, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n return getTypedFormatsInSchema(format, subschema.items, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n // If this schema has neither `properties` or `items` then it's a regular schema\n // we can re-run.\n return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });\n })\n .filter(Boolean);\n } catch (err) {\n // If this fails for whatever reason then we should act as if we didn't find any `format`'d\n // schemas.\n return [];\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { oasToHarOptions } from './lib/types.cjs';
|
|
2
1
|
import { Request } from 'har-format';
|
|
3
2
|
import Oas from 'oas';
|
|
3
|
+
import { oasToHarOptions } from './lib/types.cjs';
|
|
4
4
|
import { Operation } from 'oas/operation';
|
|
5
5
|
import { DataForHAR, AuthForHAR } from 'oas/types';
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
configureSecurity
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QZNQX2VW.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import { parse as parseDataUrl } from "@readme/data-urls";
|
|
@@ -14,7 +14,7 @@ import removeUndefinedObjects from "remove-undefined-objects";
|
|
|
14
14
|
function get(object, path) {
|
|
15
15
|
if (!path) return void 0;
|
|
16
16
|
const pathArray = String(path).match(/([^[.\]])+/g);
|
|
17
|
-
const result = pathArray?.reduce((prevObj, key) => prevObj
|
|
17
|
+
const result = pathArray?.reduce((prevObj, key) => prevObj?.[key], object);
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
20
|
function set(object, path, value) {
|
|
@@ -375,7 +375,6 @@ function stylizeValue(value, parameter) {
|
|
|
375
375
|
}
|
|
376
376
|
function handleDeepObject(value, parameter) {
|
|
377
377
|
return qs.stringify(value, {
|
|
378
|
-
// eslint-disable-next-line consistent-return
|
|
379
378
|
encoder(str, defaultEncoder, charset, type) {
|
|
380
379
|
if (type === "key") {
|
|
381
380
|
const prefixedKey = str.split(/[[\]]/g).filter(Boolean).map((k) => `[${k}]`).join("");
|
|
@@ -506,7 +505,7 @@ function getTypedFormatsInSchema(format, schema, opts) {
|
|
|
506
505
|
if (!subschemas) {
|
|
507
506
|
return false;
|
|
508
507
|
}
|
|
509
|
-
return subschemas.
|
|
508
|
+
return subschemas.flatMap(({ key, schema: subschema }) => {
|
|
510
509
|
if ("properties" in subschema) {
|
|
511
510
|
return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });
|
|
512
511
|
} else if ("items" in subschema) {
|
|
@@ -524,7 +523,7 @@ function getTypedFormatsInSchema(format, schema, opts) {
|
|
|
524
523
|
});
|
|
525
524
|
}
|
|
526
525
|
return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });
|
|
527
|
-
}).
|
|
526
|
+
}).filter(Boolean);
|
|
528
527
|
} catch (err) {
|
|
529
528
|
return [];
|
|
530
529
|
}
|
|
@@ -587,7 +586,7 @@ var defaultFormDataTypes = Object.keys(jsonSchemaTypes).reduce((prev, curr) => {
|
|
|
587
586
|
}, {});
|
|
588
587
|
function getResponseContentType(content) {
|
|
589
588
|
const types = Object.keys(content) || [];
|
|
590
|
-
if (types
|
|
589
|
+
if (types?.length) {
|
|
591
590
|
const jsonType = types.find((t) => matchesMimeType.json(t));
|
|
592
591
|
if (jsonType) {
|
|
593
592
|
return jsonType;
|
|
@@ -695,15 +694,15 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
695
694
|
}
|
|
696
695
|
return formatter(formData, parameter, "path");
|
|
697
696
|
});
|
|
698
|
-
const queryStrings = parameters
|
|
699
|
-
if (queryStrings
|
|
697
|
+
const queryStrings = parameters?.filter((param) => param.in === "query");
|
|
698
|
+
if (queryStrings?.length) {
|
|
700
699
|
queryStrings.forEach((queryString) => {
|
|
701
700
|
const value = formatter(formData, queryString, "query", true);
|
|
702
701
|
appendHarValue(har.queryString, queryString.name, value);
|
|
703
702
|
});
|
|
704
703
|
}
|
|
705
|
-
const cookies = parameters
|
|
706
|
-
if (cookies
|
|
704
|
+
const cookies = parameters?.filter((param) => param.in === "cookie");
|
|
705
|
+
if (cookies?.length) {
|
|
707
706
|
cookies.forEach((cookie) => {
|
|
708
707
|
const value = formatter(formData, cookie, "cookie", true);
|
|
709
708
|
appendHarValue(har.cookies, cookie.name, value);
|
|
@@ -724,8 +723,8 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
724
723
|
}
|
|
725
724
|
let hasContentType = false;
|
|
726
725
|
let contentType = operation.getContentType();
|
|
727
|
-
const headers = parameters
|
|
728
|
-
if (headers
|
|
726
|
+
const headers = parameters?.filter((param) => param.in === "header");
|
|
727
|
+
if (headers?.length) {
|
|
729
728
|
headers.forEach((header) => {
|
|
730
729
|
const value = formatter(formData, header, "header", true);
|
|
731
730
|
if (typeof value === "undefined") return;
|
|
@@ -771,7 +770,7 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
771
770
|
return payload.type === (operation.isFormUrlEncoded() ? "formData" : "body");
|
|
772
771
|
});
|
|
773
772
|
}
|
|
774
|
-
if (requestBody
|
|
773
|
+
if (requestBody?.schema && Object.keys(requestBody.schema).length) {
|
|
775
774
|
const requestBodySchema = requestBody.schema;
|
|
776
775
|
if (operation.isFormUrlEncoded()) {
|
|
777
776
|
if (Object.keys(formData.formData || {}).length) {
|
|
@@ -870,14 +869,14 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
870
869
|
}
|
|
871
870
|
}
|
|
872
871
|
}
|
|
873
|
-
if ((har.postData?.text || requestBody
|
|
872
|
+
if ((har.postData?.text || requestBody?.schema && Object.keys(requestBody.schema).length) && !hasContentType) {
|
|
874
873
|
har.headers.push({
|
|
875
874
|
name: "content-type",
|
|
876
875
|
value: contentType
|
|
877
876
|
});
|
|
878
877
|
}
|
|
879
878
|
const securityRequirements = operation.getSecurity();
|
|
880
|
-
if (securityRequirements
|
|
879
|
+
if (securityRequirements?.length) {
|
|
881
880
|
securityRequirements.forEach((schemes) => {
|
|
882
881
|
Object.keys(schemes).forEach((security) => {
|
|
883
882
|
const securityValue = configureSecurity(apiDefinition, auth, security);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/lib/lodash.ts","../src/lib/style-formatting/index.ts","../src/lib/style-formatting/style-serializer.ts","../src/lib/utils.ts"],"sourcesContent":["import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\nimport type { PostData, PostDataParams, Request } from 'har-format';\nimport type Oas from 'oas';\nimport type { Extensions } from 'oas/extensions';\nimport type { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n ServerVariable,\n} from 'oas/types';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport { HEADERS, PROXY_ENABLED } from 'oas/extensions';\nimport { Operation } from 'oas/operation';\nimport { isRef } from 'oas/types';\nimport { jsonSchemaTypes, matchesMimeType } from 'oas/utils';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport configureSecurity from './lib/configure-security.js';\nimport { get, set } from './lib/lodash.js';\nimport formatStyle from './lib/style-formatting/index.js';\nimport { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils.js';\n\nfunction formatter(\n values: DataForHAR,\n param: ParameterObject,\n type: 'body' | 'cookie' | 'header' | 'path' | 'query',\n onlyIfExists = false,\n) {\n if (param.style) {\n const value = values[type][param.name];\n // Note: Technically we could send everything through the format style and choose the proper\n // default for each `in` type (e.g. query defaults to form).\n return formatStyle(value, param);\n }\n\n let value;\n\n // Handle missing values\n if (typeof values[type][param.name] !== 'undefined') {\n value = values[type][param.name];\n } else if (onlyIfExists && !param.required) {\n value = undefined;\n } else if (param.required && param.schema && !isRef(param.schema) && param.schema.default) {\n value = param.schema.default;\n } else if (type === 'path') {\n // If we don't have any values for the path parameter, just use the name of the parameter as the\n // value so we don't try try to build a URL to something like `https://example.com/undefined`.\n return param.name;\n }\n\n // Handle file uploads. Specifically arrays of file uploads which need to be formatted very\n // specifically.\n if (\n param.schema &&\n !isRef(param.schema) &&\n param.schema.type === 'array' &&\n param.schema.items &&\n !isRef(param.schema.items) &&\n param.schema.items.format === 'binary'\n ) {\n if (Array.isArray(value)) {\n // If this is array of binary data then we shouldn't do anything because we'll prepare them\n // separately in the HAR in order to preserve `fileName` and `contentType` data within\n // `postData.params`. If we don't then the HAR we generate for this data will be invalid.\n return value;\n }\n\n return JSON.stringify(value);\n }\n\n if (value !== undefined) {\n // Query params should always be formatted, even if they don't have a `style` serialization\n // configured.\n if (type === 'query') {\n return formatStyle(value, param);\n }\n\n return value;\n }\n\n return undefined;\n}\n\nfunction multipartBodyToFormatterParams(payload: unknown, oasMediaTypeObject: MediaTypeObject, schema: SchemaObject) {\n const encoding = oasMediaTypeObject.encoding;\n\n if (typeof payload === 'object' && payload !== null) {\n return Object.keys(payload)\n .map(key => {\n // If we have an incoming parameter, but it's not in the schema ignore it.\n if (!schema.properties?.[key]) {\n return false;\n }\n\n const paramEncoding = encoding ? encoding[key] : undefined;\n\n return {\n name: key,\n // If the style isn't defined, use the default\n style: paramEncoding ? paramEncoding.style : undefined,\n // If explode isn't defined, use the default\n explode: paramEncoding ? paramEncoding.explode : undefined,\n required:\n (schema.required && typeof schema.required === 'boolean' && Boolean(schema.required)) ||\n (Array.isArray(schema.required) && schema.required.includes(key)),\n schema: schema.properties[key],\n in: 'body',\n };\n })\n .filter(Boolean) as ParameterObject[];\n }\n\n // Pretty sure that we'll never have anything but an object for multipart bodies, so returning\n // empty array if we get anything else.\n return [];\n}\n\nconst defaultFormDataTypes = Object.keys(jsonSchemaTypes).reduce((prev, curr) => {\n return Object.assign(prev, { [curr]: {} });\n}, {});\n\nfunction getResponseContentType(content: MediaTypeObject) {\n const types = Object.keys(content) || [];\n\n // If this response content has multiple types available we should always prefer the one that's\n // JSON-compatible. If they don't have one that is we'll return the first available, otherwise\n // if they don't have **any** repsonse content types present we'll assume it's JSON.\n if (types && types.length) {\n const jsonType = types.find(t => matchesMimeType.json(t));\n if (jsonType) {\n return jsonType;\n }\n\n return types[0];\n }\n\n return 'application/json';\n}\n\nfunction isPrimitive(val: unknown) {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n\nfunction stringify(json: Record<string | 'RAW_BODY', unknown>) {\n return JSON.stringify(removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json));\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return param;\n } else if (Array.isArray(param) && param.every(isPrimitive)) {\n return String(param);\n }\n\n return JSON.stringify(param);\n}\n\nfunction appendHarValue(\n harParam: PostDataParams['params'] | Request['cookies'] | Request['headers'] | Request['queryString'],\n name: string,\n value: any,\n addtlData: {\n contentType?: string;\n fileName?: string;\n } = {},\n) {\n if (typeof value === 'undefined') return;\n\n if (Array.isArray(value)) {\n // If the formatter gives us an array, we're expected to add each array value as a new\n // parameter item with the same parameter name\n value.forEach(singleValue => {\n appendHarValue(harParam, name, singleValue);\n });\n } else if (typeof value === 'object' && value !== null) {\n // If the formatter gives us an object, we're expected to add each property value as a new\n // parameter item, each with the name of the property\n Object.keys(value).forEach(key => {\n appendHarValue(harParam, key, value[key]);\n });\n } else {\n // If the formatter gives us a non-array, non-object, we add it as is\n harParam.push({\n ...addtlData,\n name,\n value: String(value),\n });\n }\n}\n\nfunction encodeBodyForHAR(body: any) {\n if (isPrimitive(body)) {\n return body;\n } else if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n typeof body.RAW_BODY !== 'undefined'\n ) {\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload as a\n // raw string. https://docs.readme.com/docs/raw-body-content\n if (isPrimitive(body.RAW_BODY)) {\n return body.RAW_BODY;\n }\n\n return stringify(body.RAW_BODY);\n }\n\n return stringify(body);\n}\n\nexport default function oasToHar(\n oas: Oas,\n operationSchema?: Operation,\n values: DataForHAR = {},\n auth: AuthForHAR = {},\n opts: oasToHarOptions = { proxyUrl: '' },\n): {\n log: {\n entries: readonly [\n {\n readonly request: Request;\n },\n ];\n };\n} {\n let operation: Operation;\n if (!operationSchema || typeof operationSchema.getParameters !== 'function') {\n /**\n * If `operationSchema` was supplied as a plain object instead of an instance of `Operation`\n * then we should create a new instance of it. We're doing it with a check on `getParameters`\n * instead of checking `instanceof Operation` because JS is very weird when it comes to\n * checking `instanceof` against classes. One instance of `Operation` may not always match up\n * with another if they're being loaded between two different libraries.\n *\n * It's weird. This is easier.\n */\n operation = new Operation(\n oas as unknown as OASDocument,\n operationSchema?.path || '',\n operationSchema?.method || ('' as HttpMethods),\n (operationSchema as unknown as OperationObject) || { path: '', method: '' },\n );\n } else {\n operation = operationSchema;\n }\n\n const apiDefinition = oas.getDefinition();\n\n const formData: DataForHAR = {\n ...defaultFormDataTypes,\n ...values,\n };\n\n if (!formData.server) {\n formData.server = {\n selected: 0,\n variables: oas.defaultVariables(0),\n };\n }\n\n // If the incoming `server.variables` is missing variables let's pad it out with defaults.\n formData.server.variables = {\n ...oas.defaultVariables(formData.server.selected),\n ...(formData.server.variables ? formData.server.variables : {}),\n };\n\n const har: Request = {\n cookies: [],\n headers: [],\n headersSize: 0,\n queryString: [],\n // @ts-expect-error This is fine because we're fleshing `postData` out further down.\n postData: {},\n bodySize: 0,\n method: operation.method.toUpperCase(),\n url: `${oas.url(formData.server.selected, formData.server.variables as ServerVariable)}${operation.path}`.replace(\n /\\s/g,\n '%20',\n ),\n httpVersion: 'HTTP/1.1',\n };\n\n if (opts.proxyUrl) {\n if (oas.getExtension(PROXY_ENABLED, operation)) {\n har.url = `${opts.proxyUrl}/${har.url}`;\n }\n }\n\n const parameters = operation.getParameters();\n\n har.url = har.url.replace(/{([-_a-zA-Z0-9[\\]]+)}/g, (full, key) => {\n if (!operation || !parameters) return key; // No path params at all\n\n // Find the path parameter or set a default value if it does not exist\n const parameter = parameters.find(param => param.name === key) || ({ name: key } as ParameterObject);\n\n // The library that handles our style processing already encodes uri elements. For everything\n // else we need to handle it here.\n if (!('style' in parameter) || !parameter.style) {\n return encodeURIComponent(formatter(formData, parameter, 'path'));\n }\n\n return formatter(formData, parameter, 'path');\n });\n\n const queryStrings = parameters && parameters.filter(param => param.in === 'query');\n if (queryStrings && queryStrings.length) {\n queryStrings.forEach(queryString => {\n const value = formatter(formData, queryString, 'query', true);\n appendHarValue(har.queryString, queryString.name, value);\n });\n }\n\n // Do we have any `cookie` parameters on the operation?\n const cookies = parameters && parameters.filter(param => param.in === 'cookie');\n if (cookies && cookies.length) {\n cookies.forEach(cookie => {\n const value = formatter(formData, cookie, 'cookie', true);\n appendHarValue(har.cookies, cookie.name, value);\n });\n }\n\n // Does this response have any documented content types?\n if (operation.schema.responses) {\n Object.keys(operation.schema.responses).some(response => {\n if (isRef(operation.schema.responses?.[response])) return false;\n\n const content = (operation.schema.responses?.[response] as ResponseObject).content;\n if (!content) return false;\n\n // If there's no `accept` header present we should add one so their eventual code snippet\n // follows best practices.\n if (Object.keys(formData.header || {}).find(h => h.toLowerCase() === 'accept')) return true;\n\n har.headers.push({\n name: 'accept',\n value: getResponseContentType(content),\n });\n\n return true;\n });\n }\n\n // Do we have any `header` parameters on the operation?\n let hasContentType = false;\n let contentType = operation.getContentType();\n const headers = parameters && parameters.filter(param => param.in === 'header');\n if (headers && headers.length) {\n headers.forEach(header => {\n const value = formatter(formData, header, 'header', true);\n if (typeof value === 'undefined') return;\n\n if (header.name.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(value);\n }\n\n appendHarValue(har.headers, header.name, value);\n });\n }\n\n // Are there `x-headers` static headers configured for this OAS?\n const userDefinedHeaders = oas.getExtension(HEADERS, operation) as Extensions['headers'];\n if (userDefinedHeaders) {\n userDefinedHeaders.forEach(header => {\n if (typeof header.key === 'string' && header.key.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(header.value);\n }\n\n har.headers.push({\n name: String(header.key),\n value: String(header.value),\n });\n });\n }\n\n if (formData.header) {\n // Do we have an `accept` header set up in the form data, but it hasn't been added yet?\n const acceptHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'accept');\n if (acceptHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'accept')) {\n har.headers.push({\n name: 'accept',\n value: String(formData.header[acceptHeader]),\n });\n }\n\n // Do we have a manually-defined `authorization` header set up in the form data?\n const authorizationHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'authorization');\n if (authorizationHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'authorization')) {\n har.headers.push({\n name: 'authorization',\n value: String(formData.header[authorizationHeader]),\n });\n }\n }\n\n let requestBody: SchemaWrapper | undefined;\n if (operation.hasRequestBody()) {\n requestBody = operation.getParametersAsJSONSchema().find(payload => {\n // `formData` is used in our API Explorer for `application/x-www-form-urlencoded` endpoints\n // and if you have an operation with that, it will only ever have a `formData`. `body` is\n // used for all other payload shapes.\n return payload.type === (operation.isFormUrlEncoded() ? 'formData' : 'body');\n });\n }\n\n if (requestBody && requestBody.schema && Object.keys(requestBody.schema).length) {\n const requestBodySchema = requestBody.schema as SchemaObject;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n // eslint-disable-next-line try-catch-failsafe/json-parse\n const cleanFormData = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.formData)));\n if (cleanFormData !== undefined) {\n const postData: PostData = { params: [], mimeType: 'application/x-www-form-urlencoded' };\n\n Object.keys(cleanFormData).forEach(name => {\n postData.params.push({\n name,\n value: stringifyParameter(cleanFormData[name]),\n });\n });\n\n har.postData = postData;\n }\n }\n } else if (\n 'body' in formData &&\n formData.body !== undefined &&\n (isPrimitive(formData.body) || Object.keys(formData.body).length)\n ) {\n const isMultipart = operation.isMultipart();\n const isJSON = operation.isJson();\n\n if (isMultipart || isJSON) {\n try {\n let cleanBody = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.body)));\n\n if (isMultipart) {\n har.postData = { params: [], mimeType: 'multipart/form-data' };\n\n // Because some request body schema shapes might not always be a top-level `properties`,\n // instead nesting it in an `oneOf` or `anyOf` we need to extract the first usable\n // schema that we have in order to process this multipart payload.\n const safeBodySchema = getSafeRequestBody(requestBodySchema);\n\n /**\n * Discover all `{ type: string, format: binary }` properties, or arrays containing the\n * same, within the request body. If there are any, then that means that we're dealing\n * with a `multipart/form-data` request and need to treat the payload as\n * `postData.params` and supply filenames and content types for the files (if they're\n * available).\n *\n * @todo It'd be nice to replace this with `getTypedFormatsInSchema` instead.\n * @example `{ type: string, format: binary }`\n * @example `{ type: array, items: { type: string, format: binary } }`\n */\n const binaryTypes = Object.keys(safeBodySchema.properties).filter(key => {\n const propData = safeBodySchema.properties[key] as JSONSchema;\n if (propData.format === 'binary') {\n return true;\n } else if (\n propData.type === 'array' &&\n propData.items &&\n typeof propData.items === 'object' &&\n propData.items !== null &&\n (propData.items as JSONSchema).format === 'binary'\n ) {\n return true;\n }\n\n return false;\n });\n\n if (cleanBody !== undefined) {\n const multipartParams = multipartBodyToFormatterParams(\n formData.body,\n (operation.schema.requestBody as RequestBodyObject).content['multipart/form-data'],\n safeBodySchema,\n );\n\n if (multipartParams.length) {\n Object.keys(cleanBody).forEach(name => {\n const param = multipartParams.find(multipartParam => multipartParam.name === name);\n\n if (param) {\n // If we're dealing with a binary type, and the value is a valid data URL we should\n // parse out any available filename and content type to send along with the\n // parameter to interpreters like `fetch-har` can make sense of it and send a usable\n // payload.\n const addtlData: { contentType?: string; fileName?: string } = {};\n\n let value = formatter(formData, param, 'body', true);\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n value.forEach((val: string) => {\n if (binaryTypes.includes(name)) {\n const parsed = parseDataUrl(val);\n if (parsed) {\n addtlData.fileName = 'name' in parsed ? parsed.name : 'unknown';\n if ('contentType' in parsed) {\n addtlData.contentType = parsed.contentType;\n }\n }\n }\n\n appendHarValue(har.postData?.params || [], name, val, addtlData);\n });\n }\n });\n }\n }\n } else {\n har.postData = { mimeType: contentType, text: '' };\n\n if (\n hasSchemaType(requestBody.schema, 'string') ||\n hasSchemaType(requestBody.schema, 'integer') ||\n hasSchemaType(requestBody.schema, 'number') ||\n hasSchemaType(requestBody.schema, 'boolean')\n ) {\n har.postData.text = JSON.stringify(JSON.parse(cleanBody));\n } else {\n /**\n * Handle formatted JSON objects that have properties that accept arbitrary JSON.\n *\n * Find all `{ type: string, format: json }` properties in the schema because we need\n * to manually `JSON.parse` them before submit, otherwise they'll be escaped instead\n * of actual objects. We also only want values that the user has entered, so we drop\n * any `undefined` `cleanBody` keys.\n */\n const jsonTypes = getTypedFormatsInSchema('json', requestBodySchema.properties, { payload: cleanBody });\n\n if (Array.isArray(jsonTypes) && jsonTypes.length) {\n try {\n jsonTypes.forEach((prop: boolean | string) => {\n try {\n set(cleanBody, String(prop), JSON.parse(get(cleanBody, String(prop))));\n } catch (e) {\n // leave the prop as a string value\n }\n });\n\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload\n // as a raw string. https://docs.readme.com/docs/raw-body-content\n if (typeof cleanBody.RAW_BODY !== 'undefined') {\n cleanBody = cleanBody.RAW_BODY;\n }\n\n har.postData.text = JSON.stringify(cleanBody);\n } catch (e) {\n har.postData.text = stringify(formData.body);\n }\n } else {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n } catch (e) {\n // If anything above fails for whatever reason, assume that whatever we had is invalid\n // JSON and just treat it as raw text.\n har.postData = { mimeType: contentType, text: stringify(formData.body) };\n }\n } else {\n har.postData = { mimeType: contentType, text: encodeBodyForHAR(formData.body) };\n }\n }\n }\n\n // Add a `content-type` header if there are any body values setup above or if there is a schema\n // defined, but only do so if we don't already have a `content-type` present as it's impossible\n // for a request to have multiple.\n if (\n (har.postData?.text || (requestBody && requestBody.schema && Object.keys(requestBody.schema).length)) &&\n !hasContentType\n ) {\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\n const securityRequirements = operation.getSecurity();\n\n if (securityRequirements && securityRequirements.length) {\n // TODO pass these values through the formatter?\n securityRequirements.forEach(schemes => {\n Object.keys(schemes).forEach(security => {\n const securityValue = configureSecurity(apiDefinition, auth, security);\n if (!securityValue) {\n return;\n }\n\n // If this is an `authorization` header and we've already added one (maybe one was manually\n // specified), then we shouldn't add another.\n if (securityValue.value.name === 'authorization') {\n if (har[securityValue.type].find(v => v.name === securityValue.value.name)) {\n return;\n }\n }\n\n // If we've already added this **specific** security value then don't add it again.\n if (\n har[securityValue.type].find(\n v => v.name === securityValue.value.name && v.value === securityValue.value.value,\n )\n ) {\n return;\n }\n\n har[securityValue.type].push(securityValue.value);\n });\n });\n }\n\n // If we didn't end up filling the `postData` object then we don't need it.\n if (Object.keys(har.postData || {}).length === 0) {\n delete har.postData;\n }\n\n return {\n log: {\n entries: [\n {\n request: har,\n },\n ] as const,\n },\n };\n}\n","type Many<T> = T | readonly T[];\ntype PropertyName = number | string | symbol;\ntype PropertyPath = Many<PropertyName>;\n\n/**\n * A janky, poorly typed replacement for `lodash.get`.\n *\n * @see {@link https://youmightnotneed.com/lodash#get}\n */\nexport function get(object: unknown, path?: string): any {\n // If path is not defined or it has false value\n if (!path) return undefined;\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n // Regex explained: https://regexr.com/58j0k\n const pathArray = String(path).match(/([^[.\\]])+/g);\n // Find value\n // @ts-expect-error idk man\n const result = pathArray?.reduce((prevObj, key) => prevObj && prevObj[key], object);\n // If found value is undefined return default value; otherwise return the value\n return result;\n}\n\n/**\n * A janky, poorly typed replacement for `lodash.set`.\n *\n * @see {@link https://youmightnotneed.com/lodash#set}\n */\nexport function set<TResult>(object: object, path: PropertyPath, value: any): TResult {\n // Regex explained: https://regexr.com/58j0k\n const pathArray: PropertyPath | RegExpMatchArray | null = Array.isArray(path)\n ? path\n : String(path).match(/([^[.\\]])+/g);\n\n // @ts-expect-error idk man\n return pathArray?.reduce((acc, key, i) => {\n // @ts-expect-error idk man\n if (acc[key] === undefined) {\n // @ts-expect-error idk man\n acc[key] = {};\n }\n if (i === pathArray.length - 1) {\n // @ts-expect-error idk man\n acc[key] = value;\n }\n // @ts-expect-error idk man\n return acc[key];\n }, object);\n}\n","import type { StylizerConfig } from './style-serializer.js';\nimport type { ParameterObject, SchemaObject } from 'oas/types';\n\nimport qs from 'qs';\n\nimport { stylize } from './style-serializer.js';\n\n// Certain styles don't support empty values.\nfunction shouldNotStyleEmptyValues(parameter: ParameterObject) {\n return ['simple', 'spaceDelimited', 'pipeDelimited', 'deepObject'].includes(parameter.style || '');\n}\n\nfunction shouldNotStyleReservedHeader(parameter: ParameterObject) {\n return ['accept', 'authorization', 'content-type'].includes(parameter.name.toLowerCase());\n}\n\n/**\n * Note: This isn't necessarily part of the spec. Behavior for the value 'undefined' is, well,\n * undefined. This code makes our system look better. If we wanted to be more accurate, we might\n * want to remove this, restore the un-fixed behavior for undefined and have our UI pass in empty\n * string instead of undefined.\n */\nfunction removeUndefinedForPath(value: any) {\n let finalValue = value;\n\n if (typeof finalValue === 'undefined') {\n return '';\n }\n\n if (Array.isArray(finalValue)) {\n finalValue = finalValue.filter(val => (val === undefined ? '' : val));\n\n if (finalValue.length === 0) {\n finalValue = '';\n }\n }\n\n if (typeof finalValue === 'object') {\n Object.keys(finalValue).forEach(key => {\n finalValue[key] = finalValue[key] === undefined ? '' : finalValue[key];\n });\n }\n\n return finalValue;\n}\n\nfunction stylizeValue(value: unknown, parameter: ParameterObject) {\n let finalValue = value;\n\n // Some styles don't work with empty values. We catch those there\n if (shouldNotStyleEmptyValues(parameter) && (typeof finalValue === 'undefined' || finalValue === '')) {\n // Paths need return an unstyled empty string instead of undefined so it's ignored in the final\n // path string.\n if (parameter.in === 'path') {\n return '';\n }\n\n // Everything but path should return undefined when unstyled so it's ignored in the final\n // parameter array.\n return undefined;\n }\n\n // Every style that adds their style to empty values should use emptystring for path parameters\n // instead of undefined to avoid the string `undefined`.\n if (parameter.in === 'path') {\n finalValue = removeUndefinedForPath(finalValue);\n }\n\n /**\n * Eventhough `accept`, `authorization`, and `content-type` headers can be defined as parameters,\n * they should be completely ignored when it comes to serialization.\n *\n * > If `in` is \"header\" and the `name` field is \"Accept\", \"Content-Type\" or \"Authorization\", the\n * > parameter definition SHALL be ignored.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10}\n */\n if (parameter.in === 'header' && shouldNotStyleReservedHeader(parameter)) {\n return value;\n }\n\n /**\n * All parameter types have a default `style` format so if they don't have one prescribed we\n * should still conform to what the spec defines.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterstyle}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterstyle}\n */\n let style = parameter.style;\n if (!style) {\n if (parameter.in === 'query') {\n style = 'form';\n } else if (parameter.in === 'path') {\n style = 'simple';\n } else if (parameter.in === 'header') {\n style = 'simple';\n } else if (parameter.in === 'cookie') {\n style = 'form';\n }\n }\n\n let explode = parameter.explode;\n if (explode === undefined && style === 'form') {\n /**\n * Per the spec if no `explode` is present but `style` is `form` then `explode` should default to `true`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterexplode}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterexplode}\n */\n explode = true;\n }\n\n return stylize({\n location: parameter.in as StylizerConfig['location'],\n value: finalValue,\n key: parameter.name,\n style: style as StylizerConfig['style'],\n explode,\n /**\n * @todo this parameter is optional to stylize. It defaults to false, and can accept falsy, truthy, or \"unsafe\".\n * I do not know if it is correct for query to use this. See style-serializer for more info\n */\n escape: true,\n ...(parameter.in === 'query' ? { isAllowedReserved: parameter.allowReserved || false } : {}),\n });\n}\n\nfunction handleDeepObject(value: any, parameter: ParameterObject) {\n return qs\n .stringify(value, {\n // eslint-disable-next-line consistent-return\n encoder(str, defaultEncoder, charset, type) {\n if (type === 'key') {\n // `str` will be here as `dog[treats][0]` but because the `qs` library doesn't have any\n // awareness of our OpenAPI parameters we need to rewrite it to slap the `parameter.name`\n // to the top, like `pets[dog][treats][0]`.\n const prefixedKey = str\n .split(/[[\\]]/g)\n .filter(Boolean)\n .map((k: string) => `[${k}]`)\n .join('');\n\n return `${parameter.name}${prefixedKey}`;\n } else if (type === 'value') {\n return stylizeValue(str, parameter);\n }\n },\n })\n .split('&')\n .map(item => {\n const split = item.split('=');\n return {\n label: split[0],\n // `qs` will coerce null values into being `undefined` string but we want to preserve them.\n value: split[1] === 'undefined' ? null : split[1],\n };\n });\n}\n\n// Explode is handled on its own, because style-serializer doesn't return what we expect for proper\n// HAR output.\nfunction handleExplode(value: any, parameter: ParameterObject) {\n // This is to handle the case of arrays of objects in the querystring\n // which is something that's not technically in the spec but since we're\n // using the `qs` module already, it's fairly easy for us to add support\n // for this use case.\n //\n // An example URL would be something like this:\n // https://example.com/?line_items[0][a_string]=abc&line_items[0][quantity]=1&line_items[1][a_string]=def&line_items[1][quantity]=2\n //\n // Some open issues discussing this here:\n // https://github.com/OAI/OpenAPI-Specification/issues/1706\n // https://github.com/OAI/OpenAPI-Specification/issues/1006\n //\n // Link to the spec for this:\n // https://github.com/OAI/OpenAPI-Specification/blob/36a3a67264cc1c4f1eff110cea3ebfe679435108/versions/3.1.0.md#style-examples\n if (\n Array.isArray(value) &&\n (parameter.schema as SchemaObject)?.type === 'array' &&\n parameter.style === 'deepObject'\n ) {\n const newObj: Record<string, unknown> = {};\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n return newObj;\n }\n\n if (Array.isArray(value)) {\n return value.map(val => {\n return stylizeValue(val, parameter);\n });\n }\n\n if (typeof value === 'object' && value !== null) {\n const newObj: Record<string, unknown> = {};\n\n Object.keys(value).forEach(key => {\n if (parameter.style === 'deepObject') {\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n } else {\n newObj[key] = stylizeValue(value[key], parameter);\n }\n });\n\n return newObj;\n }\n\n return stylizeValue(value, parameter);\n}\n\nfunction shouldExplode(parameter: ParameterObject) {\n return (\n (parameter.explode ||\n (parameter.explode !== false && parameter.style === 'form') ||\n // style: deepObject && explode: false doesn't exist so explode it always\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples\n parameter.style === 'deepObject') &&\n // header and path doesn't explode into separate parameters like query and cookie do\n parameter.in !== 'header' &&\n parameter.in !== 'path'\n );\n}\n\nexport default function formatStyle(value: unknown, parameter: ParameterObject): any {\n // Deep object style only works on objects and arrays, and only works with explode=true.\n if (parameter.style === 'deepObject' && (!value || typeof value !== 'object' || parameter.explode === false)) {\n return undefined;\n }\n\n // This custom explode logic allows us to bubble up arrays and objects to be handled differently\n // by our HAR transformer. We need this because the `stylizeValue` function assumes we're building\n // strings, not richer data types.\n //\n // The first part of this conditional checks if `explode` is enabled. Explode is disabled for\n // everything by default except for forms.\n //\n // The second part of this conditional bypasses the custom explode logic for headers, because they\n // work differently, and `stylizeValue` is accurate.\n if (shouldExplode(parameter)) {\n return handleExplode(value, parameter);\n }\n\n return stylizeValue(value, parameter);\n}\n","/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable no-param-reassign */\n\n/**\n * This file has been extracted and modified from `swagger-client`.\n *\n * @license Apache 2.0\n * @link https://npm.im/swagger-client\n * @link https://github.com/swagger-api/swagger-js/blob/master/src/execute/oas3/style-serializer.js\n */\n\nconst isRfc3986Reserved = (char: string) => \":/?#[]@!$&'()*+,;=\".indexOf(char) > -1;\nconst isRfc3986Unreserved = (char: string) => /^[a-z0-9\\-._~]+$/i.test(char);\n\nfunction isURIEncoded(value: string) {\n try {\n return decodeURIComponent(value) !== value;\n } catch (err) {\n // `decodeURIComponent` will throw an exception if a string that has an un-encoded percent sign\n // in it (like 20%), o if it's throwing we can just assume that the value hasn't been encoded.\n return false;\n }\n}\n\nfunction isObject(value: unknown) {\n return typeof value === 'object' && value !== null;\n}\n\nfunction encodeDisallowedCharacters(\n str: string,\n {\n escape,\n returnIfEncoded = false,\n isAllowedReserved,\n }: {\n escape?: boolean | 'unsafe';\n isAllowedReserved?: boolean;\n returnIfEncoded?: boolean;\n } = {},\n parse?: boolean,\n): any {\n if (typeof str === 'number') {\n str = (str as number).toString();\n }\n\n if (returnIfEncoded) {\n if (isURIEncoded(str)) {\n return str;\n }\n }\n\n if (typeof str !== 'string' || !str.length) {\n return str;\n }\n\n if (!escape) {\n return str;\n }\n\n if (parse) {\n // eslint-disable-next-line try-catch-failsafe/json-parse\n return JSON.parse(str);\n }\n\n // In ES6 you can do this quite easily by using the new ... spread operator. This causes the\n // string iterator (another new ES6 feature) to be used internally, and because that iterator is\n // designed to deal with code points rather than UCS-2/UTF-16 code units.\n return [...str]\n .map(char => {\n if (isRfc3986Unreserved(char)) {\n return char;\n }\n\n if (isRfc3986Reserved(char) && (escape === 'unsafe' || isAllowedReserved)) {\n return char;\n }\n\n const encoder = new TextEncoder();\n const encoded = Array.from(encoder.encode(char))\n .map(byte => `0${byte.toString(16).toUpperCase()}`.slice(-2))\n .map(encodedByte => `%${encodedByte}`)\n .join('');\n\n return encoded;\n })\n .join('');\n}\n\nexport interface StylizerConfig {\n escape: boolean | 'unsafe';\n explode?: boolean;\n isAllowedReserved?: boolean;\n key: string;\n location: 'body' | 'query';\n style: 'deepObject' | 'form' | 'label' | 'matrix' | 'pipeDelimited' | 'simple' | 'spaceDelimited';\n value: any;\n}\n\nexport function stylize(config: StylizerConfig): any {\n const { value } = config;\n\n if (Array.isArray(value)) {\n return encodeArray(config);\n }\n\n if (isObject(value)) {\n return encodeObject(config);\n }\n\n return encodePrimitive(config);\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeArray({\n location,\n key,\n value,\n style,\n explode,\n escape,\n isAllowedReserved = false,\n}: Omit<StylizerConfig, 'value'> & { value: string[] }) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue,black,brown`\n */\n case 'simple':\n return value.map(val => valueEncoder(val)).join(',');\n\n /**\n * @example <caption>`style: label`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `.blue.black.brown`\n */\n case 'label':\n return `.${value.map(val => valueEncoder(val)).join('.')}`;\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue;color=black;color=brown`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue,black,brown\t`\n */\n case 'matrix':\n return value\n .map(val => valueEncoder(val))\n .reduce((prev, curr) => {\n if (!prev || explode) {\n return `${prev || ''};${key}=${curr}`;\n }\n return `${prev},${curr}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue&color=black&color=brown`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue,black,brown`\n */\n case 'form':\n return value.map(val => valueEncoder(val)).join(explode ? `&${key}=` : ',');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue%20black%20brown`\n */\n case 'spaceDelimited':\n return value.map(val => valueEncoder(val)).join(` ${explode ? `${key}=` : ''}`);\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue|black|brown`\n */\n case 'pipeDelimited':\n return value.map(val => valueEncoder(val)).join(`|${explode ? `${key}=` : ''}`);\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeObject({ location, key, value, style, explode, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n const valueKeys = Object.keys(value);\n\n switch (style) {\n /**\n * @example <caption>`style: simple` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100,G=200,B=150`\n *\n * @example <caption>`style: simple` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R,100,G,200,B,150`\n */\n case 'simple':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : ',';\n const prefix = prev ? `${prev},` : '';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: label` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R=100.G=200.B=150`\n *\n * @example <caption>`style: label` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R.100.G.200.B.150`\n */\n case 'label':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : '.';\n const prefix = prev ? `${prev}.` : '.';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;R=100;G=200;B=150`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;color=R,100,G,200,B,150`\n */\n case 'matrix':\n if (explode) {\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev};` : ';';\n\n return `${prefix}${curr}=${val}`;\n }, '');\n }\n\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev},` : `;${key}=`;\n\n return `${prefix}${curr},${val}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100&G=200&B=150`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color=R,100,G,200,B,150`\n */\n case 'form':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';\n const separator = explode ? '=' : ',';\n\n return `${prefix}${curr}${separator}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R%20100%20G%20200%20B%20150`\n */\n case 'spaceDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev} ` : '';\n\n return `${prefix}${curr} ${val}`;\n }, '');\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R|100|G|200|B|150`\n */\n case 'pipeDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}|` : '';\n\n return `${prefix}${curr}|${val}`;\n }, '');\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color[R]=100&color[G]=200&color[B]=150`\n */\n case 'deepObject':\n return valueKeys.reduce(curr => {\n const val = valueEncoder(value[curr]);\n return `${val}`;\n }, '');\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodePrimitive({ location, key, value, style, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query' || location === 'body',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `blue` → `blue`\n */\n case 'simple':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: label`</caption>\n * `blue` → `.blue`\n */\n case 'label':\n return `.${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: matrix`</caption>\n * `blue` → `;color=blue`\n */\n case 'matrix':\n if (value === '') {\n return `;${key}`;\n }\n\n return `;${key}=${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: form`</caption>\n * `blue` → `color=blue`\n */\n case 'form':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `blue` → n/a\n */\n case 'deepObject':\n return valueEncoder(value);\n\n default:\n return undefined;\n }\n}\n","import type { JSONSchema, SchemaObject } from 'oas/types';\n\nimport { get } from './lodash.js';\n\n/**\n * Determine if a schema `type` is, or contains, a specific discriminator.\n *\n */\nexport function hasSchemaType(\n schema: SchemaObject,\n discriminator: 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string',\n): boolean {\n if (Array.isArray(schema.type)) {\n return schema.type.includes(discriminator);\n }\n\n return schema.type === discriminator;\n}\n\n/**\n * Because some request body schema shapes might not always be a top-level `properties`, instead\n * nesting it in an `oneOf` or `anyOf` we need to extract the first usable schema that we have. If\n * we don't do this then these non-conventional request body schema payloads may not be properly\n * represented in the HAR that we generate.\n *\n */\nexport function getSafeRequestBody(obj: any): any {\n if ('oneOf' in obj) {\n return getSafeRequestBody(obj.oneOf[0]);\n } else if ('anyOf' in obj) {\n return getSafeRequestBody(obj.anyOf[0]);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\nfunction getSubschemas(schema: any, opts: Options) {\n let subSchemaDataSize = 0;\n if (opts.parentIsArray) {\n // If we don't have data for this parent schema in our body payload then we\n // shouldn't bother spidering further into the schema looking for more `format`s\n // for data that definitely doesn't exist.\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData === undefined || !Array.isArray(parentData)) {\n return false;\n }\n\n subSchemaDataSize = parentData.length;\n }\n\n let subschemas: any[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n subschemas = subschemas.concat(\n Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, idx, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n })),\n );\n }\n } else {\n subschemas = Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n }));\n }\n\n return subschemas;\n}\n\n/**\n * With a supplied JSON Schema object, spider through it for any schemas that may contain specific\n * kind of `format` that also happen to be within the current `requestBody` payload that we're\n * creating a HAR representation for.\n *\n */\nexport function getTypedFormatsInSchema(\n format: 'binary' | 'json',\n schema: any,\n opts: Options,\n): (boolean | string)[] | boolean | string {\n try {\n if (schema?.format === format) {\n if (opts.parentIsArray) {\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData !== undefined && Array.isArray(parentData)) {\n return Object.keys(parentData)\n .map(pdk => {\n const currentKey = [opts.parentKey, pdk].join('.');\n if (get(opts.payload, currentKey) !== undefined) {\n return currentKey;\n }\n\n return false;\n })\n .filter(Boolean);\n }\n } else if (opts.parentKey && get(opts.payload, opts.parentKey) !== undefined) {\n return opts.parentKey;\n } else if (opts.payload !== undefined) {\n // If this payload is present and we're looking for a specific format then we should assume\n // that the **root** schema of the request body is that format, and we aren't trafficking in\n // a nested object or array schema.\n return true;\n }\n\n return false;\n }\n\n const subschemas = getSubschemas(schema, opts);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .map(({ key, schema: subschema }) => {\n if ('properties' in subschema) {\n return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });\n } else if ('items' in subschema) {\n if ((subschema.items as JSONSchema)?.properties) {\n return getTypedFormatsInSchema(format, (subschema.items as JSONSchema).properties, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n return getTypedFormatsInSchema(format, subschema.items, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n // If this schema has neither `properties` or `items` then it's a regular schema\n // we can re-run.\n return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });\n })\n .flat()\n .filter(Boolean);\n } catch (err) {\n // If this fails for whatever reason then we should act as if we didn't find any `format`'d\n // schemas.\n return [];\n }\n}\n"],"mappings":";;;;;AAkBA,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,qBAAqB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,iBAAiB,uBAAuB;AACjD,OAAO,4BAA4B;;;ACd5B,SAAS,IAAI,QAAiB,MAAoB;AAEvD,MAAI,CAAC,KAAM,QAAO;AAGlB,QAAM,YAAY,OAAO,IAAI,EAAE,MAAM,aAAa;AAGlD,QAAM,SAAS,WAAW,OAAO,CAAC,SAAS,QAAQ,WAA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YACE,IAAI,cAAc,IAAI,EAAE;AAAA,UACtB,OAAK,EAAE,SAAS,cAAc,MAAM,QAAQ,EAAE,UAAU,cAAc,MAAM;AAAA,QAC9E,GACA;AACA;AAAA,QACF;AAEA,YAAI,cAAc,IAAI,EAAE,KAAK,cAAc,KAAK;AAAA,MAClD,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAGA,MAAI,OAAO,KAAK,IAAI,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG;AAChD,WAAO,IAAI;AAAA,EACb;AAEA,SAAO;AAAA,IACL,KAAK;AAAA,MACH,SAAS;AAAA,QACP;AAAA,UACE,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["value"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/lodash.ts","../src/lib/style-formatting/index.ts","../src/lib/style-formatting/style-serializer.ts","../src/lib/utils.ts"],"sourcesContent":["import type { PostData, PostDataParams, Request } from 'har-format';\nimport type Oas from 'oas';\nimport type { Extensions } from 'oas/extensions';\nimport type { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n ServerVariable,\n} from 'oas/types';\nimport type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport { HEADERS, PROXY_ENABLED } from 'oas/extensions';\nimport { Operation } from 'oas/operation';\nimport { isRef } from 'oas/types';\nimport { jsonSchemaTypes, matchesMimeType } from 'oas/utils';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport configureSecurity from './lib/configure-security.js';\nimport { get, set } from './lib/lodash.js';\nimport formatStyle from './lib/style-formatting/index.js';\nimport { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils.js';\n\nfunction formatter(\n values: DataForHAR,\n param: ParameterObject,\n type: 'body' | 'cookie' | 'header' | 'path' | 'query',\n onlyIfExists = false,\n) {\n if (param.style) {\n const value = values[type][param.name];\n // Note: Technically we could send everything through the format style and choose the proper\n // default for each `in` type (e.g. query defaults to form).\n return formatStyle(value, param);\n }\n\n let value: string | number | boolean | undefined;\n\n // Handle missing values\n if (typeof values[type][param.name] !== 'undefined') {\n value = values[type][param.name];\n } else if (onlyIfExists && !param.required) {\n value = undefined;\n } else if (param.required && param.schema && !isRef(param.schema) && param.schema.default) {\n value = param.schema.default;\n } else if (type === 'path') {\n // If we don't have any values for the path parameter, just use the name of the parameter as the\n // value so we don't try try to build a URL to something like `https://example.com/undefined`.\n return param.name;\n }\n\n // Handle file uploads. Specifically arrays of file uploads which need to be formatted very\n // specifically.\n if (\n param.schema &&\n !isRef(param.schema) &&\n param.schema.type === 'array' &&\n param.schema.items &&\n !isRef(param.schema.items) &&\n param.schema.items.format === 'binary'\n ) {\n if (Array.isArray(value)) {\n // If this is array of binary data then we shouldn't do anything because we'll prepare them\n // separately in the HAR in order to preserve `fileName` and `contentType` data within\n // `postData.params`. If we don't then the HAR we generate for this data will be invalid.\n return value;\n }\n\n return JSON.stringify(value);\n }\n\n if (value !== undefined) {\n // Query params should always be formatted, even if they don't have a `style` serialization\n // configured.\n if (type === 'query') {\n return formatStyle(value, param);\n }\n\n return value;\n }\n\n return undefined;\n}\n\nfunction multipartBodyToFormatterParams(payload: unknown, oasMediaTypeObject: MediaTypeObject, schema: SchemaObject) {\n const encoding = oasMediaTypeObject.encoding;\n\n if (typeof payload === 'object' && payload !== null) {\n return Object.keys(payload)\n .map(key => {\n // If we have an incoming parameter, but it's not in the schema ignore it.\n if (!schema.properties?.[key]) {\n return false;\n }\n\n const paramEncoding = encoding ? encoding[key] : undefined;\n\n return {\n name: key,\n // If the style isn't defined, use the default\n style: paramEncoding ? paramEncoding.style : undefined,\n // If explode isn't defined, use the default\n explode: paramEncoding ? paramEncoding.explode : undefined,\n required:\n (schema.required && typeof schema.required === 'boolean' && Boolean(schema.required)) ||\n (Array.isArray(schema.required) && schema.required.includes(key)),\n schema: schema.properties[key],\n in: 'body',\n };\n })\n .filter(Boolean) as ParameterObject[];\n }\n\n // Pretty sure that we'll never have anything but an object for multipart bodies, so returning\n // empty array if we get anything else.\n return [];\n}\n\nconst defaultFormDataTypes = Object.keys(jsonSchemaTypes).reduce((prev, curr) => {\n return Object.assign(prev, { [curr]: {} });\n}, {});\n\nfunction getResponseContentType(content: MediaTypeObject) {\n const types = Object.keys(content) || [];\n\n // If this response content has multiple types available we should always prefer the one that's\n // JSON-compatible. If they don't have one that is we'll return the first available, otherwise\n // if they don't have **any** repsonse content types present we'll assume it's JSON.\n if (types?.length) {\n const jsonType = types.find(t => matchesMimeType.json(t));\n if (jsonType) {\n return jsonType;\n }\n\n return types[0];\n }\n\n return 'application/json';\n}\n\nfunction isPrimitive(val: unknown) {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n\nfunction stringify(json: Record<string | 'RAW_BODY', unknown>) {\n return JSON.stringify(removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json));\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return param;\n } else if (Array.isArray(param) && param.every(isPrimitive)) {\n return String(param);\n }\n\n return JSON.stringify(param);\n}\n\nfunction appendHarValue(\n harParam: PostDataParams['params'] | Request['cookies'] | Request['headers'] | Request['queryString'],\n name: string,\n value: any,\n addtlData: {\n contentType?: string;\n fileName?: string;\n } = {},\n) {\n if (typeof value === 'undefined') return;\n\n if (Array.isArray(value)) {\n // If the formatter gives us an array, we're expected to add each array value as a new\n // parameter item with the same parameter name\n value.forEach(singleValue => {\n appendHarValue(harParam, name, singleValue);\n });\n } else if (typeof value === 'object' && value !== null) {\n // If the formatter gives us an object, we're expected to add each property value as a new\n // parameter item, each with the name of the property\n Object.keys(value).forEach(key => {\n appendHarValue(harParam, key, value[key]);\n });\n } else {\n // If the formatter gives us a non-array, non-object, we add it as is\n harParam.push({\n ...addtlData,\n name,\n value: String(value),\n });\n }\n}\n\nfunction encodeBodyForHAR(body: any) {\n if (isPrimitive(body)) {\n return body;\n } else if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n typeof body.RAW_BODY !== 'undefined'\n ) {\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload as a\n // raw string. https://docs.readme.com/docs/raw-body-content\n if (isPrimitive(body.RAW_BODY)) {\n return body.RAW_BODY;\n }\n\n return stringify(body.RAW_BODY);\n }\n\n return stringify(body);\n}\n\nexport default function oasToHar(\n oas: Oas,\n operationSchema?: Operation,\n values: DataForHAR = {},\n auth: AuthForHAR = {},\n opts: oasToHarOptions = { proxyUrl: '' },\n): {\n log: {\n entries: readonly [\n {\n readonly request: Request;\n },\n ];\n };\n} {\n let operation: Operation;\n if (!operationSchema || typeof operationSchema.getParameters !== 'function') {\n /**\n * If `operationSchema` was supplied as a plain object instead of an instance of `Operation`\n * then we should create a new instance of it. We're doing it with a check on `getParameters`\n * instead of checking `instanceof Operation` because JS is very weird when it comes to\n * checking `instanceof` against classes. One instance of `Operation` may not always match up\n * with another if they're being loaded between two different libraries.\n *\n * It's weird. This is easier.\n */\n operation = new Operation(\n oas as unknown as OASDocument,\n operationSchema?.path || '',\n operationSchema?.method || ('' as HttpMethods),\n (operationSchema as unknown as OperationObject) || { path: '', method: '' },\n );\n } else {\n operation = operationSchema;\n }\n\n const apiDefinition = oas.getDefinition();\n\n const formData: DataForHAR = {\n ...defaultFormDataTypes,\n ...values,\n };\n\n if (!formData.server) {\n formData.server = {\n selected: 0,\n variables: oas.defaultVariables(0),\n };\n }\n\n // If the incoming `server.variables` is missing variables let's pad it out with defaults.\n formData.server.variables = {\n ...oas.defaultVariables(formData.server.selected),\n ...(formData.server.variables ? formData.server.variables : {}),\n };\n\n const har: Request = {\n cookies: [],\n headers: [],\n headersSize: 0,\n queryString: [],\n // @ts-expect-error This is fine because we're fleshing `postData` out further down.\n postData: {},\n bodySize: 0,\n method: operation.method.toUpperCase(),\n url: `${oas.url(formData.server.selected, formData.server.variables as ServerVariable)}${operation.path}`.replace(\n /\\s/g,\n '%20',\n ),\n httpVersion: 'HTTP/1.1',\n };\n\n if (opts.proxyUrl) {\n if (oas.getExtension(PROXY_ENABLED, operation)) {\n har.url = `${opts.proxyUrl}/${har.url}`;\n }\n }\n\n const parameters = operation.getParameters();\n\n har.url = har.url.replace(/{([-_a-zA-Z0-9[\\]]+)}/g, (full, key) => {\n if (!operation || !parameters) return key; // No path params at all\n\n // Find the path parameter or set a default value if it does not exist\n const parameter = parameters.find(param => param.name === key) || ({ name: key } as ParameterObject);\n\n // The library that handles our style processing already encodes uri elements. For everything\n // else we need to handle it here.\n if (!('style' in parameter) || !parameter.style) {\n return encodeURIComponent(formatter(formData, parameter, 'path'));\n }\n\n return formatter(formData, parameter, 'path');\n });\n\n const queryStrings = parameters?.filter(param => param.in === 'query');\n if (queryStrings?.length) {\n queryStrings.forEach(queryString => {\n const value = formatter(formData, queryString, 'query', true);\n appendHarValue(har.queryString, queryString.name, value);\n });\n }\n\n // Do we have any `cookie` parameters on the operation?\n const cookies = parameters?.filter(param => param.in === 'cookie');\n if (cookies?.length) {\n cookies.forEach(cookie => {\n const value = formatter(formData, cookie, 'cookie', true);\n appendHarValue(har.cookies, cookie.name, value);\n });\n }\n\n // Does this response have any documented content types?\n if (operation.schema.responses) {\n Object.keys(operation.schema.responses).some(response => {\n if (isRef(operation.schema.responses?.[response])) return false;\n\n const content = (operation.schema.responses?.[response] as ResponseObject).content;\n if (!content) return false;\n\n // If there's no `accept` header present we should add one so their eventual code snippet\n // follows best practices.\n if (Object.keys(formData.header || {}).find(h => h.toLowerCase() === 'accept')) return true;\n\n har.headers.push({\n name: 'accept',\n value: getResponseContentType(content),\n });\n\n return true;\n });\n }\n\n // Do we have any `header` parameters on the operation?\n let hasContentType = false;\n let contentType = operation.getContentType();\n const headers = parameters?.filter(param => param.in === 'header');\n if (headers?.length) {\n headers.forEach(header => {\n const value = formatter(formData, header, 'header', true);\n if (typeof value === 'undefined') return;\n\n if (header.name.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(value);\n }\n\n appendHarValue(har.headers, header.name, value);\n });\n }\n\n // Are there `x-headers` static headers configured for this OAS?\n const userDefinedHeaders = oas.getExtension(HEADERS, operation) as Extensions['headers'];\n if (userDefinedHeaders) {\n userDefinedHeaders.forEach(header => {\n if (typeof header.key === 'string' && header.key.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(header.value);\n }\n\n har.headers.push({\n name: String(header.key),\n value: String(header.value),\n });\n });\n }\n\n if (formData.header) {\n // Do we have an `accept` header set up in the form data, but it hasn't been added yet?\n const acceptHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'accept');\n if (acceptHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'accept')) {\n har.headers.push({\n name: 'accept',\n value: String(formData.header[acceptHeader]),\n });\n }\n\n // Do we have a manually-defined `authorization` header set up in the form data?\n const authorizationHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'authorization');\n if (authorizationHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'authorization')) {\n har.headers.push({\n name: 'authorization',\n value: String(formData.header[authorizationHeader]),\n });\n }\n }\n\n let requestBody: SchemaWrapper | undefined;\n if (operation.hasRequestBody()) {\n requestBody = operation.getParametersAsJSONSchema().find(payload => {\n // `formData` is used in our API Explorer for `application/x-www-form-urlencoded` endpoints\n // and if you have an operation with that, it will only ever have a `formData`. `body` is\n // used for all other payload shapes.\n return payload.type === (operation.isFormUrlEncoded() ? 'formData' : 'body');\n });\n }\n\n if (requestBody?.schema && Object.keys(requestBody.schema).length) {\n const requestBodySchema = requestBody.schema as SchemaObject;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.formData)));\n if (cleanFormData !== undefined) {\n const postData: PostData = { params: [], mimeType: 'application/x-www-form-urlencoded' };\n\n Object.keys(cleanFormData).forEach(name => {\n postData.params.push({\n name,\n value: stringifyParameter(cleanFormData[name]),\n });\n });\n\n har.postData = postData;\n }\n }\n } else if (\n 'body' in formData &&\n formData.body !== undefined &&\n (isPrimitive(formData.body) || Object.keys(formData.body).length)\n ) {\n const isMultipart = operation.isMultipart();\n const isJSON = operation.isJson();\n\n if (isMultipart || isJSON) {\n try {\n let cleanBody = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.body)));\n\n if (isMultipart) {\n har.postData = { params: [], mimeType: 'multipart/form-data' };\n\n // Because some request body schema shapes might not always be a top-level `properties`,\n // instead nesting it in an `oneOf` or `anyOf` we need to extract the first usable\n // schema that we have in order to process this multipart payload.\n const safeBodySchema = getSafeRequestBody(requestBodySchema);\n\n /**\n * Discover all `{ type: string, format: binary }` properties, or arrays containing the\n * same, within the request body. If there are any, then that means that we're dealing\n * with a `multipart/form-data` request and need to treat the payload as\n * `postData.params` and supply filenames and content types for the files (if they're\n * available).\n *\n * @todo It'd be nice to replace this with `getTypedFormatsInSchema` instead.\n * @example `{ type: string, format: binary }`\n * @example `{ type: array, items: { type: string, format: binary } }`\n */\n const binaryTypes = Object.keys(safeBodySchema.properties).filter(key => {\n const propData = safeBodySchema.properties[key] as JSONSchema;\n if (propData.format === 'binary') {\n return true;\n } else if (\n propData.type === 'array' &&\n propData.items &&\n typeof propData.items === 'object' &&\n propData.items !== null &&\n (propData.items as JSONSchema).format === 'binary'\n ) {\n return true;\n }\n\n return false;\n });\n\n if (cleanBody !== undefined) {\n const multipartParams = multipartBodyToFormatterParams(\n formData.body,\n (operation.schema.requestBody as RequestBodyObject).content['multipart/form-data'],\n safeBodySchema,\n );\n\n if (multipartParams.length) {\n Object.keys(cleanBody).forEach(name => {\n const param = multipartParams.find(multipartParam => multipartParam.name === name);\n\n if (param) {\n // If we're dealing with a binary type, and the value is a valid data URL we should\n // parse out any available filename and content type to send along with the\n // parameter to interpreters like `fetch-har` can make sense of it and send a usable\n // payload.\n const addtlData: { contentType?: string; fileName?: string } = {};\n\n let value = formatter(formData, param, 'body', true);\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n value.forEach((val: string) => {\n if (binaryTypes.includes(name)) {\n const parsed = parseDataUrl(val);\n if (parsed) {\n addtlData.fileName = 'name' in parsed ? parsed.name : 'unknown';\n if ('contentType' in parsed) {\n addtlData.contentType = parsed.contentType;\n }\n }\n }\n\n appendHarValue(har.postData?.params || [], name, val, addtlData);\n });\n }\n });\n }\n }\n } else {\n har.postData = { mimeType: contentType, text: '' };\n\n if (\n hasSchemaType(requestBody.schema, 'string') ||\n hasSchemaType(requestBody.schema, 'integer') ||\n hasSchemaType(requestBody.schema, 'number') ||\n hasSchemaType(requestBody.schema, 'boolean')\n ) {\n har.postData.text = JSON.stringify(JSON.parse(cleanBody));\n } else {\n /**\n * Handle formatted JSON objects that have properties that accept arbitrary JSON.\n *\n * Find all `{ type: string, format: json }` properties in the schema because we need\n * to manually `JSON.parse` them before submit, otherwise they'll be escaped instead\n * of actual objects. We also only want values that the user has entered, so we drop\n * any `undefined` `cleanBody` keys.\n */\n const jsonTypes = getTypedFormatsInSchema('json', requestBodySchema.properties, { payload: cleanBody });\n\n if (Array.isArray(jsonTypes) && jsonTypes.length) {\n try {\n jsonTypes.forEach((prop: boolean | string) => {\n try {\n set(cleanBody, String(prop), JSON.parse(get(cleanBody, String(prop))));\n } catch (e) {\n // leave the prop as a string value\n }\n });\n\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload\n // as a raw string. https://docs.readme.com/docs/raw-body-content\n if (typeof cleanBody.RAW_BODY !== 'undefined') {\n cleanBody = cleanBody.RAW_BODY;\n }\n\n har.postData.text = JSON.stringify(cleanBody);\n } catch (e) {\n har.postData.text = stringify(formData.body);\n }\n } else {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n } catch (e) {\n // If anything above fails for whatever reason, assume that whatever we had is invalid\n // JSON and just treat it as raw text.\n har.postData = { mimeType: contentType, text: stringify(formData.body) };\n }\n } else {\n har.postData = { mimeType: contentType, text: encodeBodyForHAR(formData.body) };\n }\n }\n }\n\n // Add a `content-type` header if there are any body values setup above or if there is a schema\n // defined, but only do so if we don't already have a `content-type` present as it's impossible\n // for a request to have multiple.\n if ((har.postData?.text || (requestBody?.schema && Object.keys(requestBody.schema).length)) && !hasContentType) {\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\n const securityRequirements = operation.getSecurity();\n\n if (securityRequirements?.length) {\n // TODO pass these values through the formatter?\n securityRequirements.forEach(schemes => {\n Object.keys(schemes).forEach(security => {\n const securityValue = configureSecurity(apiDefinition, auth, security);\n if (!securityValue) {\n return;\n }\n\n // If this is an `authorization` header and we've already added one (maybe one was manually\n // specified), then we shouldn't add another.\n if (securityValue.value.name === 'authorization') {\n if (har[securityValue.type].find(v => v.name === securityValue.value.name)) {\n return;\n }\n }\n\n // If we've already added this **specific** security value then don't add it again.\n if (\n har[securityValue.type].find(\n v => v.name === securityValue.value.name && v.value === securityValue.value.value,\n )\n ) {\n return;\n }\n\n har[securityValue.type].push(securityValue.value);\n });\n });\n }\n\n // If we didn't end up filling the `postData` object then we don't need it.\n if (Object.keys(har.postData || {}).length === 0) {\n delete har.postData;\n }\n\n return {\n log: {\n entries: [\n {\n request: har,\n },\n ] as const,\n },\n };\n}\n","type Many<T> = T | readonly T[];\ntype PropertyName = number | string | symbol;\ntype PropertyPath = Many<PropertyName>;\n\n/**\n * A janky, poorly typed replacement for `lodash.get`.\n *\n * @see {@link https://youmightnotneed.com/lodash#get}\n */\nexport function get(object: unknown, path?: string): any {\n // If path is not defined or it has false value\n if (!path) return undefined;\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n // Regex explained: https://regexr.com/58j0k\n const pathArray = String(path).match(/([^[.\\]])+/g);\n // Find value\n // @ts-expect-error idk man\n const result = pathArray?.reduce((prevObj, key) => prevObj?.[key], object);\n // If found value is undefined return default value; otherwise return the value\n return result;\n}\n\n/**\n * A janky, poorly typed replacement for `lodash.set`.\n *\n * @see {@link https://youmightnotneed.com/lodash#set}\n */\nexport function set<TResult>(object: object, path: PropertyPath, value: any): TResult {\n // Regex explained: https://regexr.com/58j0k\n const pathArray: PropertyPath | RegExpMatchArray | null = Array.isArray(path)\n ? path\n : String(path).match(/([^[.\\]])+/g);\n\n // @ts-expect-error idk man\n return pathArray?.reduce((acc, key, i) => {\n // @ts-expect-error idk man\n if (acc[key] === undefined) {\n // @ts-expect-error idk man\n acc[key] = {};\n }\n if (i === pathArray.length - 1) {\n // @ts-expect-error idk man\n acc[key] = value;\n }\n // @ts-expect-error idk man\n return acc[key];\n }, object);\n}\n","import type { ParameterObject, SchemaObject } from 'oas/types';\nimport type { StylizerConfig } from './style-serializer.js';\n\nimport qs from 'qs';\n\nimport { stylize } from './style-serializer.js';\n\n// Certain styles don't support empty values.\nfunction shouldNotStyleEmptyValues(parameter: ParameterObject) {\n return ['simple', 'spaceDelimited', 'pipeDelimited', 'deepObject'].includes(parameter.style || '');\n}\n\nfunction shouldNotStyleReservedHeader(parameter: ParameterObject) {\n return ['accept', 'authorization', 'content-type'].includes(parameter.name.toLowerCase());\n}\n\n/**\n * Note: This isn't necessarily part of the spec. Behavior for the value 'undefined' is, well,\n * undefined. This code makes our system look better. If we wanted to be more accurate, we might\n * want to remove this, restore the un-fixed behavior for undefined and have our UI pass in empty\n * string instead of undefined.\n */\nfunction removeUndefinedForPath(value: any) {\n let finalValue = value;\n\n if (typeof finalValue === 'undefined') {\n return '';\n }\n\n if (Array.isArray(finalValue)) {\n finalValue = finalValue.filter(val => (val === undefined ? '' : val));\n\n if (finalValue.length === 0) {\n finalValue = '';\n }\n }\n\n if (typeof finalValue === 'object') {\n Object.keys(finalValue).forEach(key => {\n finalValue[key] = finalValue[key] === undefined ? '' : finalValue[key];\n });\n }\n\n return finalValue;\n}\n\nfunction stylizeValue(value: unknown, parameter: ParameterObject) {\n let finalValue = value;\n\n // Some styles don't work with empty values. We catch those there\n if (shouldNotStyleEmptyValues(parameter) && (typeof finalValue === 'undefined' || finalValue === '')) {\n // Paths need return an unstyled empty string instead of undefined so it's ignored in the final\n // path string.\n if (parameter.in === 'path') {\n return '';\n }\n\n // Everything but path should return undefined when unstyled so it's ignored in the final\n // parameter array.\n return undefined;\n }\n\n // Every style that adds their style to empty values should use emptystring for path parameters\n // instead of undefined to avoid the string `undefined`.\n if (parameter.in === 'path') {\n finalValue = removeUndefinedForPath(finalValue);\n }\n\n /**\n * Eventhough `accept`, `authorization`, and `content-type` headers can be defined as parameters,\n * they should be completely ignored when it comes to serialization.\n *\n * > If `in` is \"header\" and the `name` field is \"Accept\", \"Content-Type\" or \"Authorization\", the\n * > parameter definition SHALL be ignored.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10}\n */\n if (parameter.in === 'header' && shouldNotStyleReservedHeader(parameter)) {\n return value;\n }\n\n /**\n * All parameter types have a default `style` format so if they don't have one prescribed we\n * should still conform to what the spec defines.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterstyle}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterstyle}\n */\n let style = parameter.style;\n if (!style) {\n if (parameter.in === 'query') {\n style = 'form';\n } else if (parameter.in === 'path') {\n style = 'simple';\n } else if (parameter.in === 'header') {\n style = 'simple';\n } else if (parameter.in === 'cookie') {\n style = 'form';\n }\n }\n\n let explode = parameter.explode;\n if (explode === undefined && style === 'form') {\n /**\n * Per the spec if no `explode` is present but `style` is `form` then `explode` should default to `true`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterexplode}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterexplode}\n */\n explode = true;\n }\n\n return stylize({\n location: parameter.in as StylizerConfig['location'],\n value: finalValue,\n key: parameter.name,\n style: style as StylizerConfig['style'],\n explode,\n /**\n * @todo this parameter is optional to stylize. It defaults to false, and can accept falsy, truthy, or \"unsafe\".\n * I do not know if it is correct for query to use this. See style-serializer for more info\n */\n escape: true,\n ...(parameter.in === 'query' ? { isAllowedReserved: parameter.allowReserved || false } : {}),\n });\n}\n\nfunction handleDeepObject(value: any, parameter: ParameterObject) {\n return qs\n .stringify(value, {\n encoder(str, defaultEncoder, charset, type) {\n if (type === 'key') {\n // `str` will be here as `dog[treats][0]` but because the `qs` library doesn't have any\n // awareness of our OpenAPI parameters we need to rewrite it to slap the `parameter.name`\n // to the top, like `pets[dog][treats][0]`.\n const prefixedKey = str\n .split(/[[\\]]/g)\n .filter(Boolean)\n .map((k: string) => `[${k}]`)\n .join('');\n\n return `${parameter.name}${prefixedKey}`;\n } else if (type === 'value') {\n return stylizeValue(str, parameter);\n }\n },\n })\n .split('&')\n .map(item => {\n const split = item.split('=');\n return {\n label: split[0],\n // `qs` will coerce null values into being `undefined` string but we want to preserve them.\n value: split[1] === 'undefined' ? null : split[1],\n };\n });\n}\n\n// Explode is handled on its own, because style-serializer doesn't return what we expect for proper\n// HAR output.\nfunction handleExplode(value: any, parameter: ParameterObject) {\n // This is to handle the case of arrays of objects in the querystring\n // which is something that's not technically in the spec but since we're\n // using the `qs` module already, it's fairly easy for us to add support\n // for this use case.\n //\n // An example URL would be something like this:\n // https://example.com/?line_items[0][a_string]=abc&line_items[0][quantity]=1&line_items[1][a_string]=def&line_items[1][quantity]=2\n //\n // Some open issues discussing this here:\n // https://github.com/OAI/OpenAPI-Specification/issues/1706\n // https://github.com/OAI/OpenAPI-Specification/issues/1006\n //\n // Link to the spec for this:\n // https://github.com/OAI/OpenAPI-Specification/blob/36a3a67264cc1c4f1eff110cea3ebfe679435108/versions/3.1.0.md#style-examples\n if (\n Array.isArray(value) &&\n (parameter.schema as SchemaObject)?.type === 'array' &&\n parameter.style === 'deepObject'\n ) {\n const newObj: Record<string, unknown> = {};\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n return newObj;\n }\n\n if (Array.isArray(value)) {\n return value.map(val => {\n return stylizeValue(val, parameter);\n });\n }\n\n if (typeof value === 'object' && value !== null) {\n const newObj: Record<string, unknown> = {};\n\n Object.keys(value).forEach(key => {\n if (parameter.style === 'deepObject') {\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n } else {\n newObj[key] = stylizeValue(value[key], parameter);\n }\n });\n\n return newObj;\n }\n\n return stylizeValue(value, parameter);\n}\n\nfunction shouldExplode(parameter: ParameterObject) {\n return (\n (parameter.explode ||\n (parameter.explode !== false && parameter.style === 'form') ||\n // style: deepObject && explode: false doesn't exist so explode it always\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples\n parameter.style === 'deepObject') &&\n // header and path doesn't explode into separate parameters like query and cookie do\n parameter.in !== 'header' &&\n parameter.in !== 'path'\n );\n}\n\nexport default function formatStyle(value: unknown, parameter: ParameterObject): any {\n // Deep object style only works on objects and arrays, and only works with explode=true.\n if (parameter.style === 'deepObject' && (!value || typeof value !== 'object' || parameter.explode === false)) {\n return undefined;\n }\n\n // This custom explode logic allows us to bubble up arrays and objects to be handled differently\n // by our HAR transformer. We need this because the `stylizeValue` function assumes we're building\n // strings, not richer data types.\n //\n // The first part of this conditional checks if `explode` is enabled. Explode is disabled for\n // everything by default except for forms.\n //\n // The second part of this conditional bypasses the custom explode logic for headers, because they\n // work differently, and `stylizeValue` is accurate.\n if (shouldExplode(parameter)) {\n return handleExplode(value, parameter);\n }\n\n return stylizeValue(value, parameter);\n}\n","/**\n * This file has been extracted and modified from `swagger-client`.\n *\n * @license Apache 2.0\n * @link https://npm.im/swagger-client\n * @link https://github.com/swagger-api/swagger-js/blob/master/src/execute/oas3/style-serializer.js\n */\n\nconst isRfc3986Reserved = (char: string) => \":/?#[]@!$&'()*+,;=\".indexOf(char) > -1;\nconst isRfc3986Unreserved = (char: string) => /^[a-z0-9\\-._~]+$/i.test(char);\n\nfunction isURIEncoded(value: string) {\n try {\n return decodeURIComponent(value) !== value;\n } catch (err) {\n // `decodeURIComponent` will throw an exception if a string that has an un-encoded percent sign\n // in it (like 20%), o if it's throwing we can just assume that the value hasn't been encoded.\n return false;\n }\n}\n\nfunction isObject(value: unknown) {\n return typeof value === 'object' && value !== null;\n}\n\nfunction encodeDisallowedCharacters(\n str: string,\n {\n escape,\n returnIfEncoded = false,\n isAllowedReserved,\n }: {\n escape?: boolean | 'unsafe';\n isAllowedReserved?: boolean;\n returnIfEncoded?: boolean;\n } = {},\n parse?: boolean,\n): any {\n if (typeof str === 'number') {\n // biome-ignore lint/style/noParameterAssign: It is what it is.\n str = (str as number).toString();\n }\n\n if (returnIfEncoded) {\n if (isURIEncoded(str)) {\n return str;\n }\n }\n\n if (typeof str !== 'string' || !str.length) {\n return str;\n }\n\n if (!escape) {\n return str;\n }\n\n if (parse) {\n return JSON.parse(str);\n }\n\n // In ES6 you can do this quite easily by using the new ... spread operator. This causes the\n // string iterator (another new ES6 feature) to be used internally, and because that iterator is\n // designed to deal with code points rather than UCS-2/UTF-16 code units.\n return [...str]\n .map(char => {\n if (isRfc3986Unreserved(char)) {\n return char;\n }\n\n if (isRfc3986Reserved(char) && (escape === 'unsafe' || isAllowedReserved)) {\n return char;\n }\n\n const encoder = new TextEncoder();\n const encoded = Array.from(encoder.encode(char))\n .map(byte => `0${byte.toString(16).toUpperCase()}`.slice(-2))\n .map(encodedByte => `%${encodedByte}`)\n .join('');\n\n return encoded;\n })\n .join('');\n}\n\nexport interface StylizerConfig {\n escape: boolean | 'unsafe';\n explode?: boolean;\n isAllowedReserved?: boolean;\n key: string;\n location: 'body' | 'query';\n style: 'deepObject' | 'form' | 'label' | 'matrix' | 'pipeDelimited' | 'simple' | 'spaceDelimited';\n value: any;\n}\n\nexport function stylize(config: StylizerConfig): any {\n const { value } = config;\n\n if (Array.isArray(value)) {\n return encodeArray(config);\n }\n\n if (isObject(value)) {\n return encodeObject(config);\n }\n\n return encodePrimitive(config);\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeArray({\n location,\n key,\n value,\n style,\n explode,\n escape,\n isAllowedReserved = false,\n}: Omit<StylizerConfig, 'value'> & { value: string[] }) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue,black,brown`\n */\n case 'simple':\n return value.map(val => valueEncoder(val)).join(',');\n\n /**\n * @example <caption>`style: label`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `.blue.black.brown`\n */\n case 'label':\n return `.${value.map(val => valueEncoder(val)).join('.')}`;\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue;color=black;color=brown`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `;color=blue,black,brown\t`\n */\n case 'matrix':\n return value\n .map(val => valueEncoder(val))\n .reduce((prev, curr) => {\n if (!prev || explode) {\n return `${prev || ''};${key}=${curr}`;\n }\n return `${prev},${curr}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue&color=black&color=brown`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `color=blue,black,brown`\n */\n case 'form':\n return value.map(val => valueEncoder(val)).join(explode ? `&${key}=` : ',');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue%20black%20brown`\n */\n case 'spaceDelimited':\n return value.map(val => valueEncoder(val)).join(` ${explode ? `${key}=` : ''}`);\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `[\"blue\",\"black\",\"brown\"]` → `blue|black|brown`\n */\n case 'pipeDelimited':\n return value.map(val => valueEncoder(val)).join(`|${explode ? `${key}=` : ''}`);\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeObject({ location, key, value, style, explode, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n const valueKeys = Object.keys(value);\n\n switch (style) {\n /**\n * @example <caption>`style: simple` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100,G=200,B=150`\n *\n * @example <caption>`style: simple` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R,100,G,200,B,150`\n */\n case 'simple':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : ',';\n const prefix = prev ? `${prev},` : '';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: label` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R=100.G=200.B=150`\n *\n * @example <caption>`style: label` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R.100.G.200.B.150`\n */\n case 'label':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : '.';\n const prefix = prev ? `${prev}.` : '.';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;R=100;G=200;B=150`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;color=R,100,G,200,B,150`\n */\n case 'matrix':\n if (explode) {\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev};` : ';';\n\n return `${prefix}${curr}=${val}`;\n }, '');\n }\n\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev},` : `;${key}=`;\n\n return `${prefix}${curr},${val}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100&G=200&B=150`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color=R,100,G,200,B,150`\n */\n case 'form':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';\n const separator = explode ? '=' : ',';\n\n return `${prefix}${curr}${separator}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R%20100%20G%20200%20B%20150`\n */\n case 'spaceDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev} ` : '';\n\n return `${prefix}${curr} ${val}`;\n }, '');\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R|100|G|200|B|150`\n */\n case 'pipeDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}|` : '';\n\n return `${prefix}${curr}|${val}`;\n }, '');\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color[R]=100&color[G]=200&color[B]=150`\n */\n case 'deepObject':\n return valueKeys.reduce(curr => {\n const val = valueEncoder(value[curr]);\n return `${val}`;\n }, '');\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodePrimitive({ location, key, value, style, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query' || location === 'body',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `blue` → `blue`\n */\n case 'simple':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: label`</caption>\n * `blue` → `.blue`\n */\n case 'label':\n return `.${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: matrix`</caption>\n * `blue` → `;color=blue`\n */\n case 'matrix':\n if (value === '') {\n return `;${key}`;\n }\n\n return `;${key}=${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: form`</caption>\n * `blue` → `color=blue`\n */\n case 'form':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `blue` → n/a\n */\n case 'deepObject':\n return valueEncoder(value);\n\n default:\n return undefined;\n }\n}\n","import type { JSONSchema, SchemaObject } from 'oas/types';\n\nimport { get } from './lodash.js';\n\n/**\n * Determine if a schema `type` is, or contains, a specific discriminator.\n *\n */\nexport function hasSchemaType(\n schema: SchemaObject,\n discriminator: 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string',\n): boolean {\n if (Array.isArray(schema.type)) {\n return schema.type.includes(discriminator);\n }\n\n return schema.type === discriminator;\n}\n\n/**\n * Because some request body schema shapes might not always be a top-level `properties`, instead\n * nesting it in an `oneOf` or `anyOf` we need to extract the first usable schema that we have. If\n * we don't do this then these non-conventional request body schema payloads may not be properly\n * represented in the HAR that we generate.\n *\n */\nexport function getSafeRequestBody(obj: any): any {\n if ('oneOf' in obj) {\n return getSafeRequestBody(obj.oneOf[0]);\n } else if ('anyOf' in obj) {\n return getSafeRequestBody(obj.anyOf[0]);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\nfunction getSubschemas(schema: any, opts: Options) {\n let subSchemaDataSize = 0;\n if (opts.parentIsArray) {\n // If we don't have data for this parent schema in our body payload then we\n // shouldn't bother spidering further into the schema looking for more `format`s\n // for data that definitely doesn't exist.\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData === undefined || !Array.isArray(parentData)) {\n return false;\n }\n\n subSchemaDataSize = parentData.length;\n }\n\n let subschemas: any[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n subschemas = subschemas.concat(\n Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, idx, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n })),\n );\n }\n } else {\n subschemas = Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n }));\n }\n\n return subschemas;\n}\n\n/**\n * With a supplied JSON Schema object, spider through it for any schemas that may contain specific\n * kind of `format` that also happen to be within the current `requestBody` payload that we're\n * creating a HAR representation for.\n *\n */\nexport function getTypedFormatsInSchema(\n format: 'binary' | 'json',\n schema: any,\n opts: Options,\n): (boolean | string)[] | boolean | string {\n try {\n if (schema?.format === format) {\n if (opts.parentIsArray) {\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData !== undefined && Array.isArray(parentData)) {\n return Object.keys(parentData)\n .map(pdk => {\n const currentKey = [opts.parentKey, pdk].join('.');\n if (get(opts.payload, currentKey) !== undefined) {\n return currentKey;\n }\n\n return false;\n })\n .filter(Boolean);\n }\n } else if (opts.parentKey && get(opts.payload, opts.parentKey) !== undefined) {\n return opts.parentKey;\n } else if (opts.payload !== undefined) {\n // If this payload is present and we're looking for a specific format then we should assume\n // that the **root** schema of the request body is that format, and we aren't trafficking in\n // a nested object or array schema.\n return true;\n }\n\n return false;\n }\n\n const subschemas = getSubschemas(schema, opts);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema }) => {\n if ('properties' in subschema) {\n return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });\n } else if ('items' in subschema) {\n if ((subschema.items as JSONSchema)?.properties) {\n return getTypedFormatsInSchema(format, (subschema.items as JSONSchema).properties, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n return getTypedFormatsInSchema(format, subschema.items, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n // If this schema has neither `properties` or `items` then it's a regular schema\n // we can re-run.\n return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });\n })\n .filter(Boolean);\n } catch (err) {\n // If this fails for whatever reason then we should act as if we didn't find any `format`'d\n // schemas.\n return [];\n }\n}\n"],"mappings":";;;;;AAkBA,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,qBAAqB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,iBAAiB,uBAAuB;AACjD,OAAO,4BAA4B;;;ACd5B,SAAS,IAAI,QAAiB,MAAoB;AAEvD,MAAI,CAAC,KAAM,QAAO;AAGlB,QAAM,YAAY,OAAO,IAAI,EAAE,MAAM,aAAa;AAGlD,QAAM,SAAS,WAAW,OAAO,CAAC,SAAS,QAAQ,UAAU,GAAG,GAAG,MAAM;AAEzE,SAAO;AACT;AAOO,SAAS,IAAa,QAAgB,MAAoB,OAAqB;AAEpF,QAAM,YAAoD,MAAM,QAAQ,IAAI,IACxE,OACA,OAAO,IAAI,EAAE,MAAM,aAAa;AAGpC,SAAO,WAAW,OAAO,CAAC,KAAK,KAAK,MAAM;AAExC,QAAI,IAAI,GAAG,MAAM,QAAW;AAE1B,UAAI,GAAG,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AAA,MACH,SAAS;AAAA,QACP;AAAA,UACE,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["value"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNZMKP35Vcjs = require('../chunk-NZMKP35V.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = _chunkNZMKP35Vcjs.configureSecurity;
|
|
7
7
|
|
|
8
8
|
module.exports = exports.default;
|
|
9
9
|
//# sourceMappingURL=configure-security.cjs.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readme/oas-to-har",
|
|
3
3
|
"description": "Utility to transform an OAS operation into a HAR representation",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "27.0.0",
|
|
5
5
|
"author": "Jon Ursenbach <jon@ursenba.ch>",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"scripts": {
|
|
42
42
|
"attw": "attw --pack --format ascii --profile node16",
|
|
43
43
|
"build": "tsup",
|
|
44
|
-
"lint": "npm run lint:types
|
|
45
|
-
"lint:js": "eslint . --ext .js,.ts --ignore-path ../../.gitignore",
|
|
44
|
+
"lint": "npm run lint:types",
|
|
46
45
|
"lint:types": "tsc --noEmit",
|
|
47
46
|
"prebuild": "rm -rf dist/",
|
|
48
47
|
"prepack": "npm run build",
|
|
@@ -50,18 +49,19 @@
|
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
52
51
|
"@readme/data-urls": "^3.0.0",
|
|
53
|
-
"oas": "^
|
|
52
|
+
"oas": "^28.0.0",
|
|
54
53
|
"qs": "^6.12.0",
|
|
55
54
|
"remove-undefined-objects": "^6.0.0"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@readme/oas-examples": "^6.1.
|
|
57
|
+
"@readme/oas-examples": "^6.1.4",
|
|
59
58
|
"@types/har-format": "^1.2.15",
|
|
60
59
|
"@types/qs": "^6.9.14",
|
|
61
|
-
"jest-expect-har": "^8.0.
|
|
60
|
+
"jest-expect-har": "^8.0.5",
|
|
61
|
+
"tsup": "^8.5.0",
|
|
62
62
|
"typescript": "^5.2.2",
|
|
63
63
|
"vitest": "^3.2.1"
|
|
64
64
|
},
|
|
65
|
-
"prettier": "@readme/
|
|
66
|
-
"gitHead": "
|
|
65
|
+
"prettier": "@readme/standards/prettier",
|
|
66
|
+
"gitHead": "ed83a8d1753b2a51f76b479f920fc6a78d328451"
|
|
67
67
|
}
|