@readme/oas-to-har 33.1.1 → 33.1.2

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/index.cjs CHANGED
@@ -266,6 +266,9 @@ function parseJSONStringsObjectContainersOnly(obj) {
266
266
  }
267
267
  return obj;
268
268
  }
269
+ function getAdditionalPropertiesSchema(schema) {
270
+ return schema.additionalProperties && typeof schema.additionalProperties === "object" ? schema.additionalProperties : void 0;
271
+ }
269
272
  function mergePropertiesFromAllOf(allOf, api, seenRefs) {
270
273
  const merged = {};
271
274
  let found = false;
@@ -403,13 +406,22 @@ function parseJSONStringsInBodyWithSchema(obj, schema, api, seenRefs = /* @__PUR
403
406
  return obj.map((item) => parseJSONStringsInBodyWithSchema(item, items, api, new Set(seenRefs)));
404
407
  }
405
408
  if (obj !== null && typeof obj === "object") {
409
+ const additionalPropertiesSchema = getAdditionalPropertiesSchema(resolved);
406
410
  if (!resolved.properties || typeof resolved.properties !== "object") {
411
+ if (additionalPropertiesSchema) {
412
+ const out2 = {};
413
+ for (const [k, v] of Object.entries(obj)) {
414
+ out2[k] = parseJSONStringsInBodyWithSchema(v, additionalPropertiesSchema, api, new Set(seenRefs));
415
+ }
416
+ return out2;
417
+ }
407
418
  return parseJSONStrings(obj);
408
419
  }
409
420
  const out = {};
410
421
  for (const [k, v] of Object.entries(obj)) {
411
422
  const propSchema = resolved.properties[k];
412
- out[k] = propSchema !== void 0 ? parseJSONStringsInBodyWithSchema(v, propSchema, api, new Set(seenRefs)) : parseJSONStringsObjectContainersOnly(v);
423
+ const schemaForValue = _nullishCoalesce(propSchema, () => ( additionalPropertiesSchema));
424
+ out[k] = schemaForValue !== void 0 ? parseJSONStringsInBodyWithSchema(v, schemaForValue, api, new Set(seenRefs)) : parseJSONStringsObjectContainersOnly(v);
413
425
  }
414
426
  return out;
415
427
  }
@@ -878,12 +890,19 @@ function multipartBodyToFormatterParams(payload, oasMediaTypeObject, schema) {
878
890
  return false;
879
891
  }
880
892
  const paramEncoding = encoding ? encoding[key] : void 0;
893
+ const propertySchema = schema.properties[key];
894
+ const isObjectSchema = typeof propertySchema === "object" && propertySchema !== null && !_types.isRef.call(void 0, propertySchema);
895
+ const hasObjectType = isObjectSchema && // OAS 3.1 uses JSON Schema union types, so object schemas can appear as
896
+ // `type: ['object', 'null']` or another union that includes `object`.
897
+ (Array.isArray(propertySchema.type) ? propertySchema.type.includes("object") : propertySchema.type === "object");
898
+ const hasObjectProperties = isObjectSchema && typeof propertySchema.properties === "object" && propertySchema.properties !== null;
899
+ const shouldDefaultNestedMultipartObject = !paramEncoding && (hasObjectType || hasObjectProperties);
881
900
  return {
882
901
  name: key,
883
- // If the style isn't defined, use the default
884
- style: paramEncoding ? paramEncoding.style : void 0,
885
- // If explode isn't defined, use the default
886
- explode: paramEncoding ? paramEncoding.explode : void 0,
902
+ // Preserve nested multipart object paths as form fields unless the spec supplies explicit
903
+ // encoding for this property.
904
+ style: paramEncoding ? paramEncoding.style : shouldDefaultNestedMultipartObject ? "deepObject" : void 0,
905
+ explode: paramEncoding ? paramEncoding.explode : shouldDefaultNestedMultipartObject ? true : void 0,
887
906
  required: schema.required && typeof schema.required === "boolean" && Boolean(schema.required) || Array.isArray(schema.required) && schema.required.includes(key),
888
907
  schema: schema.properties[key],
889
908
  in: "body"
@@ -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/utils.ts","../src/lib/style-formatting/style-serializer.ts"],"names":["isRef"],"mappings":"AAAA;AACE;AACF,wDAAA;AACA;AACA;ACWA,6CAAsC;AACtC,oEAAgB;AAChB,4CAAuC;AACvC,0CAA0B;AAC1B,kCAAsB;AACtB,kCAAiD;AACjD,kJAAmC;ADTnC;AACA;AEJO,SAAS,GAAA,CAAI,MAAA,EAAiB,IAAA,EAAoB;AAEvD,EAAA,GAAA,CAAI,CAAC,IA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AA;AACF,UAAA;AACM,QAAA;AAGiE,UAAA;AACzE,QAAA;AACK,MAAA;AACyE,QAAA;AAChF,MAAA;AACF,IAAA;AACF,EAAA;AAKgG,EAAA;AAC7E,IAAA;AACT,MAAA;AACC,MAAA;AACR,IAAA;AACH,EAAA;AAEmD,EAAA;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;ADkjBuG;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 { Extensions } from 'oas/extensions';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n SchemaObject,\n SchemaWrapper,\n ServerVariable,\n} from 'oas/types';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport Oas from 'oas';\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 {\n getParameterContentSchema,\n getParameterContentType,\n getTypedFormatsInSchema,\n getSafeRequestBody,\n hasSchemaType,\n parseJSONStringsInBodyWithSchema,\n} 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 (param.required && param.content) {\n const contentType = getParameterContentType(param);\n const schema = contentType ? getParameterContentSchema(param, contentType) : null;\n value = 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. Content-based header params also need formatting to properly serialize values\n // (e.g. JSON.stringify objects) instead of passing raw objects through. However, schema-based\n // header params should NOT be formatted as this would incorrectly URL-encode their values.\n if (type === 'query' || (type === 'header' && param.content)) {\n return formatStyle(value, param);\n }\n\n return value;\n }\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(\n removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n }),\n );\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return String(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 const currentOas = Oas.init(oas as unknown as OASDocument);\n operation = new Operation(\n currentOas,\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(statusCode => {\n // `getResponseByStatusCode` will lazily dereference the response if it's a `$ref` pointer.\n const response = operation.getResponseByStatusCode(statusCode);\n if (!response) return false;\n\n const content = response.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 a `content-type` header set up in the form data, but it hasn't been added yet?\n const contentTypeFormHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'content-type');\n if (contentTypeFormHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'content-type')) {\n hasContentType = true;\n contentType = String(formData.header[contentTypeFormHeader]);\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\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;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(formData.formData, { preserveNullishArrays: true });\n\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(formData.body, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n });\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, formData.body, operation.api);\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 if (\n !safeBodySchema.properties?.[key] ||\n typeof safeBodySchema.properties[key] !== 'object' ||\n safeBodySchema.properties[key] === null\n ) {\n return false;\n }\n\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 let multipartParams: ParameterObject[] = [];\n\n const multipartContent = operation.getRequestBody('multipart/form-data');\n if (multipartContent) {\n multipartParams = multipartBodyToFormatterParams(\n formData.body,\n multipartContent.mediaTypeObject,\n safeBodySchema,\n );\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, operation.api, {\n payload: cleanBody,\n });\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 {\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 {\n har.postData.text = stringify(formData.body);\n }\n } else {\n // If no `format: json` paths are found then we should recursively parse any string\n // values that are valid JSON so `format: json` is still resolved for our\n // `application/json` payload.\n try {\n const parsed: any = parseJSONStringsInBodyWithSchema(cleanBody, requestBodySchema, operation.api);\n if (typeof parsed?.RAW_BODY !== 'undefined') {\n har.postData.text = isPrimitive(parsed.RAW_BODY)\n ? String(parsed.RAW_BODY)\n : stringify(parsed.RAW_BODY as Record<string | 'RAW_BODY', unknown>);\n } else {\n har.postData.text = JSON.stringify(parsed);\n }\n } catch {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n }\n } catch {\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 { StylizerConfig } from './style-serializer.js';\nimport type { ParameterObject, SchemaObject } from 'oas/types';\n\nimport { matchesMimeType } from 'oas/utils';\nimport qs from 'qs';\n\nimport { getParameterContentType } from '../utils.js';\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;\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 * If content is present, we should use the content type to format the value. We also ignore the style and explode settings.\n *\n * @see {@link https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content}\n */\n if (parameter.content && (parameter.in === 'query' || parameter.in === 'header')) {\n const contentType = getParameterContentType(parameter);\n if (!contentType) {\n return;\n }\n\n /**\n * @todo Handle other content types\n */\n let serialized: string;\n if (matchesMimeType.json(contentType)) {\n serialized = JSON.stringify(value);\n } else {\n serialized = String(value);\n }\n\n return parameter.in === 'query' ? encodeURIComponent(serialized) : serialized;\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 !parameter.content\n );\n}\n\nexport 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 (\n !parameter.content &&\n parameter.style === 'deepObject' &&\n (!value || typeof value !== 'object' || parameter.explode === false)\n ) {\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","import type { OASDocument, ParameterObject, SchemaObject } from 'oas/types';\n\nimport { isRef } from 'oas/types';\nimport { dereferenceRef, dereferenceRefDeep, getParameterContentType as getParameterContentTypeUtil } from 'oas/utils';\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 * When we only have a schema fragment (no request payload), peel a single top-level polymorphic\n * schema to its first branch so we can enumerate its properties.\n *\n */\nfunction unwrapFirstPolymorphicBranch(obj: SchemaObject): SchemaObject {\n if (obj.oneOf && Array.isArray(obj.oneOf) && obj.oneOf.length) {\n return unwrapFirstPolymorphicBranch(obj.oneOf[0] as SchemaObject);\n }\n\n if (obj.anyOf && Array.isArray(obj.anyOf) && obj.anyOf.length) {\n return unwrapFirstPolymorphicBranch(obj.anyOf[0] as SchemaObject);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\ninterface SubschemaEntry {\n key: string;\n parentIsArray?: boolean;\n schema: SchemaObject;\n}\n\nfunction getSubschemas(\n schema: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\n): SubschemaEntry[] | false {\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: SubschemaEntry[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n const foundSubschemas = getSubschemas(\n schema,\n api,\n {\n ...opts,\n parentIsArray: false,\n parentKey: opts.parentKey ? [opts.parentKey, idx].join('.') : String(idx),\n },\n seenRefs,\n );\n\n if (foundSubschemas) {\n subschemas = subschemas.concat(foundSubschemas);\n }\n }\n } else {\n let resolvedSchema = schema;\n if (schema && isRef(schema)) {\n // Skip $refs we've already visited to prevent infinite recursion on circular references\n if (seenRefs.has(schema.$ref)) {\n return subschemas;\n }\n seenRefs.add(schema.$ref);\n\n resolvedSchema = dereferenceRef(schema, api);\n if (!resolvedSchema || isRef(resolvedSchema)) {\n return subschemas;\n }\n }\n\n const baseKey = opts.parentKey ?? '';\n\n // Collect subschemas from this objects `properties`, dereferencing `$ref` pointers and\n // building up a collection of dot-notation keys for each schema.\n if (resolvedSchema.properties && typeof resolvedSchema.properties === 'object') {\n for (const [propName, propSchema] of Object.entries(resolvedSchema.properties)) {\n if (propSchema && typeof propSchema === 'object') {\n let resolved: SchemaObject | undefined;\n if (isRef(propSchema)) {\n if (seenRefs.has(propSchema.$ref)) {\n // oxlint-disable-next-line no-continue\n continue;\n }\n\n seenRefs.add(propSchema.$ref);\n resolved = dereferenceRef(propSchema, api);\n } else {\n resolved = propSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: resolved,\n });\n }\n }\n }\n }\n\n // When the schema has no formal `properties` we need to enumerate through each of its available\n // property keys, collecting subschemas and dot-notation keysfrom each value. Generally we'll\n // hit this block when processing data like OpenAPI Media Type objects.\n if (\n !('properties' in resolvedSchema) &&\n typeof resolvedSchema === 'object' &&\n !('type' in resolvedSchema && resolvedSchema.type !== 'object')\n ) {\n for (const [propName, propSchema] of Object.entries(resolvedSchema)) {\n if (propSchema && (Array.isArray(propSchema) || (typeof propSchema === 'object' && propSchema !== null))) {\n const raw = unwrapFirstPolymorphicBranch(propSchema as SchemaObject);\n const resolved = isRef(raw) ? dereferenceRef(raw, api) : raw;\n const toPush = resolved && !isRef(resolved) ? resolved : raw;\n if (toPush && typeof toPush === 'object') {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: toPush,\n });\n }\n }\n }\n }\n\n if ('items' in resolvedSchema && resolvedSchema.items !== undefined && resolvedSchema.items !== true) {\n const itemsSchema = resolvedSchema.items as SchemaObject;\n let resolved: SchemaObject | undefined;\n if (isRef(itemsSchema)) {\n if (!seenRefs.has(itemsSchema.$ref)) {\n seenRefs.add(itemsSchema.$ref);\n resolved = dereferenceRef(itemsSchema, api);\n }\n } else {\n resolved = itemsSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey,\n schema: resolved,\n parentIsArray: true,\n });\n }\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: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\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.parentKey && 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, api, opts, seenRefs);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema, parentIsArray: entryIsArray }) => {\n if (isRef(subschema)) {\n const resolved = dereferenceRef(subschema, api);\n if (resolved && !isRef(resolved)) {\n return resolved;\n }\n\n return false;\n }\n\n return getTypedFormatsInSchema(\n format,\n subschema,\n api,\n {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: entryIsArray,\n },\n seenRefs,\n );\n })\n .filter(Boolean);\n } catch {\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\n/**\n * Extract content type from a parameter's `content` field.\n * According to OAS spec, when `content` is present, `style` and `explode` are ignored.\n * We prioritize `application/json` and other JSON-like content types over other content types.\n * Note: this is just a safe guard. In OAS parser, we enforce that there is exactly one content type.\n *\n * @param param - The parameter object\n * @returns The content type, or `null` if no content is present\n */\nexport function getParameterContentType(param: ParameterObject): string | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const contentKeys = Object.keys(param.content);\n if (contentKeys.length < 1) {\n return null;\n }\n\n return getParameterContentTypeUtil(contentKeys) || null;\n}\n\n/**\n * Extract schema from a parameter's `content` field.\n *\n * @param param - The parameter object\n * @param contentType - The content type\n * @returns The schema, or `null` if no schema is present\n */\nexport function getParameterContentSchema(param: ParameterObject, contentType: string): SchemaObject | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const mediaTypeObject = param.content[contentType];\n if (typeof mediaTypeObject === 'object' && mediaTypeObject && 'schema' in mediaTypeObject && mediaTypeObject.schema) {\n return isRef(mediaTypeObject.schema) ? null : (mediaTypeObject.schema as SchemaObject);\n }\n\n return null;\n}\n\n/**\n * Recursively parse string values that are valid JSON.\n *\n * This is used when we're dealing with objects that have nested `format: json` descriptors.\n */\nexport function parseJSONStrings(obj: unknown): unknown {\n if (typeof obj === 'string') {\n try {\n const p = JSON.parse(obj);\n return typeof p === 'object' && p !== null ? parseJSONStrings(p) : p;\n } catch {\n return obj;\n }\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStrings);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStrings(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\n/**\n * Like {@link parseJSONStrings} but only parses string values that are clearly JSON objects or\n * arrays (after trim, starts with `{` or `[`). Used for payload keys that are not declared on the\n * schema's `properties` map so numerical strings are not coerced into numbers.\n */\nfunction parseJSONStringsObjectContainersOnly(obj: unknown): unknown {\n if (typeof obj === 'string') {\n const trimmed = obj.trim();\n if (trimmed.startsWith('{') || trimmed.startsWith('[')) {\n try {\n const parsed = JSON.parse(obj);\n return parseJSONStringsObjectContainersOnly(parsed);\n } catch {\n return obj;\n }\n }\n\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStringsObjectContainersOnly);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\nfunction mergePropertiesFromAllOf(\n allOf: SchemaObject[],\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n const merged: Record<string, SchemaObject> = {};\n let found = false;\n\n for (const branch of allOf) {\n // oxlint-disable-next-line no-use-before-define\n const collected = collectSchemaObjectProperties(branch, api, new Set(seenRefs));\n if (collected) {\n found = true;\n Object.assign(merged, collected);\n }\n }\n\n return found ? merged : undefined;\n}\n\nfunction collectSchemaObjectProperties(\n schema: SchemaObject,\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n let node: SchemaObject | undefined = schema;\n\n if (isRef(node)) {\n if (seenRefs.has(node.$ref)) {\n return undefined;\n }\n\n seenRefs.add(node.$ref);\n const deref = dereferenceRef(node, api);\n if (!deref || isRef(deref)) {\n return undefined;\n }\n\n node = deref;\n }\n\n const safe = unwrapFirstPolymorphicBranch(node);\n if (isRef(safe)) {\n return collectSchemaObjectProperties(safe, api, seenRefs);\n }\n\n node = safe;\n\n if (node) {\n if ('allOf' in node && Array.isArray(node.allOf) && node.allOf.length) {\n return mergePropertiesFromAllOf(node.allOf as SchemaObject[], api, seenRefs);\n }\n\n if (node.properties && typeof node.properties === 'object') {\n return node.properties as Record<string, SchemaObject>;\n }\n }\n\n return undefined;\n}\n\nfunction getPayloadPropertyKeys(payload: unknown): string[] {\n if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {\n return [];\n }\n\n return Object.keys(payload as Record<string, unknown>).filter(\n k => typeof (payload as Record<string, unknown>)[k] !== 'undefined',\n );\n}\n\nfunction getPolymorphicSchema(node: SchemaObject): SchemaObject[] | null {\n return node.oneOf && Array.isArray(node.oneOf) && node.oneOf.length\n ? (node.oneOf as SchemaObject[])\n : node.anyOf && Array.isArray(node.anyOf) && node.anyOf.length\n ? (node.anyOf as SchemaObject[])\n : null;\n}\n\n/**\n * Choose a single branch from a polymorphic schema that best matches the payload we have.\n *\n * A branch matches when every non-`undefined` payload key exists on that branch's merged object\n * properties. If we have no payload, or no branches match, we use the first branch.\n *\n * When several branches match the one with the fewest declared properties wins, which would get us\n * as close to a best match as possible, however having more data in our payload would give us more\n * insight into which branch is what the user wants.\n */\nfunction pickPolymorphicBranch(alternatives: SchemaObject[], keys: string[], api: OASDocument): SchemaObject {\n if (!keys.length) {\n return alternatives[0];\n }\n\n const scored = alternatives.map((branch, idx) => {\n const props = collectSchemaObjectProperties(branch, api, new Set<string>());\n const allMatch = Boolean(props && keys.every(k => Object.prototype.hasOwnProperty.call(props, k)));\n const propCount = props ? Object.keys(props).length : Number.POSITIVE_INFINITY;\n\n return { idx, branch, allMatch, propCount };\n });\n\n const matches = scored.filter(entry => entry.allMatch);\n if (matches.length === 1) return matches[0].branch;\n if (matches.length > 1) {\n matches.sort((a, b) => a.propCount - b.propCount || a.idx - b.idx);\n return matches[0].branch;\n }\n\n return scored[0].branch;\n}\n\n/**\n * Resolve a request-body JSON Schema against a concrete payload.\n *\n */\nexport function getSafeRequestBody(schema: SchemaObject, payload: unknown, api: OASDocument): SchemaObject {\n // This isn't ideal but let's do a full dereference of our current schema so we can quickly pick\n // up and determine the polymorphic branch we need to use for this payload.\n let resolved = dereferenceRefDeep(schema, api);\n\n const keys = getPayloadPropertyKeys(payload);\n\n // Stop when `resolved` has no top-level polymorphic schema. Each pass replaces `resolved` with\n // one branch, which may still be polymorphic, so the increment step recomputes `alternatives`\n // from the new `resolved`.\n for (\n let alternatives = getPolymorphicSchema(resolved);\n alternatives != null;\n alternatives = getPolymorphicSchema(resolved)\n ) {\n resolved = pickPolymorphicBranch(alternatives, keys, api);\n }\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set());\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n return resolved;\n}\n\n/**\n * Recursively runs through a schema, parsing any values that have `format: json` attached and\n * deserializing them into their JSON representations.\n *\n * @see {@link parseJSONStrings}\n */\nexport function parseJSONStringsInBodyWithSchema(\n obj: unknown,\n schema: SchemaObject | undefined,\n api: OASDocument,\n seenRefs: Set<string> = new Set(),\n): unknown {\n // If there's no schema then we should parse any strings that look like JSON.\n if (schema === undefined) return parseJSONStrings(obj);\n\n let resolved: SchemaObject = schema;\n if (isRef(schema)) {\n // If we have already processed this `$ref` before then we should stop all schema-guiding\n // parsing behaviors so we don't infinitely recurse.\n if (seenRefs.has(schema.$ref)) {\n return parseJSONStrings(obj);\n }\n\n seenRefs.add(schema.$ref);\n const deref = dereferenceRef(schema, api);\n if (!deref || isRef(deref)) {\n return parseJSONStrings(obj);\n }\n\n resolved = deref;\n }\n\n // If our resolved schema is a polymorphic `oneOf` or `anyOf` schema then we should use the first\n // branch of the schema to guide our parsing behavior. If the schema is _not_ polymorphic then\n // we'll use that schema as-is.\n const safe = getSafeRequestBody(resolved, obj, api);\n if (isRef(safe)) {\n return parseJSONStringsInBodyWithSchema(obj, safe, api, seenRefs);\n }\n\n resolved = safe;\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set(seenRefs));\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n if (typeof obj === 'string') {\n // If the schema is a string but does **not** have `format: json` then it should be left alone.\n if (hasSchemaType(resolved, 'string') && resolved.format !== 'json') {\n return obj;\n }\n\n return parseJSONStrings(obj);\n }\n\n if (Array.isArray(obj)) {\n // @ts-expect-error -- `items` exists in schema objects, just the typing on `SchemaObject` is very messy.\n let items = resolved.items as SchemaObject | undefined;\n if (items && typeof items === 'object' && isRef(items)) {\n // If we've already processed this `$ref` before then we should stop all schema-guided\n // parsing behaviors so we don't infinitely recurse, instead treating what we have as it is\n // and parsing anything that looks like JSON.\n if (seenRefs.has(items.$ref)) {\n return obj.map(item => parseJSONStrings(item));\n }\n\n seenRefs.add(items.$ref);\n const derefItems = dereferenceRef(items, api);\n items = derefItems && !isRef(derefItems) ? derefItems : undefined;\n }\n\n return obj.map(item => parseJSONStringsInBodyWithSchema(item, items, api, new Set(seenRefs)));\n }\n\n if (obj !== null && typeof obj === 'object') {\n // If we have an object schema that doesn't have any `properties` then we should just parse\n // anything that looks like JSON within whatever we _do_ have here.\n if (!resolved.properties || typeof resolved.properties !== 'object') {\n return parseJSONStrings(obj);\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n const propSchema = resolved.properties[k] as SchemaObject | undefined;\n out[k] =\n propSchema !== undefined\n ? parseJSONStringsInBodyWithSchema(v, propSchema, api, new Set(seenRefs))\n : parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n","// oxlint-disable no-use-before-define\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 {\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 // oxlint-disable-next-line no-param-reassign -- 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 // oxlint-disable-next-line readme/json-parse-try-catch\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 // Handle null values explicitly to prevent join() from converting to empty string\n if (str === null) {\n return 'null';\n }\n\n const result = encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n return result;\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 // no-op\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 // no-op\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 // no-op\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/utils.ts","../src/lib/style-formatting/style-serializer.ts"],"names":["out","isRef"],"mappings":"AAAA;AACE;AACF,wDAAA;AACA;AACA;ACWA,6CAAsC;AACtC,oEAAgB;AAChB,4CAAuC;AACvC,0CAA0B;AAC1B,kCAAsB;AACtB,kCAAiD;AACjD,kJAAmC;ADTnC;AACA;AEJO,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,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,IAAA,GAAA,CAAI,EA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AACM,QAAA;AAGiE,UAAA;AACzE,QAAA;AACK,MAAA;AACyE,QAAA;AAChF,MAAA;AACF,IAAA;AACF,EAAA;AAKgG,EAAA;AAC7E,IAAA;AACT,MAAA;AACC,MAAA;AACR,IAAA;AACH,EAAA;AAEmD,EAAA;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;ADyjBuG;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 { Extensions } from 'oas/extensions';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n SchemaObject,\n SchemaWrapper,\n ServerVariable,\n} from 'oas/types';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport Oas from 'oas';\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 {\n getParameterContentSchema,\n getParameterContentType,\n getTypedFormatsInSchema,\n getSafeRequestBody,\n hasSchemaType,\n parseJSONStringsInBodyWithSchema,\n} 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 (param.required && param.content) {\n const contentType = getParameterContentType(param);\n const schema = contentType ? getParameterContentSchema(param, contentType) : null;\n value = 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. Content-based header params also need formatting to properly serialize values\n // (e.g. JSON.stringify objects) instead of passing raw objects through. However, schema-based\n // header params should NOT be formatted as this would incorrectly URL-encode their values.\n if (type === 'query' || (type === 'header' && param.content)) {\n return formatStyle(value, param);\n }\n\n return value;\n }\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 const propertySchema = schema.properties[key];\n const isObjectSchema = typeof propertySchema === 'object' && propertySchema !== null && !isRef(propertySchema);\n const hasObjectType =\n isObjectSchema &&\n // OAS 3.1 uses JSON Schema union types, so object schemas can appear as\n // `type: ['object', 'null']` or another union that includes `object`.\n (Array.isArray(propertySchema.type)\n ? propertySchema.type.includes('object')\n : propertySchema.type === 'object');\n const hasObjectProperties =\n isObjectSchema && typeof propertySchema.properties === 'object' && propertySchema.properties !== null;\n const shouldDefaultNestedMultipartObject = !paramEncoding && (hasObjectType || hasObjectProperties);\n\n return {\n name: key,\n // Preserve nested multipart object paths as form fields unless the spec supplies explicit\n // encoding for this property.\n style: paramEncoding ? paramEncoding.style : shouldDefaultNestedMultipartObject ? 'deepObject' : undefined,\n explode: paramEncoding ? paramEncoding.explode : shouldDefaultNestedMultipartObject ? true : 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(\n removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n }),\n );\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return String(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 const currentOas = Oas.init(oas as unknown as OASDocument);\n operation = new Operation(\n currentOas,\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(statusCode => {\n // `getResponseByStatusCode` will lazily dereference the response if it's a `$ref` pointer.\n const response = operation.getResponseByStatusCode(statusCode);\n if (!response) return false;\n\n const content = response.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 a `content-type` header set up in the form data, but it hasn't been added yet?\n const contentTypeFormHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'content-type');\n if (contentTypeFormHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'content-type')) {\n hasContentType = true;\n contentType = String(formData.header[contentTypeFormHeader]);\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\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;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(formData.formData, { preserveNullishArrays: true });\n\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(formData.body, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n });\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, formData.body, operation.api);\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 if (\n !safeBodySchema.properties?.[key] ||\n typeof safeBodySchema.properties[key] !== 'object' ||\n safeBodySchema.properties[key] === null\n ) {\n return false;\n }\n\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 let multipartParams: ParameterObject[] = [];\n\n const multipartContent = operation.getRequestBody('multipart/form-data');\n if (multipartContent) {\n multipartParams = multipartBodyToFormatterParams(\n formData.body,\n multipartContent.mediaTypeObject,\n safeBodySchema,\n );\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, operation.api, {\n payload: cleanBody,\n });\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 {\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 {\n har.postData.text = stringify(formData.body);\n }\n } else {\n // If no `format: json` paths are found then we should recursively parse any string\n // values that are valid JSON so `format: json` is still resolved for our\n // `application/json` payload.\n try {\n const parsed: any = parseJSONStringsInBodyWithSchema(cleanBody, requestBodySchema, operation.api);\n if (typeof parsed?.RAW_BODY !== 'undefined') {\n har.postData.text = isPrimitive(parsed.RAW_BODY)\n ? String(parsed.RAW_BODY)\n : stringify(parsed.RAW_BODY as Record<string | 'RAW_BODY', unknown>);\n } else {\n har.postData.text = JSON.stringify(parsed);\n }\n } catch {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n }\n } catch {\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 { StylizerConfig } from './style-serializer.js';\nimport type { ParameterObject, SchemaObject } from 'oas/types';\n\nimport { matchesMimeType } from 'oas/utils';\nimport qs from 'qs';\n\nimport { getParameterContentType } from '../utils.js';\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;\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 * If content is present, we should use the content type to format the value. We also ignore the style and explode settings.\n *\n * @see {@link https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content}\n */\n if (parameter.content && (parameter.in === 'query' || parameter.in === 'header')) {\n const contentType = getParameterContentType(parameter);\n if (!contentType) {\n return;\n }\n\n /**\n * @todo Handle other content types\n */\n let serialized: string;\n if (matchesMimeType.json(contentType)) {\n serialized = JSON.stringify(value);\n } else {\n serialized = String(value);\n }\n\n return parameter.in === 'query' ? encodeURIComponent(serialized) : serialized;\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 !parameter.content\n );\n}\n\nexport 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 (\n !parameter.content &&\n parameter.style === 'deepObject' &&\n (!value || typeof value !== 'object' || parameter.explode === false)\n ) {\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","import type { OASDocument, ParameterObject, SchemaObject } from 'oas/types';\n\nimport { isRef } from 'oas/types';\nimport { dereferenceRef, dereferenceRefDeep, getParameterContentType as getParameterContentTypeUtil } from 'oas/utils';\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 * When we only have a schema fragment (no request payload), peel a single top-level polymorphic\n * schema to its first branch so we can enumerate its properties.\n *\n */\nfunction unwrapFirstPolymorphicBranch(obj: SchemaObject): SchemaObject {\n if (obj.oneOf && Array.isArray(obj.oneOf) && obj.oneOf.length) {\n return unwrapFirstPolymorphicBranch(obj.oneOf[0] as SchemaObject);\n }\n\n if (obj.anyOf && Array.isArray(obj.anyOf) && obj.anyOf.length) {\n return unwrapFirstPolymorphicBranch(obj.anyOf[0] as SchemaObject);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\ninterface SubschemaEntry {\n key: string;\n parentIsArray?: boolean;\n schema: SchemaObject;\n}\n\nfunction getSubschemas(\n schema: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\n): SubschemaEntry[] | false {\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: SubschemaEntry[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n const foundSubschemas = getSubschemas(\n schema,\n api,\n {\n ...opts,\n parentIsArray: false,\n parentKey: opts.parentKey ? [opts.parentKey, idx].join('.') : String(idx),\n },\n seenRefs,\n );\n\n if (foundSubschemas) {\n subschemas = subschemas.concat(foundSubschemas);\n }\n }\n } else {\n let resolvedSchema = schema;\n if (schema && isRef(schema)) {\n // Skip $refs we've already visited to prevent infinite recursion on circular references\n if (seenRefs.has(schema.$ref)) {\n return subschemas;\n }\n seenRefs.add(schema.$ref);\n\n resolvedSchema = dereferenceRef(schema, api);\n if (!resolvedSchema || isRef(resolvedSchema)) {\n return subschemas;\n }\n }\n\n const baseKey = opts.parentKey ?? '';\n\n // Collect subschemas from this objects `properties`, dereferencing `$ref` pointers and\n // building up a collection of dot-notation keys for each schema.\n if (resolvedSchema.properties && typeof resolvedSchema.properties === 'object') {\n for (const [propName, propSchema] of Object.entries(resolvedSchema.properties)) {\n if (propSchema && typeof propSchema === 'object') {\n let resolved: SchemaObject | undefined;\n if (isRef(propSchema)) {\n if (seenRefs.has(propSchema.$ref)) {\n // oxlint-disable-next-line no-continue\n continue;\n }\n\n seenRefs.add(propSchema.$ref);\n resolved = dereferenceRef(propSchema, api);\n } else {\n resolved = propSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: resolved,\n });\n }\n }\n }\n }\n\n // When the schema has no formal `properties` we need to enumerate through each of its available\n // property keys, collecting subschemas and dot-notation keysfrom each value. Generally we'll\n // hit this block when processing data like OpenAPI Media Type objects.\n if (\n !('properties' in resolvedSchema) &&\n typeof resolvedSchema === 'object' &&\n !('type' in resolvedSchema && resolvedSchema.type !== 'object')\n ) {\n for (const [propName, propSchema] of Object.entries(resolvedSchema)) {\n if (propSchema && (Array.isArray(propSchema) || (typeof propSchema === 'object' && propSchema !== null))) {\n const raw = unwrapFirstPolymorphicBranch(propSchema as SchemaObject);\n const resolved = isRef(raw) ? dereferenceRef(raw, api) : raw;\n const toPush = resolved && !isRef(resolved) ? resolved : raw;\n if (toPush && typeof toPush === 'object') {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: toPush,\n });\n }\n }\n }\n }\n\n if ('items' in resolvedSchema && resolvedSchema.items !== undefined && resolvedSchema.items !== true) {\n const itemsSchema = resolvedSchema.items as SchemaObject;\n let resolved: SchemaObject | undefined;\n if (isRef(itemsSchema)) {\n if (!seenRefs.has(itemsSchema.$ref)) {\n seenRefs.add(itemsSchema.$ref);\n resolved = dereferenceRef(itemsSchema, api);\n }\n } else {\n resolved = itemsSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey,\n schema: resolved,\n parentIsArray: true,\n });\n }\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: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\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.parentKey && 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, api, opts, seenRefs);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema, parentIsArray: entryIsArray }) => {\n if (isRef(subschema)) {\n const resolved = dereferenceRef(subschema, api);\n if (resolved && !isRef(resolved)) {\n return resolved;\n }\n\n return false;\n }\n\n return getTypedFormatsInSchema(\n format,\n subschema,\n api,\n {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: entryIsArray,\n },\n seenRefs,\n );\n })\n .filter(Boolean);\n } catch {\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\n/**\n * Extract content type from a parameter's `content` field.\n * According to OAS spec, when `content` is present, `style` and `explode` are ignored.\n * We prioritize `application/json` and other JSON-like content types over other content types.\n * Note: this is just a safe guard. In OAS parser, we enforce that there is exactly one content type.\n *\n * @param param - The parameter object\n * @returns The content type, or `null` if no content is present\n */\nexport function getParameterContentType(param: ParameterObject): string | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const contentKeys = Object.keys(param.content);\n if (contentKeys.length < 1) {\n return null;\n }\n\n return getParameterContentTypeUtil(contentKeys) || null;\n}\n\n/**\n * Extract schema from a parameter's `content` field.\n *\n * @param param - The parameter object\n * @param contentType - The content type\n * @returns The schema, or `null` if no schema is present\n */\nexport function getParameterContentSchema(param: ParameterObject, contentType: string): SchemaObject | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const mediaTypeObject = param.content[contentType];\n if (typeof mediaTypeObject === 'object' && mediaTypeObject && 'schema' in mediaTypeObject && mediaTypeObject.schema) {\n return isRef(mediaTypeObject.schema) ? null : (mediaTypeObject.schema as SchemaObject);\n }\n\n return null;\n}\n\n/**\n * Recursively parse string values that are valid JSON.\n *\n * This is used when we're dealing with objects that have nested `format: json` descriptors.\n */\nexport function parseJSONStrings(obj: unknown): unknown {\n if (typeof obj === 'string') {\n try {\n const p = JSON.parse(obj);\n return typeof p === 'object' && p !== null ? parseJSONStrings(p) : p;\n } catch {\n return obj;\n }\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStrings);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStrings(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\n/**\n * Like {@link parseJSONStrings} but only parses string values that are clearly JSON objects or\n * arrays (after trim, starts with `{` or `[`). Used for payload keys that are not declared on the\n * schema's `properties` map so numerical strings are not coerced into numbers.\n */\nfunction parseJSONStringsObjectContainersOnly(obj: unknown): unknown {\n if (typeof obj === 'string') {\n const trimmed = obj.trim();\n if (trimmed.startsWith('{') || trimmed.startsWith('[')) {\n try {\n const parsed = JSON.parse(obj);\n return parseJSONStringsObjectContainersOnly(parsed);\n } catch {\n return obj;\n }\n }\n\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStringsObjectContainersOnly);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\nfunction getAdditionalPropertiesSchema(schema: SchemaObject): SchemaObject | undefined {\n return schema.additionalProperties && typeof schema.additionalProperties === 'object'\n ? (schema.additionalProperties as SchemaObject)\n : undefined;\n}\n\nfunction mergePropertiesFromAllOf(\n allOf: SchemaObject[],\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n const merged: Record<string, SchemaObject> = {};\n let found = false;\n\n for (const branch of allOf) {\n // oxlint-disable-next-line no-use-before-define\n const collected = collectSchemaObjectProperties(branch, api, new Set(seenRefs));\n if (collected) {\n found = true;\n Object.assign(merged, collected);\n }\n }\n\n return found ? merged : undefined;\n}\n\nfunction collectSchemaObjectProperties(\n schema: SchemaObject,\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n let node: SchemaObject | undefined = schema;\n\n if (isRef(node)) {\n if (seenRefs.has(node.$ref)) {\n return undefined;\n }\n\n seenRefs.add(node.$ref);\n const deref = dereferenceRef(node, api);\n if (!deref || isRef(deref)) {\n return undefined;\n }\n\n node = deref;\n }\n\n const safe = unwrapFirstPolymorphicBranch(node);\n if (isRef(safe)) {\n return collectSchemaObjectProperties(safe, api, seenRefs);\n }\n\n node = safe;\n\n if (node) {\n if ('allOf' in node && Array.isArray(node.allOf) && node.allOf.length) {\n return mergePropertiesFromAllOf(node.allOf as SchemaObject[], api, seenRefs);\n }\n\n if (node.properties && typeof node.properties === 'object') {\n return node.properties as Record<string, SchemaObject>;\n }\n }\n\n return undefined;\n}\n\nfunction getPayloadPropertyKeys(payload: unknown): string[] {\n if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {\n return [];\n }\n\n return Object.keys(payload as Record<string, unknown>).filter(\n k => typeof (payload as Record<string, unknown>)[k] !== 'undefined',\n );\n}\n\nfunction getPolymorphicSchema(node: SchemaObject): SchemaObject[] | null {\n return node.oneOf && Array.isArray(node.oneOf) && node.oneOf.length\n ? (node.oneOf as SchemaObject[])\n : node.anyOf && Array.isArray(node.anyOf) && node.anyOf.length\n ? (node.anyOf as SchemaObject[])\n : null;\n}\n\n/**\n * Choose a single branch from a polymorphic schema that best matches the payload we have.\n *\n * A branch matches when every non-`undefined` payload key exists on that branch's merged object\n * properties. If we have no payload, or no branches match, we use the first branch.\n *\n * When several branches match the one with the fewest declared properties wins, which would get us\n * as close to a best match as possible, however having more data in our payload would give us more\n * insight into which branch is what the user wants.\n */\nfunction pickPolymorphicBranch(alternatives: SchemaObject[], keys: string[], api: OASDocument): SchemaObject {\n if (!keys.length) {\n return alternatives[0];\n }\n\n const scored = alternatives.map((branch, idx) => {\n const props = collectSchemaObjectProperties(branch, api, new Set<string>());\n const allMatch = Boolean(props && keys.every(k => Object.prototype.hasOwnProperty.call(props, k)));\n const propCount = props ? Object.keys(props).length : Number.POSITIVE_INFINITY;\n\n return { idx, branch, allMatch, propCount };\n });\n\n const matches = scored.filter(entry => entry.allMatch);\n if (matches.length === 1) return matches[0].branch;\n if (matches.length > 1) {\n matches.sort((a, b) => a.propCount - b.propCount || a.idx - b.idx);\n return matches[0].branch;\n }\n\n return scored[0].branch;\n}\n\n/**\n * Resolve a request-body JSON Schema against a concrete payload.\n *\n */\nexport function getSafeRequestBody(schema: SchemaObject, payload: unknown, api: OASDocument): SchemaObject {\n // This isn't ideal but let's do a full dereference of our current schema so we can quickly pick\n // up and determine the polymorphic branch we need to use for this payload.\n let resolved = dereferenceRefDeep(schema, api);\n\n const keys = getPayloadPropertyKeys(payload);\n\n // Stop when `resolved` has no top-level polymorphic schema. Each pass replaces `resolved` with\n // one branch, which may still be polymorphic, so the increment step recomputes `alternatives`\n // from the new `resolved`.\n for (\n let alternatives = getPolymorphicSchema(resolved);\n alternatives != null;\n alternatives = getPolymorphicSchema(resolved)\n ) {\n resolved = pickPolymorphicBranch(alternatives, keys, api);\n }\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set());\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n return resolved;\n}\n\n/**\n * Recursively runs through a schema, parsing any values that have `format: json` attached and\n * deserializing them into their JSON representations.\n *\n * @see {@link parseJSONStrings}\n */\nexport function parseJSONStringsInBodyWithSchema(\n obj: unknown,\n schema: SchemaObject | undefined,\n api: OASDocument,\n seenRefs: Set<string> = new Set(),\n): unknown {\n // If there's no schema then we should parse any strings that look like JSON.\n if (schema === undefined) return parseJSONStrings(obj);\n\n let resolved: SchemaObject = schema;\n if (isRef(schema)) {\n // If we have already processed this `$ref` before then we should stop all schema-guiding\n // parsing behaviors so we don't infinitely recurse.\n if (seenRefs.has(schema.$ref)) {\n return parseJSONStrings(obj);\n }\n\n seenRefs.add(schema.$ref);\n const deref = dereferenceRef(schema, api);\n if (!deref || isRef(deref)) {\n return parseJSONStrings(obj);\n }\n\n resolved = deref;\n }\n\n // If our resolved schema is a polymorphic `oneOf` or `anyOf` schema then we should use the first\n // branch of the schema to guide our parsing behavior. If the schema is _not_ polymorphic then\n // we'll use that schema as-is.\n const safe = getSafeRequestBody(resolved, obj, api);\n if (isRef(safe)) {\n return parseJSONStringsInBodyWithSchema(obj, safe, api, seenRefs);\n }\n\n resolved = safe;\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set(seenRefs));\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n if (typeof obj === 'string') {\n // If the schema is a string but does **not** have `format: json` then it should be left alone.\n if (hasSchemaType(resolved, 'string') && resolved.format !== 'json') {\n return obj;\n }\n\n return parseJSONStrings(obj);\n }\n\n if (Array.isArray(obj)) {\n // @ts-expect-error -- `items` exists in schema objects, just the typing on `SchemaObject` is very messy.\n let items = resolved.items as SchemaObject | undefined;\n if (items && typeof items === 'object' && isRef(items)) {\n // If we've already processed this `$ref` before then we should stop all schema-guided\n // parsing behaviors so we don't infinitely recurse, instead treating what we have as it is\n // and parsing anything that looks like JSON.\n if (seenRefs.has(items.$ref)) {\n return obj.map(item => parseJSONStrings(item));\n }\n\n seenRefs.add(items.$ref);\n const derefItems = dereferenceRef(items, api);\n items = derefItems && !isRef(derefItems) ? derefItems : undefined;\n }\n\n return obj.map(item => parseJSONStringsInBodyWithSchema(item, items, api, new Set(seenRefs)));\n }\n\n if (obj !== null && typeof obj === 'object') {\n const additionalPropertiesSchema = getAdditionalPropertiesSchema(resolved);\n\n // If we have an object schema that doesn't have any `properties`, use a schema-object\n // `additionalProperties` as the schema for each key. Otherwise parse whatever we have loosely.\n if (!resolved.properties || typeof resolved.properties !== 'object') {\n if (additionalPropertiesSchema) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStringsInBodyWithSchema(v, additionalPropertiesSchema, api, new Set(seenRefs));\n }\n\n return out;\n }\n\n return parseJSONStrings(obj);\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n const propSchema = resolved.properties[k] as SchemaObject | undefined;\n const schemaForValue = propSchema ?? additionalPropertiesSchema;\n out[k] =\n schemaForValue !== undefined\n ? parseJSONStringsInBodyWithSchema(v, schemaForValue, api, new Set(seenRefs))\n : parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n","// oxlint-disable no-use-before-define\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 {\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 // oxlint-disable-next-line no-param-reassign -- 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 // oxlint-disable-next-line readme/json-parse-try-catch\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 // Handle null values explicitly to prevent join() from converting to empty string\n if (str === null) {\n return 'null';\n }\n\n const result = encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n return result;\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 // no-op\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 // no-op\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 // no-op\n }\n}\n"]}
package/dist/index.js CHANGED
@@ -266,6 +266,9 @@ function parseJSONStringsObjectContainersOnly(obj) {
266
266
  }
267
267
  return obj;
268
268
  }
269
+ function getAdditionalPropertiesSchema(schema) {
270
+ return schema.additionalProperties && typeof schema.additionalProperties === "object" ? schema.additionalProperties : void 0;
271
+ }
269
272
  function mergePropertiesFromAllOf(allOf, api, seenRefs) {
270
273
  const merged = {};
271
274
  let found = false;
@@ -403,13 +406,22 @@ function parseJSONStringsInBodyWithSchema(obj, schema, api, seenRefs = /* @__PUR
403
406
  return obj.map((item) => parseJSONStringsInBodyWithSchema(item, items, api, new Set(seenRefs)));
404
407
  }
405
408
  if (obj !== null && typeof obj === "object") {
409
+ const additionalPropertiesSchema = getAdditionalPropertiesSchema(resolved);
406
410
  if (!resolved.properties || typeof resolved.properties !== "object") {
411
+ if (additionalPropertiesSchema) {
412
+ const out2 = {};
413
+ for (const [k, v] of Object.entries(obj)) {
414
+ out2[k] = parseJSONStringsInBodyWithSchema(v, additionalPropertiesSchema, api, new Set(seenRefs));
415
+ }
416
+ return out2;
417
+ }
407
418
  return parseJSONStrings(obj);
408
419
  }
409
420
  const out = {};
410
421
  for (const [k, v] of Object.entries(obj)) {
411
422
  const propSchema = resolved.properties[k];
412
- out[k] = propSchema !== void 0 ? parseJSONStringsInBodyWithSchema(v, propSchema, api, new Set(seenRefs)) : parseJSONStringsObjectContainersOnly(v);
423
+ const schemaForValue = propSchema ?? additionalPropertiesSchema;
424
+ out[k] = schemaForValue !== void 0 ? parseJSONStringsInBodyWithSchema(v, schemaForValue, api, new Set(seenRefs)) : parseJSONStringsObjectContainersOnly(v);
413
425
  }
414
426
  return out;
415
427
  }
@@ -878,12 +890,19 @@ function multipartBodyToFormatterParams(payload, oasMediaTypeObject, schema) {
878
890
  return false;
879
891
  }
880
892
  const paramEncoding = encoding ? encoding[key] : void 0;
893
+ const propertySchema = schema.properties[key];
894
+ const isObjectSchema = typeof propertySchema === "object" && propertySchema !== null && !isRef2(propertySchema);
895
+ const hasObjectType = isObjectSchema && // OAS 3.1 uses JSON Schema union types, so object schemas can appear as
896
+ // `type: ['object', 'null']` or another union that includes `object`.
897
+ (Array.isArray(propertySchema.type) ? propertySchema.type.includes("object") : propertySchema.type === "object");
898
+ const hasObjectProperties = isObjectSchema && typeof propertySchema.properties === "object" && propertySchema.properties !== null;
899
+ const shouldDefaultNestedMultipartObject = !paramEncoding && (hasObjectType || hasObjectProperties);
881
900
  return {
882
901
  name: key,
883
- // If the style isn't defined, use the default
884
- style: paramEncoding ? paramEncoding.style : void 0,
885
- // If explode isn't defined, use the default
886
- explode: paramEncoding ? paramEncoding.explode : void 0,
902
+ // Preserve nested multipart object paths as form fields unless the spec supplies explicit
903
+ // encoding for this property.
904
+ style: paramEncoding ? paramEncoding.style : shouldDefaultNestedMultipartObject ? "deepObject" : void 0,
905
+ explode: paramEncoding ? paramEncoding.explode : shouldDefaultNestedMultipartObject ? true : void 0,
887
906
  required: schema.required && typeof schema.required === "boolean" && Boolean(schema.required) || Array.isArray(schema.required) && schema.required.includes(key),
888
907
  schema: schema.properties[key],
889
908
  in: "body"
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/utils.ts","../src/lib/style-formatting/style-serializer.ts"],"sourcesContent":["import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\nimport type { PostData, PostDataParams, Request } from 'har-format';\nimport type { Extensions } from 'oas/extensions';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n SchemaObject,\n SchemaWrapper,\n ServerVariable,\n} from 'oas/types';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport Oas from 'oas';\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 {\n getParameterContentSchema,\n getParameterContentType,\n getTypedFormatsInSchema,\n getSafeRequestBody,\n hasSchemaType,\n parseJSONStringsInBodyWithSchema,\n} 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 (param.required && param.content) {\n const contentType = getParameterContentType(param);\n const schema = contentType ? getParameterContentSchema(param, contentType) : null;\n value = 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. Content-based header params also need formatting to properly serialize values\n // (e.g. JSON.stringify objects) instead of passing raw objects through. However, schema-based\n // header params should NOT be formatted as this would incorrectly URL-encode their values.\n if (type === 'query' || (type === 'header' && param.content)) {\n return formatStyle(value, param);\n }\n\n return value;\n }\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(\n removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n }),\n );\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return String(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 const currentOas = Oas.init(oas as unknown as OASDocument);\n operation = new Operation(\n currentOas,\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(statusCode => {\n // `getResponseByStatusCode` will lazily dereference the response if it's a `$ref` pointer.\n const response = operation.getResponseByStatusCode(statusCode);\n if (!response) return false;\n\n const content = response.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 a `content-type` header set up in the form data, but it hasn't been added yet?\n const contentTypeFormHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'content-type');\n if (contentTypeFormHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'content-type')) {\n hasContentType = true;\n contentType = String(formData.header[contentTypeFormHeader]);\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\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;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(formData.formData, { preserveNullishArrays: true });\n\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(formData.body, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n });\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, formData.body, operation.api);\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 if (\n !safeBodySchema.properties?.[key] ||\n typeof safeBodySchema.properties[key] !== 'object' ||\n safeBodySchema.properties[key] === null\n ) {\n return false;\n }\n\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 let multipartParams: ParameterObject[] = [];\n\n const multipartContent = operation.getRequestBody('multipart/form-data');\n if (multipartContent) {\n multipartParams = multipartBodyToFormatterParams(\n formData.body,\n multipartContent.mediaTypeObject,\n safeBodySchema,\n );\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, operation.api, {\n payload: cleanBody,\n });\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 {\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 {\n har.postData.text = stringify(formData.body);\n }\n } else {\n // If no `format: json` paths are found then we should recursively parse any string\n // values that are valid JSON so `format: json` is still resolved for our\n // `application/json` payload.\n try {\n const parsed: any = parseJSONStringsInBodyWithSchema(cleanBody, requestBodySchema, operation.api);\n if (typeof parsed?.RAW_BODY !== 'undefined') {\n har.postData.text = isPrimitive(parsed.RAW_BODY)\n ? String(parsed.RAW_BODY)\n : stringify(parsed.RAW_BODY as Record<string | 'RAW_BODY', unknown>);\n } else {\n har.postData.text = JSON.stringify(parsed);\n }\n } catch {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n }\n } catch {\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 { StylizerConfig } from './style-serializer.js';\nimport type { ParameterObject, SchemaObject } from 'oas/types';\n\nimport { matchesMimeType } from 'oas/utils';\nimport qs from 'qs';\n\nimport { getParameterContentType } from '../utils.js';\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;\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 * If content is present, we should use the content type to format the value. We also ignore the style and explode settings.\n *\n * @see {@link https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content}\n */\n if (parameter.content && (parameter.in === 'query' || parameter.in === 'header')) {\n const contentType = getParameterContentType(parameter);\n if (!contentType) {\n return;\n }\n\n /**\n * @todo Handle other content types\n */\n let serialized: string;\n if (matchesMimeType.json(contentType)) {\n serialized = JSON.stringify(value);\n } else {\n serialized = String(value);\n }\n\n return parameter.in === 'query' ? encodeURIComponent(serialized) : serialized;\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 !parameter.content\n );\n}\n\nexport 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 (\n !parameter.content &&\n parameter.style === 'deepObject' &&\n (!value || typeof value !== 'object' || parameter.explode === false)\n ) {\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","import type { OASDocument, ParameterObject, SchemaObject } from 'oas/types';\n\nimport { isRef } from 'oas/types';\nimport { dereferenceRef, dereferenceRefDeep, getParameterContentType as getParameterContentTypeUtil } from 'oas/utils';\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 * When we only have a schema fragment (no request payload), peel a single top-level polymorphic\n * schema to its first branch so we can enumerate its properties.\n *\n */\nfunction unwrapFirstPolymorphicBranch(obj: SchemaObject): SchemaObject {\n if (obj.oneOf && Array.isArray(obj.oneOf) && obj.oneOf.length) {\n return unwrapFirstPolymorphicBranch(obj.oneOf[0] as SchemaObject);\n }\n\n if (obj.anyOf && Array.isArray(obj.anyOf) && obj.anyOf.length) {\n return unwrapFirstPolymorphicBranch(obj.anyOf[0] as SchemaObject);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\ninterface SubschemaEntry {\n key: string;\n parentIsArray?: boolean;\n schema: SchemaObject;\n}\n\nfunction getSubschemas(\n schema: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\n): SubschemaEntry[] | false {\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: SubschemaEntry[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n const foundSubschemas = getSubschemas(\n schema,\n api,\n {\n ...opts,\n parentIsArray: false,\n parentKey: opts.parentKey ? [opts.parentKey, idx].join('.') : String(idx),\n },\n seenRefs,\n );\n\n if (foundSubschemas) {\n subschemas = subschemas.concat(foundSubschemas);\n }\n }\n } else {\n let resolvedSchema = schema;\n if (schema && isRef(schema)) {\n // Skip $refs we've already visited to prevent infinite recursion on circular references\n if (seenRefs.has(schema.$ref)) {\n return subschemas;\n }\n seenRefs.add(schema.$ref);\n\n resolvedSchema = dereferenceRef(schema, api);\n if (!resolvedSchema || isRef(resolvedSchema)) {\n return subschemas;\n }\n }\n\n const baseKey = opts.parentKey ?? '';\n\n // Collect subschemas from this objects `properties`, dereferencing `$ref` pointers and\n // building up a collection of dot-notation keys for each schema.\n if (resolvedSchema.properties && typeof resolvedSchema.properties === 'object') {\n for (const [propName, propSchema] of Object.entries(resolvedSchema.properties)) {\n if (propSchema && typeof propSchema === 'object') {\n let resolved: SchemaObject | undefined;\n if (isRef(propSchema)) {\n if (seenRefs.has(propSchema.$ref)) {\n // oxlint-disable-next-line no-continue\n continue;\n }\n\n seenRefs.add(propSchema.$ref);\n resolved = dereferenceRef(propSchema, api);\n } else {\n resolved = propSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: resolved,\n });\n }\n }\n }\n }\n\n // When the schema has no formal `properties` we need to enumerate through each of its available\n // property keys, collecting subschemas and dot-notation keysfrom each value. Generally we'll\n // hit this block when processing data like OpenAPI Media Type objects.\n if (\n !('properties' in resolvedSchema) &&\n typeof resolvedSchema === 'object' &&\n !('type' in resolvedSchema && resolvedSchema.type !== 'object')\n ) {\n for (const [propName, propSchema] of Object.entries(resolvedSchema)) {\n if (propSchema && (Array.isArray(propSchema) || (typeof propSchema === 'object' && propSchema !== null))) {\n const raw = unwrapFirstPolymorphicBranch(propSchema as SchemaObject);\n const resolved = isRef(raw) ? dereferenceRef(raw, api) : raw;\n const toPush = resolved && !isRef(resolved) ? resolved : raw;\n if (toPush && typeof toPush === 'object') {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: toPush,\n });\n }\n }\n }\n }\n\n if ('items' in resolvedSchema && resolvedSchema.items !== undefined && resolvedSchema.items !== true) {\n const itemsSchema = resolvedSchema.items as SchemaObject;\n let resolved: SchemaObject | undefined;\n if (isRef(itemsSchema)) {\n if (!seenRefs.has(itemsSchema.$ref)) {\n seenRefs.add(itemsSchema.$ref);\n resolved = dereferenceRef(itemsSchema, api);\n }\n } else {\n resolved = itemsSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey,\n schema: resolved,\n parentIsArray: true,\n });\n }\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: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\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.parentKey && 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, api, opts, seenRefs);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema, parentIsArray: entryIsArray }) => {\n if (isRef(subschema)) {\n const resolved = dereferenceRef(subschema, api);\n if (resolved && !isRef(resolved)) {\n return resolved;\n }\n\n return false;\n }\n\n return getTypedFormatsInSchema(\n format,\n subschema,\n api,\n {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: entryIsArray,\n },\n seenRefs,\n );\n })\n .filter(Boolean);\n } catch {\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\n/**\n * Extract content type from a parameter's `content` field.\n * According to OAS spec, when `content` is present, `style` and `explode` are ignored.\n * We prioritize `application/json` and other JSON-like content types over other content types.\n * Note: this is just a safe guard. In OAS parser, we enforce that there is exactly one content type.\n *\n * @param param - The parameter object\n * @returns The content type, or `null` if no content is present\n */\nexport function getParameterContentType(param: ParameterObject): string | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const contentKeys = Object.keys(param.content);\n if (contentKeys.length < 1) {\n return null;\n }\n\n return getParameterContentTypeUtil(contentKeys) || null;\n}\n\n/**\n * Extract schema from a parameter's `content` field.\n *\n * @param param - The parameter object\n * @param contentType - The content type\n * @returns The schema, or `null` if no schema is present\n */\nexport function getParameterContentSchema(param: ParameterObject, contentType: string): SchemaObject | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const mediaTypeObject = param.content[contentType];\n if (typeof mediaTypeObject === 'object' && mediaTypeObject && 'schema' in mediaTypeObject && mediaTypeObject.schema) {\n return isRef(mediaTypeObject.schema) ? null : (mediaTypeObject.schema as SchemaObject);\n }\n\n return null;\n}\n\n/**\n * Recursively parse string values that are valid JSON.\n *\n * This is used when we're dealing with objects that have nested `format: json` descriptors.\n */\nexport function parseJSONStrings(obj: unknown): unknown {\n if (typeof obj === 'string') {\n try {\n const p = JSON.parse(obj);\n return typeof p === 'object' && p !== null ? parseJSONStrings(p) : p;\n } catch {\n return obj;\n }\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStrings);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStrings(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\n/**\n * Like {@link parseJSONStrings} but only parses string values that are clearly JSON objects or\n * arrays (after trim, starts with `{` or `[`). Used for payload keys that are not declared on the\n * schema's `properties` map so numerical strings are not coerced into numbers.\n */\nfunction parseJSONStringsObjectContainersOnly(obj: unknown): unknown {\n if (typeof obj === 'string') {\n const trimmed = obj.trim();\n if (trimmed.startsWith('{') || trimmed.startsWith('[')) {\n try {\n const parsed = JSON.parse(obj);\n return parseJSONStringsObjectContainersOnly(parsed);\n } catch {\n return obj;\n }\n }\n\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStringsObjectContainersOnly);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\nfunction mergePropertiesFromAllOf(\n allOf: SchemaObject[],\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n const merged: Record<string, SchemaObject> = {};\n let found = false;\n\n for (const branch of allOf) {\n // oxlint-disable-next-line no-use-before-define\n const collected = collectSchemaObjectProperties(branch, api, new Set(seenRefs));\n if (collected) {\n found = true;\n Object.assign(merged, collected);\n }\n }\n\n return found ? merged : undefined;\n}\n\nfunction collectSchemaObjectProperties(\n schema: SchemaObject,\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n let node: SchemaObject | undefined = schema;\n\n if (isRef(node)) {\n if (seenRefs.has(node.$ref)) {\n return undefined;\n }\n\n seenRefs.add(node.$ref);\n const deref = dereferenceRef(node, api);\n if (!deref || isRef(deref)) {\n return undefined;\n }\n\n node = deref;\n }\n\n const safe = unwrapFirstPolymorphicBranch(node);\n if (isRef(safe)) {\n return collectSchemaObjectProperties(safe, api, seenRefs);\n }\n\n node = safe;\n\n if (node) {\n if ('allOf' in node && Array.isArray(node.allOf) && node.allOf.length) {\n return mergePropertiesFromAllOf(node.allOf as SchemaObject[], api, seenRefs);\n }\n\n if (node.properties && typeof node.properties === 'object') {\n return node.properties as Record<string, SchemaObject>;\n }\n }\n\n return undefined;\n}\n\nfunction getPayloadPropertyKeys(payload: unknown): string[] {\n if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {\n return [];\n }\n\n return Object.keys(payload as Record<string, unknown>).filter(\n k => typeof (payload as Record<string, unknown>)[k] !== 'undefined',\n );\n}\n\nfunction getPolymorphicSchema(node: SchemaObject): SchemaObject[] | null {\n return node.oneOf && Array.isArray(node.oneOf) && node.oneOf.length\n ? (node.oneOf as SchemaObject[])\n : node.anyOf && Array.isArray(node.anyOf) && node.anyOf.length\n ? (node.anyOf as SchemaObject[])\n : null;\n}\n\n/**\n * Choose a single branch from a polymorphic schema that best matches the payload we have.\n *\n * A branch matches when every non-`undefined` payload key exists on that branch's merged object\n * properties. If we have no payload, or no branches match, we use the first branch.\n *\n * When several branches match the one with the fewest declared properties wins, which would get us\n * as close to a best match as possible, however having more data in our payload would give us more\n * insight into which branch is what the user wants.\n */\nfunction pickPolymorphicBranch(alternatives: SchemaObject[], keys: string[], api: OASDocument): SchemaObject {\n if (!keys.length) {\n return alternatives[0];\n }\n\n const scored = alternatives.map((branch, idx) => {\n const props = collectSchemaObjectProperties(branch, api, new Set<string>());\n const allMatch = Boolean(props && keys.every(k => Object.prototype.hasOwnProperty.call(props, k)));\n const propCount = props ? Object.keys(props).length : Number.POSITIVE_INFINITY;\n\n return { idx, branch, allMatch, propCount };\n });\n\n const matches = scored.filter(entry => entry.allMatch);\n if (matches.length === 1) return matches[0].branch;\n if (matches.length > 1) {\n matches.sort((a, b) => a.propCount - b.propCount || a.idx - b.idx);\n return matches[0].branch;\n }\n\n return scored[0].branch;\n}\n\n/**\n * Resolve a request-body JSON Schema against a concrete payload.\n *\n */\nexport function getSafeRequestBody(schema: SchemaObject, payload: unknown, api: OASDocument): SchemaObject {\n // This isn't ideal but let's do a full dereference of our current schema so we can quickly pick\n // up and determine the polymorphic branch we need to use for this payload.\n let resolved = dereferenceRefDeep(schema, api);\n\n const keys = getPayloadPropertyKeys(payload);\n\n // Stop when `resolved` has no top-level polymorphic schema. Each pass replaces `resolved` with\n // one branch, which may still be polymorphic, so the increment step recomputes `alternatives`\n // from the new `resolved`.\n for (\n let alternatives = getPolymorphicSchema(resolved);\n alternatives != null;\n alternatives = getPolymorphicSchema(resolved)\n ) {\n resolved = pickPolymorphicBranch(alternatives, keys, api);\n }\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set());\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n return resolved;\n}\n\n/**\n * Recursively runs through a schema, parsing any values that have `format: json` attached and\n * deserializing them into their JSON representations.\n *\n * @see {@link parseJSONStrings}\n */\nexport function parseJSONStringsInBodyWithSchema(\n obj: unknown,\n schema: SchemaObject | undefined,\n api: OASDocument,\n seenRefs: Set<string> = new Set(),\n): unknown {\n // If there's no schema then we should parse any strings that look like JSON.\n if (schema === undefined) return parseJSONStrings(obj);\n\n let resolved: SchemaObject = schema;\n if (isRef(schema)) {\n // If we have already processed this `$ref` before then we should stop all schema-guiding\n // parsing behaviors so we don't infinitely recurse.\n if (seenRefs.has(schema.$ref)) {\n return parseJSONStrings(obj);\n }\n\n seenRefs.add(schema.$ref);\n const deref = dereferenceRef(schema, api);\n if (!deref || isRef(deref)) {\n return parseJSONStrings(obj);\n }\n\n resolved = deref;\n }\n\n // If our resolved schema is a polymorphic `oneOf` or `anyOf` schema then we should use the first\n // branch of the schema to guide our parsing behavior. If the schema is _not_ polymorphic then\n // we'll use that schema as-is.\n const safe = getSafeRequestBody(resolved, obj, api);\n if (isRef(safe)) {\n return parseJSONStringsInBodyWithSchema(obj, safe, api, seenRefs);\n }\n\n resolved = safe;\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set(seenRefs));\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n if (typeof obj === 'string') {\n // If the schema is a string but does **not** have `format: json` then it should be left alone.\n if (hasSchemaType(resolved, 'string') && resolved.format !== 'json') {\n return obj;\n }\n\n return parseJSONStrings(obj);\n }\n\n if (Array.isArray(obj)) {\n // @ts-expect-error -- `items` exists in schema objects, just the typing on `SchemaObject` is very messy.\n let items = resolved.items as SchemaObject | undefined;\n if (items && typeof items === 'object' && isRef(items)) {\n // If we've already processed this `$ref` before then we should stop all schema-guided\n // parsing behaviors so we don't infinitely recurse, instead treating what we have as it is\n // and parsing anything that looks like JSON.\n if (seenRefs.has(items.$ref)) {\n return obj.map(item => parseJSONStrings(item));\n }\n\n seenRefs.add(items.$ref);\n const derefItems = dereferenceRef(items, api);\n items = derefItems && !isRef(derefItems) ? derefItems : undefined;\n }\n\n return obj.map(item => parseJSONStringsInBodyWithSchema(item, items, api, new Set(seenRefs)));\n }\n\n if (obj !== null && typeof obj === 'object') {\n // If we have an object schema that doesn't have any `properties` then we should just parse\n // anything that looks like JSON within whatever we _do_ have here.\n if (!resolved.properties || typeof resolved.properties !== 'object') {\n return parseJSONStrings(obj);\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n const propSchema = resolved.properties[k] as SchemaObject | undefined;\n out[k] =\n propSchema !== undefined\n ? parseJSONStringsInBodyWithSchema(v, propSchema, api, new Set(seenRefs))\n : parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n","// oxlint-disable no-use-before-define\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 {\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 // oxlint-disable-next-line no-param-reassign -- 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 // oxlint-disable-next-line readme/json-parse-try-catch\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 // Handle null values explicitly to prevent join() from converting to empty string\n if (str === null) {\n return 'null';\n }\n\n const result = encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n return result;\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 // no-op\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 // no-op\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 // no-op\n }\n}\n"],"mappings":";;;;;AAeA,SAAS,SAAS,oBAAoB;AACtC,OAAO,SAAS;AAChB,SAAS,SAAS,qBAAqB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,SAAAA,cAAa;AACtB,SAAS,iBAAiB,mBAAAC,wBAAuB;AACj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YAAI,cAAc,MAAM,SAAS,iBAAiB;AAChD,cAAI,IAAI,cAAc,IAAI,EAAE,KAAK,OAAK,EAAE,SAAS,cAAc,MAAM,IAAI,GAAG;AAC1E;AAAA,UACF;AAAA,QACF;AAGA,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":["isRef","matchesMimeType","value","isRef","matchesMimeType"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/lib/lodash.ts","../src/lib/style-formatting/index.ts","../src/lib/utils.ts","../src/lib/style-formatting/style-serializer.ts"],"sourcesContent":["import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\nimport type { PostData, PostDataParams, Request } from 'har-format';\nimport type { Extensions } from 'oas/extensions';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n SchemaObject,\n SchemaWrapper,\n ServerVariable,\n} from 'oas/types';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport Oas from 'oas';\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 {\n getParameterContentSchema,\n getParameterContentType,\n getTypedFormatsInSchema,\n getSafeRequestBody,\n hasSchemaType,\n parseJSONStringsInBodyWithSchema,\n} 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 (param.required && param.content) {\n const contentType = getParameterContentType(param);\n const schema = contentType ? getParameterContentSchema(param, contentType) : null;\n value = 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. Content-based header params also need formatting to properly serialize values\n // (e.g. JSON.stringify objects) instead of passing raw objects through. However, schema-based\n // header params should NOT be formatted as this would incorrectly URL-encode their values.\n if (type === 'query' || (type === 'header' && param.content)) {\n return formatStyle(value, param);\n }\n\n return value;\n }\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 const propertySchema = schema.properties[key];\n const isObjectSchema = typeof propertySchema === 'object' && propertySchema !== null && !isRef(propertySchema);\n const hasObjectType =\n isObjectSchema &&\n // OAS 3.1 uses JSON Schema union types, so object schemas can appear as\n // `type: ['object', 'null']` or another union that includes `object`.\n (Array.isArray(propertySchema.type)\n ? propertySchema.type.includes('object')\n : propertySchema.type === 'object');\n const hasObjectProperties =\n isObjectSchema && typeof propertySchema.properties === 'object' && propertySchema.properties !== null;\n const shouldDefaultNestedMultipartObject = !paramEncoding && (hasObjectType || hasObjectProperties);\n\n return {\n name: key,\n // Preserve nested multipart object paths as form fields unless the spec supplies explicit\n // encoding for this property.\n style: paramEncoding ? paramEncoding.style : shouldDefaultNestedMultipartObject ? 'deepObject' : undefined,\n explode: paramEncoding ? paramEncoding.explode : shouldDefaultNestedMultipartObject ? true : 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(\n removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n }),\n );\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return String(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 const currentOas = Oas.init(oas as unknown as OASDocument);\n operation = new Operation(\n currentOas,\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(statusCode => {\n // `getResponseByStatusCode` will lazily dereference the response if it's a `$ref` pointer.\n const response = operation.getResponseByStatusCode(statusCode);\n if (!response) return false;\n\n const content = response.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 a `content-type` header set up in the form data, but it hasn't been added yet?\n const contentTypeFormHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'content-type');\n if (contentTypeFormHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'content-type')) {\n hasContentType = true;\n contentType = String(formData.header[contentTypeFormHeader]);\n har.headers.push({\n name: 'content-type',\n value: contentType,\n });\n }\n\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;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(formData.formData, { preserveNullishArrays: true });\n\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(formData.body, {\n preserveNullishArrays: true,\n preserveEmptyArray: true,\n });\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, formData.body, operation.api);\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 if (\n !safeBodySchema.properties?.[key] ||\n typeof safeBodySchema.properties[key] !== 'object' ||\n safeBodySchema.properties[key] === null\n ) {\n return false;\n }\n\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 let multipartParams: ParameterObject[] = [];\n\n const multipartContent = operation.getRequestBody('multipart/form-data');\n if (multipartContent) {\n multipartParams = multipartBodyToFormatterParams(\n formData.body,\n multipartContent.mediaTypeObject,\n safeBodySchema,\n );\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, operation.api, {\n payload: cleanBody,\n });\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 {\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 {\n har.postData.text = stringify(formData.body);\n }\n } else {\n // If no `format: json` paths are found then we should recursively parse any string\n // values that are valid JSON so `format: json` is still resolved for our\n // `application/json` payload.\n try {\n const parsed: any = parseJSONStringsInBodyWithSchema(cleanBody, requestBodySchema, operation.api);\n if (typeof parsed?.RAW_BODY !== 'undefined') {\n har.postData.text = isPrimitive(parsed.RAW_BODY)\n ? String(parsed.RAW_BODY)\n : stringify(parsed.RAW_BODY as Record<string | 'RAW_BODY', unknown>);\n } else {\n har.postData.text = JSON.stringify(parsed);\n }\n } catch {\n har.postData.text = encodeBodyForHAR(formData.body);\n }\n }\n }\n }\n } catch {\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 { StylizerConfig } from './style-serializer.js';\nimport type { ParameterObject, SchemaObject } from 'oas/types';\n\nimport { matchesMimeType } from 'oas/utils';\nimport qs from 'qs';\n\nimport { getParameterContentType } from '../utils.js';\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;\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 * If content is present, we should use the content type to format the value. We also ignore the style and explode settings.\n *\n * @see {@link https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content}\n */\n if (parameter.content && (parameter.in === 'query' || parameter.in === 'header')) {\n const contentType = getParameterContentType(parameter);\n if (!contentType) {\n return;\n }\n\n /**\n * @todo Handle other content types\n */\n let serialized: string;\n if (matchesMimeType.json(contentType)) {\n serialized = JSON.stringify(value);\n } else {\n serialized = String(value);\n }\n\n return parameter.in === 'query' ? encodeURIComponent(serialized) : serialized;\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 !parameter.content\n );\n}\n\nexport 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 (\n !parameter.content &&\n parameter.style === 'deepObject' &&\n (!value || typeof value !== 'object' || parameter.explode === false)\n ) {\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","import type { OASDocument, ParameterObject, SchemaObject } from 'oas/types';\n\nimport { isRef } from 'oas/types';\nimport { dereferenceRef, dereferenceRefDeep, getParameterContentType as getParameterContentTypeUtil } from 'oas/utils';\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 * When we only have a schema fragment (no request payload), peel a single top-level polymorphic\n * schema to its first branch so we can enumerate its properties.\n *\n */\nfunction unwrapFirstPolymorphicBranch(obj: SchemaObject): SchemaObject {\n if (obj.oneOf && Array.isArray(obj.oneOf) && obj.oneOf.length) {\n return unwrapFirstPolymorphicBranch(obj.oneOf[0] as SchemaObject);\n }\n\n if (obj.anyOf && Array.isArray(obj.anyOf) && obj.anyOf.length) {\n return unwrapFirstPolymorphicBranch(obj.anyOf[0] as SchemaObject);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\ninterface SubschemaEntry {\n key: string;\n parentIsArray?: boolean;\n schema: SchemaObject;\n}\n\nfunction getSubschemas(\n schema: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\n): SubschemaEntry[] | false {\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: SubschemaEntry[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n const foundSubschemas = getSubschemas(\n schema,\n api,\n {\n ...opts,\n parentIsArray: false,\n parentKey: opts.parentKey ? [opts.parentKey, idx].join('.') : String(idx),\n },\n seenRefs,\n );\n\n if (foundSubschemas) {\n subschemas = subschemas.concat(foundSubschemas);\n }\n }\n } else {\n let resolvedSchema = schema;\n if (schema && isRef(schema)) {\n // Skip $refs we've already visited to prevent infinite recursion on circular references\n if (seenRefs.has(schema.$ref)) {\n return subschemas;\n }\n seenRefs.add(schema.$ref);\n\n resolvedSchema = dereferenceRef(schema, api);\n if (!resolvedSchema || isRef(resolvedSchema)) {\n return subschemas;\n }\n }\n\n const baseKey = opts.parentKey ?? '';\n\n // Collect subschemas from this objects `properties`, dereferencing `$ref` pointers and\n // building up a collection of dot-notation keys for each schema.\n if (resolvedSchema.properties && typeof resolvedSchema.properties === 'object') {\n for (const [propName, propSchema] of Object.entries(resolvedSchema.properties)) {\n if (propSchema && typeof propSchema === 'object') {\n let resolved: SchemaObject | undefined;\n if (isRef(propSchema)) {\n if (seenRefs.has(propSchema.$ref)) {\n // oxlint-disable-next-line no-continue\n continue;\n }\n\n seenRefs.add(propSchema.$ref);\n resolved = dereferenceRef(propSchema, api);\n } else {\n resolved = propSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: resolved,\n });\n }\n }\n }\n }\n\n // When the schema has no formal `properties` we need to enumerate through each of its available\n // property keys, collecting subschemas and dot-notation keysfrom each value. Generally we'll\n // hit this block when processing data like OpenAPI Media Type objects.\n if (\n !('properties' in resolvedSchema) &&\n typeof resolvedSchema === 'object' &&\n !('type' in resolvedSchema && resolvedSchema.type !== 'object')\n ) {\n for (const [propName, propSchema] of Object.entries(resolvedSchema)) {\n if (propSchema && (Array.isArray(propSchema) || (typeof propSchema === 'object' && propSchema !== null))) {\n const raw = unwrapFirstPolymorphicBranch(propSchema as SchemaObject);\n const resolved = isRef(raw) ? dereferenceRef(raw, api) : raw;\n const toPush = resolved && !isRef(resolved) ? resolved : raw;\n if (toPush && typeof toPush === 'object') {\n subschemas.push({\n key: baseKey ? [baseKey, propName].join('.') : propName,\n schema: toPush,\n });\n }\n }\n }\n }\n\n if ('items' in resolvedSchema && resolvedSchema.items !== undefined && resolvedSchema.items !== true) {\n const itemsSchema = resolvedSchema.items as SchemaObject;\n let resolved: SchemaObject | undefined;\n if (isRef(itemsSchema)) {\n if (!seenRefs.has(itemsSchema.$ref)) {\n seenRefs.add(itemsSchema.$ref);\n resolved = dereferenceRef(itemsSchema, api);\n }\n } else {\n resolved = itemsSchema;\n }\n\n if (resolved && !isRef(resolved)) {\n subschemas.push({\n key: baseKey,\n schema: resolved,\n parentIsArray: true,\n });\n }\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: SchemaObject,\n api: OASDocument,\n opts: Options,\n seenRefs: Set<string> = new Set(),\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.parentKey && 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, api, opts, seenRefs);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema, parentIsArray: entryIsArray }) => {\n if (isRef(subschema)) {\n const resolved = dereferenceRef(subschema, api);\n if (resolved && !isRef(resolved)) {\n return resolved;\n }\n\n return false;\n }\n\n return getTypedFormatsInSchema(\n format,\n subschema,\n api,\n {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: entryIsArray,\n },\n seenRefs,\n );\n })\n .filter(Boolean);\n } catch {\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\n/**\n * Extract content type from a parameter's `content` field.\n * According to OAS spec, when `content` is present, `style` and `explode` are ignored.\n * We prioritize `application/json` and other JSON-like content types over other content types.\n * Note: this is just a safe guard. In OAS parser, we enforce that there is exactly one content type.\n *\n * @param param - The parameter object\n * @returns The content type, or `null` if no content is present\n */\nexport function getParameterContentType(param: ParameterObject): string | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const contentKeys = Object.keys(param.content);\n if (contentKeys.length < 1) {\n return null;\n }\n\n return getParameterContentTypeUtil(contentKeys) || null;\n}\n\n/**\n * Extract schema from a parameter's `content` field.\n *\n * @param param - The parameter object\n * @param contentType - The content type\n * @returns The schema, or `null` if no schema is present\n */\nexport function getParameterContentSchema(param: ParameterObject, contentType: string): SchemaObject | null {\n if (!('content' in param) || typeof param.content !== 'object' || !param.content) {\n return null;\n }\n\n const mediaTypeObject = param.content[contentType];\n if (typeof mediaTypeObject === 'object' && mediaTypeObject && 'schema' in mediaTypeObject && mediaTypeObject.schema) {\n return isRef(mediaTypeObject.schema) ? null : (mediaTypeObject.schema as SchemaObject);\n }\n\n return null;\n}\n\n/**\n * Recursively parse string values that are valid JSON.\n *\n * This is used when we're dealing with objects that have nested `format: json` descriptors.\n */\nexport function parseJSONStrings(obj: unknown): unknown {\n if (typeof obj === 'string') {\n try {\n const p = JSON.parse(obj);\n return typeof p === 'object' && p !== null ? parseJSONStrings(p) : p;\n } catch {\n return obj;\n }\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStrings);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStrings(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\n/**\n * Like {@link parseJSONStrings} but only parses string values that are clearly JSON objects or\n * arrays (after trim, starts with `{` or `[`). Used for payload keys that are not declared on the\n * schema's `properties` map so numerical strings are not coerced into numbers.\n */\nfunction parseJSONStringsObjectContainersOnly(obj: unknown): unknown {\n if (typeof obj === 'string') {\n const trimmed = obj.trim();\n if (trimmed.startsWith('{') || trimmed.startsWith('[')) {\n try {\n const parsed = JSON.parse(obj);\n return parseJSONStringsObjectContainersOnly(parsed);\n } catch {\n return obj;\n }\n }\n\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(parseJSONStringsObjectContainersOnly);\n }\n\n if (obj !== null && typeof obj === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n\nfunction getAdditionalPropertiesSchema(schema: SchemaObject): SchemaObject | undefined {\n return schema.additionalProperties && typeof schema.additionalProperties === 'object'\n ? (schema.additionalProperties as SchemaObject)\n : undefined;\n}\n\nfunction mergePropertiesFromAllOf(\n allOf: SchemaObject[],\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n const merged: Record<string, SchemaObject> = {};\n let found = false;\n\n for (const branch of allOf) {\n // oxlint-disable-next-line no-use-before-define\n const collected = collectSchemaObjectProperties(branch, api, new Set(seenRefs));\n if (collected) {\n found = true;\n Object.assign(merged, collected);\n }\n }\n\n return found ? merged : undefined;\n}\n\nfunction collectSchemaObjectProperties(\n schema: SchemaObject,\n api: OASDocument,\n seenRefs: Set<string>,\n): Record<string, SchemaObject> | undefined {\n let node: SchemaObject | undefined = schema;\n\n if (isRef(node)) {\n if (seenRefs.has(node.$ref)) {\n return undefined;\n }\n\n seenRefs.add(node.$ref);\n const deref = dereferenceRef(node, api);\n if (!deref || isRef(deref)) {\n return undefined;\n }\n\n node = deref;\n }\n\n const safe = unwrapFirstPolymorphicBranch(node);\n if (isRef(safe)) {\n return collectSchemaObjectProperties(safe, api, seenRefs);\n }\n\n node = safe;\n\n if (node) {\n if ('allOf' in node && Array.isArray(node.allOf) && node.allOf.length) {\n return mergePropertiesFromAllOf(node.allOf as SchemaObject[], api, seenRefs);\n }\n\n if (node.properties && typeof node.properties === 'object') {\n return node.properties as Record<string, SchemaObject>;\n }\n }\n\n return undefined;\n}\n\nfunction getPayloadPropertyKeys(payload: unknown): string[] {\n if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {\n return [];\n }\n\n return Object.keys(payload as Record<string, unknown>).filter(\n k => typeof (payload as Record<string, unknown>)[k] !== 'undefined',\n );\n}\n\nfunction getPolymorphicSchema(node: SchemaObject): SchemaObject[] | null {\n return node.oneOf && Array.isArray(node.oneOf) && node.oneOf.length\n ? (node.oneOf as SchemaObject[])\n : node.anyOf && Array.isArray(node.anyOf) && node.anyOf.length\n ? (node.anyOf as SchemaObject[])\n : null;\n}\n\n/**\n * Choose a single branch from a polymorphic schema that best matches the payload we have.\n *\n * A branch matches when every non-`undefined` payload key exists on that branch's merged object\n * properties. If we have no payload, or no branches match, we use the first branch.\n *\n * When several branches match the one with the fewest declared properties wins, which would get us\n * as close to a best match as possible, however having more data in our payload would give us more\n * insight into which branch is what the user wants.\n */\nfunction pickPolymorphicBranch(alternatives: SchemaObject[], keys: string[], api: OASDocument): SchemaObject {\n if (!keys.length) {\n return alternatives[0];\n }\n\n const scored = alternatives.map((branch, idx) => {\n const props = collectSchemaObjectProperties(branch, api, new Set<string>());\n const allMatch = Boolean(props && keys.every(k => Object.prototype.hasOwnProperty.call(props, k)));\n const propCount = props ? Object.keys(props).length : Number.POSITIVE_INFINITY;\n\n return { idx, branch, allMatch, propCount };\n });\n\n const matches = scored.filter(entry => entry.allMatch);\n if (matches.length === 1) return matches[0].branch;\n if (matches.length > 1) {\n matches.sort((a, b) => a.propCount - b.propCount || a.idx - b.idx);\n return matches[0].branch;\n }\n\n return scored[0].branch;\n}\n\n/**\n * Resolve a request-body JSON Schema against a concrete payload.\n *\n */\nexport function getSafeRequestBody(schema: SchemaObject, payload: unknown, api: OASDocument): SchemaObject {\n // This isn't ideal but let's do a full dereference of our current schema so we can quickly pick\n // up and determine the polymorphic branch we need to use for this payload.\n let resolved = dereferenceRefDeep(schema, api);\n\n const keys = getPayloadPropertyKeys(payload);\n\n // Stop when `resolved` has no top-level polymorphic schema. Each pass replaces `resolved` with\n // one branch, which may still be polymorphic, so the increment step recomputes `alternatives`\n // from the new `resolved`.\n for (\n let alternatives = getPolymorphicSchema(resolved);\n alternatives != null;\n alternatives = getPolymorphicSchema(resolved)\n ) {\n resolved = pickPolymorphicBranch(alternatives, keys, api);\n }\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set());\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n return resolved;\n}\n\n/**\n * Recursively runs through a schema, parsing any values that have `format: json` attached and\n * deserializing them into their JSON representations.\n *\n * @see {@link parseJSONStrings}\n */\nexport function parseJSONStringsInBodyWithSchema(\n obj: unknown,\n schema: SchemaObject | undefined,\n api: OASDocument,\n seenRefs: Set<string> = new Set(),\n): unknown {\n // If there's no schema then we should parse any strings that look like JSON.\n if (schema === undefined) return parseJSONStrings(obj);\n\n let resolved: SchemaObject = schema;\n if (isRef(schema)) {\n // If we have already processed this `$ref` before then we should stop all schema-guiding\n // parsing behaviors so we don't infinitely recurse.\n if (seenRefs.has(schema.$ref)) {\n return parseJSONStrings(obj);\n }\n\n seenRefs.add(schema.$ref);\n const deref = dereferenceRef(schema, api);\n if (!deref || isRef(deref)) {\n return parseJSONStrings(obj);\n }\n\n resolved = deref;\n }\n\n // If our resolved schema is a polymorphic `oneOf` or `anyOf` schema then we should use the first\n // branch of the schema to guide our parsing behavior. If the schema is _not_ polymorphic then\n // we'll use that schema as-is.\n const safe = getSafeRequestBody(resolved, obj, api);\n if (isRef(safe)) {\n return parseJSONStringsInBodyWithSchema(obj, safe, api, seenRefs);\n }\n\n resolved = safe;\n\n if ('allOf' in resolved && Array.isArray(resolved.allOf) && resolved.allOf.length) {\n const fromAllOf = mergePropertiesFromAllOf(resolved.allOf as SchemaObject[], api, new Set(seenRefs));\n if (fromAllOf && Object.keys(fromAllOf).length) {\n const existing =\n resolved.properties && typeof resolved.properties === 'object' && resolved.properties !== null\n ? resolved.properties\n : {};\n\n resolved = {\n ...resolved,\n type: 'object',\n properties: { ...fromAllOf, ...existing },\n } as SchemaObject;\n }\n }\n\n if (typeof obj === 'string') {\n // If the schema is a string but does **not** have `format: json` then it should be left alone.\n if (hasSchemaType(resolved, 'string') && resolved.format !== 'json') {\n return obj;\n }\n\n return parseJSONStrings(obj);\n }\n\n if (Array.isArray(obj)) {\n // @ts-expect-error -- `items` exists in schema objects, just the typing on `SchemaObject` is very messy.\n let items = resolved.items as SchemaObject | undefined;\n if (items && typeof items === 'object' && isRef(items)) {\n // If we've already processed this `$ref` before then we should stop all schema-guided\n // parsing behaviors so we don't infinitely recurse, instead treating what we have as it is\n // and parsing anything that looks like JSON.\n if (seenRefs.has(items.$ref)) {\n return obj.map(item => parseJSONStrings(item));\n }\n\n seenRefs.add(items.$ref);\n const derefItems = dereferenceRef(items, api);\n items = derefItems && !isRef(derefItems) ? derefItems : undefined;\n }\n\n return obj.map(item => parseJSONStringsInBodyWithSchema(item, items, api, new Set(seenRefs)));\n }\n\n if (obj !== null && typeof obj === 'object') {\n const additionalPropertiesSchema = getAdditionalPropertiesSchema(resolved);\n\n // If we have an object schema that doesn't have any `properties`, use a schema-object\n // `additionalProperties` as the schema for each key. Otherwise parse whatever we have loosely.\n if (!resolved.properties || typeof resolved.properties !== 'object') {\n if (additionalPropertiesSchema) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = parseJSONStringsInBodyWithSchema(v, additionalPropertiesSchema, api, new Set(seenRefs));\n }\n\n return out;\n }\n\n return parseJSONStrings(obj);\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n const propSchema = resolved.properties[k] as SchemaObject | undefined;\n const schemaForValue = propSchema ?? additionalPropertiesSchema;\n out[k] =\n schemaForValue !== undefined\n ? parseJSONStringsInBodyWithSchema(v, schemaForValue, api, new Set(seenRefs))\n : parseJSONStringsObjectContainersOnly(v);\n }\n\n return out;\n }\n\n return obj;\n}\n","// oxlint-disable no-use-before-define\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 {\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 // oxlint-disable-next-line no-param-reassign -- 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 // oxlint-disable-next-line readme/json-parse-try-catch\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 // Handle null values explicitly to prevent join() from converting to empty string\n if (str === null) {\n return 'null';\n }\n\n const result = encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n return result;\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 // no-op\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 // no-op\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 // no-op\n }\n}\n"],"mappings":";;;;;AAeA,SAAS,SAAS,oBAAoB;AACtC,OAAO,SAAS;AAChB,SAAS,SAAS,qBAAqB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,SAAAA,cAAa;AACtB,SAAS,iBAAiB,mBAAAC,wBAAuB;AACjD,OAAO,4BAA4B;;;ACZ5B,SAAS,IAAI,QAAiB,MAAoB;AAEvD,MAAI,CAAC,KAAM,QAAO;AAGlB,QAAM,YAAY,OAAO,IAAI,EAAE,MAAM,aAAa;AAGlD,QA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MimeType","out","value","isRef","matchesMimeType"]}
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": "33.1.1",
4
+ "version": "33.1.2",
5
5
  "author": "Jon Ursenbach <jon@ursenba.ch>",
6
6
  "license": "ISC",
7
7
  "sideEffects": false,