@readme/oas-to-har 27.3.3 → 28.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +149 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +135 -97
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","../src/index.ts","../src/lib/lodash.ts","../src/lib/style-formatting/index.ts","../src/lib/style-formatting/style-serializer.ts","../src/lib/utils.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAAA;AACA;AACA;ACcA,6CAAsC;AACtC,4CAAuC;AACvC,0CAA0B;AAC1B,kCAAsB;AACtB,kCAAiD;AACjD,kJAAmC;ADZnC;AACA;AEHO,SAAS,GAAA,CAAI,MAAA,EAAiB,IAAA,EAAoB;AAEvD,EAAA,GAAA,CAAI,CAAC,IAAA,EAAM,OAAO,KAAA,CAAA;AAGlB,EAAA,MAAM,UAAA,EAAY,MAAA,CAAO,IAAI,CAAA,CAAE,KAAA,CAAM,aAAa,CAAA;AAGlD,EAAA,MAAM,OAAA,kBAAS,SAAA,2BAAW,MAAA,mBAAO,CAAC,OAAA,EAAS,GAAA,EAAA,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,I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AA;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;ADuRuG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","sourcesContent":[null,"import type { PostData, PostDataParams, Request } from 'har-format';\nimport type Oas from 'oas';\nimport type { Extensions } from 'oas/extensions';\nimport type { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n ServerVariable,\n} from 'oas/types';\nimport type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport { HEADERS, PROXY_ENABLED } from 'oas/extensions';\nimport { Operation } from 'oas/operation';\nimport { isRef } from 'oas/types';\nimport { jsonSchemaTypes, matchesMimeType } from 'oas/utils';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport configureSecurity from './lib/configure-security.js';\nimport { get, set } from './lib/lodash.js';\nimport { formatStyle } from './lib/style-formatting/index.js';\nimport { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils.js';\n\nfunction formatter(\n values: DataForHAR,\n param: ParameterObject,\n type: 'body' | 'cookie' | 'header' | 'path' | 'query',\n onlyIfExists = false,\n) {\n if (param.style) {\n const value = values[type][param.name];\n // Note: Technically we could send everything through the format style and choose the proper\n // default for each `in` type (e.g. query defaults to form).\n return formatStyle(value, param);\n }\n\n let value: string | number | boolean | undefined;\n\n // Handle missing values\n if (typeof values[type][param.name] !== 'undefined') {\n value = values[type][param.name];\n } else if (onlyIfExists && !param.required) {\n value = undefined;\n } else if (param.required && param.schema && !isRef(param.schema) && param.schema.default) {\n value = param.schema.default;\n } else if (type === 'path') {\n // If we don't have any values for the path parameter, just use the name of the parameter as the\n // value so we don't try try to build a URL to something like `https://example.com/undefined`.\n return param.name;\n }\n\n // Handle file uploads. Specifically arrays of file uploads which need to be formatted very\n // specifically.\n if (\n param.schema &&\n !isRef(param.schema) &&\n param.schema.type === 'array' &&\n param.schema.items &&\n !isRef(param.schema.items) &&\n param.schema.items.format === 'binary'\n ) {\n if (Array.isArray(value)) {\n // If this is array of binary data then we shouldn't do anything because we'll prepare them\n // separately in the HAR in order to preserve `fileName` and `contentType` data within\n // `postData.params`. If we don't then the HAR we generate for this data will be invalid.\n return value;\n }\n\n return JSON.stringify(value);\n }\n\n if (value !== undefined) {\n // Query params should always be formatted, even if they don't have a `style` serialization\n // configured.\n if (type === 'query') {\n return formatStyle(value, param);\n }\n\n return value;\n }\n\n return undefined;\n}\n\nfunction multipartBodyToFormatterParams(payload: unknown, oasMediaTypeObject: MediaTypeObject, schema: SchemaObject) {\n const encoding = oasMediaTypeObject.encoding;\n\n if (typeof payload === 'object' && payload !== null) {\n return Object.keys(payload)\n .map(key => {\n // If we have an incoming parameter, but it's not in the schema ignore it.\n if (!schema.properties?.[key]) {\n return false;\n }\n\n const paramEncoding = encoding ? encoding[key] : undefined;\n\n return {\n name: key,\n // If the style isn't defined, use the default\n style: paramEncoding ? paramEncoding.style : undefined,\n // If explode isn't defined, use the default\n explode: paramEncoding ? paramEncoding.explode : undefined,\n required:\n (schema.required && typeof schema.required === 'boolean' && Boolean(schema.required)) ||\n (Array.isArray(schema.required) && schema.required.includes(key)),\n schema: schema.properties[key],\n in: 'body',\n };\n })\n .filter(Boolean) as ParameterObject[];\n }\n\n // Pretty sure that we'll never have anything but an object for multipart bodies, so returning\n // empty array if we get anything else.\n return [];\n}\n\nconst defaultFormDataTypes = Object.keys(jsonSchemaTypes).reduce((prev, curr) => {\n return Object.assign(prev, { [curr]: {} });\n}, {});\n\nfunction getResponseContentType(content: MediaTypeObject) {\n const types = Object.keys(content) || [];\n\n // If this response content has multiple types available we should always prefer the one that's\n // JSON-compatible. If they don't have one that is we'll return the first available, otherwise\n // if they don't have **any** repsonse content types present we'll assume it's JSON.\n if (types?.length) {\n const jsonType = types.find(t => matchesMimeType.json(t));\n if (jsonType) {\n return jsonType;\n }\n\n return types[0];\n }\n\n return 'application/json';\n}\n\nfunction isPrimitive(val: unknown) {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n\nfunction stringify(json: Record<string | 'RAW_BODY', unknown>) {\n return JSON.stringify(\n removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json, {\n preserveNullishArrays: true,\n }),\n );\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return param;\n } else if (Array.isArray(param) && param.every(isPrimitive)) {\n return String(param);\n }\n\n return JSON.stringify(param);\n}\n\nfunction appendHarValue(\n harParam: PostDataParams['params'] | Request['cookies'] | Request['headers'] | Request['queryString'],\n name: string,\n value: any,\n addtlData: {\n contentType?: string;\n fileName?: string;\n } = {},\n) {\n if (typeof value === 'undefined') return;\n\n if (Array.isArray(value)) {\n // If the formatter gives us an array, we're expected to add each array value as a new\n // parameter item with the same parameter name\n value.forEach(singleValue => {\n appendHarValue(harParam, name, singleValue);\n });\n } else if (typeof value === 'object' && value !== null) {\n // If the formatter gives us an object, we're expected to add each property value as a new\n // parameter item, each with the name of the property\n Object.keys(value).forEach(key => {\n appendHarValue(harParam, key, value[key]);\n });\n } else {\n // If the formatter gives us a non-array, non-object, we add it as is\n harParam.push({\n ...addtlData,\n name,\n value: String(value),\n });\n }\n}\n\nfunction encodeBodyForHAR(body: any) {\n if (isPrimitive(body)) {\n return body;\n } else if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n typeof body.RAW_BODY !== 'undefined'\n ) {\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload as a\n // raw string. https://docs.readme.com/docs/raw-body-content\n if (isPrimitive(body.RAW_BODY)) {\n return body.RAW_BODY;\n }\n\n return stringify(body.RAW_BODY);\n }\n\n return stringify(body);\n}\n\n// biome-ignore lint/style/noDefaultExport: This is fine for now.\nexport default function oasToHar(\n oas: Oas,\n operationSchema?: Operation,\n values: DataForHAR = {},\n auth: AuthForHAR = {},\n opts: oasToHarOptions = { proxyUrl: '' },\n): {\n log: {\n entries: readonly [\n {\n readonly request: Request;\n },\n ];\n };\n} {\n let operation: Operation;\n if (!operationSchema || typeof operationSchema.getParameters !== 'function') {\n /**\n * If `operationSchema` was supplied as a plain object instead of an instance of `Operation`\n * then we should create a new instance of it. We're doing it with a check on `getParameters`\n * instead of checking `instanceof Operation` because JS is very weird when it comes to\n * checking `instanceof` against classes. One instance of `Operation` may not always match up\n * with another if they're being loaded between two different libraries.\n *\n * It's weird. This is easier.\n */\n operation = new Operation(\n oas as unknown as OASDocument,\n operationSchema?.path || '',\n operationSchema?.method || ('' as HttpMethods),\n (operationSchema as unknown as OperationObject) || { path: '', method: '' },\n );\n } else {\n operation = operationSchema;\n }\n\n const apiDefinition = oas.getDefinition();\n\n const formData: DataForHAR = {\n ...defaultFormDataTypes,\n ...values,\n };\n\n if (!formData.server) {\n formData.server = {\n selected: 0,\n variables: oas.defaultVariables(0),\n };\n }\n\n // If the incoming `server.variables` is missing variables let's pad it out with defaults.\n formData.server.variables = {\n ...oas.defaultVariables(formData.server.selected),\n ...(formData.server.variables ? formData.server.variables : {}),\n };\n\n const har: Request = {\n cookies: [],\n headers: [],\n headersSize: 0,\n queryString: [],\n // @ts-expect-error This is fine because we're fleshing `postData` out further down.\n postData: {},\n bodySize: 0,\n method: operation.method.toUpperCase(),\n url: `${oas.url(formData.server.selected, formData.server.variables as ServerVariable)}${operation.path}`.replace(\n /\\s/g,\n '%20',\n ),\n httpVersion: 'HTTP/1.1',\n };\n\n if (opts.proxyUrl) {\n if (oas.getExtension(PROXY_ENABLED, operation)) {\n har.url = `${opts.proxyUrl}/${har.url}`;\n }\n }\n\n const parameters = operation.getParameters();\n\n har.url = har.url.replace(/{([-_a-zA-Z0-9[\\]]+)}/g, (full, key) => {\n if (!operation || !parameters) return key; // No path params at all\n\n // Find the path parameter or set a default value if it does not exist\n const parameter = parameters.find(param => param.name === key) || ({ name: key } as ParameterObject);\n\n // The library that handles our style processing already encodes uri elements. For everything\n // else we need to handle it here.\n if (!('style' in parameter) || !parameter.style) {\n return encodeURIComponent(formatter(formData, parameter, 'path'));\n }\n\n return formatter(formData, parameter, 'path');\n });\n\n const queryStrings = parameters?.filter(param => param.in === 'query');\n if (queryStrings?.length) {\n queryStrings.forEach(queryString => {\n const value = formatter(formData, queryString, 'query', true);\n appendHarValue(har.queryString, queryString.name, value);\n });\n }\n\n // Do we have any `cookie` parameters on the operation?\n const cookies = parameters?.filter(param => param.in === 'cookie');\n if (cookies?.length) {\n cookies.forEach(cookie => {\n const value = formatter(formData, cookie, 'cookie', true);\n appendHarValue(har.cookies, cookie.name, value);\n });\n }\n\n // Does this response have any documented content types?\n if (operation.schema.responses) {\n Object.keys(operation.schema.responses).some(response => {\n if (isRef(operation.schema.responses?.[response])) return false;\n\n const content = (operation.schema.responses?.[response] as ResponseObject).content;\n if (!content) return false;\n\n // If there's no `accept` header present we should add one so their eventual code snippet\n // follows best practices.\n if (Object.keys(formData.header || {}).find(h => h.toLowerCase() === 'accept')) return true;\n\n har.headers.push({\n name: 'accept',\n value: getResponseContentType(content),\n });\n\n return true;\n });\n }\n\n // Do we have any `header` parameters on the operation?\n let hasContentType = false;\n let contentType = operation.getContentType();\n const headers = parameters?.filter(param => param.in === 'header');\n if (headers?.length) {\n headers.forEach(header => {\n const value = formatter(formData, header, 'header', true);\n if (typeof value === 'undefined') return;\n\n if (header.name.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(value);\n }\n\n appendHarValue(har.headers, header.name, value);\n });\n }\n\n // Are there `x-headers` static headers configured for this OAS?\n const userDefinedHeaders = oas.getExtension(HEADERS, operation) as Extensions['headers'];\n if (userDefinedHeaders) {\n userDefinedHeaders.forEach(header => {\n if (typeof header.key === 'string' && header.key.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(header.value);\n }\n\n har.headers.push({\n name: String(header.key),\n value: String(header.value),\n });\n });\n }\n\n if (formData.header) {\n // Do we have an `accept` header set up in the form data, but it hasn't been added yet?\n const acceptHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'accept');\n if (acceptHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'accept')) {\n har.headers.push({\n name: 'accept',\n value: String(formData.header[acceptHeader]),\n });\n }\n\n // Do we have a manually-defined `authorization` header set up in the form data?\n const authorizationHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'authorization');\n if (authorizationHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'authorization')) {\n har.headers.push({\n name: 'authorization',\n value: String(formData.header[authorizationHeader]),\n });\n }\n }\n\n let requestBody: SchemaWrapper | undefined;\n if (operation.hasRequestBody()) {\n requestBody = operation.getParametersAsJSONSchema().find(payload => {\n // `formData` is used in our API Explorer for `application/x-www-form-urlencoded` endpoints\n // and if you have an operation with that, it will only ever have a `formData`. `body` is\n // used for all other payload shapes.\n return payload.type === (operation.isFormUrlEncoded() ? 'formData' : 'body');\n });\n }\n\n if (requestBody?.schema && Object.keys(requestBody.schema).length) {\n const requestBodySchema = requestBody.schema as SchemaObject;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(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, { preserveNullishArrays: true });\n\n if (isMultipart) {\n har.postData = { params: [], mimeType: 'multipart/form-data' };\n\n // Because some request body schema shapes might not always be a top-level `properties`,\n // instead nesting it in an `oneOf` or `anyOf` we need to extract the first usable\n // schema that we have in order to process this multipart payload.\n const safeBodySchema = getSafeRequestBody(requestBodySchema);\n\n /**\n * Discover all `{ type: string, format: binary }` properties, or arrays containing the\n * same, within the request body. If there are any, then that means that we're dealing\n * with a `multipart/form-data` request and need to treat the payload as\n * `postData.params` and supply filenames and content types for the files (if they're\n * available).\n *\n * @todo It'd be nice to replace this with `getTypedFormatsInSchema` instead.\n * @example `{ type: string, format: binary }`\n * @example `{ type: array, items: { type: string, format: binary } }`\n */\n const binaryTypes = Object.keys(safeBodySchema.properties).filter(key => {\n const propData = safeBodySchema.properties[key] as JSONSchema;\n if (propData.format === 'binary') {\n return true;\n } else if (\n propData.type === 'array' &&\n propData.items &&\n typeof propData.items === 'object' &&\n propData.items !== null &&\n (propData.items as JSONSchema).format === 'binary'\n ) {\n return true;\n }\n\n return false;\n });\n\n if (cleanBody !== undefined) {\n const multipartParams = multipartBodyToFormatterParams(\n formData.body,\n (operation.schema.requestBody as RequestBodyObject).content['multipart/form-data'],\n safeBodySchema,\n );\n\n if (multipartParams.length) {\n Object.keys(cleanBody).forEach(name => {\n const param = multipartParams.find(multipartParam => multipartParam.name === name);\n\n if (param) {\n // If we're dealing with a binary type, and the value is a valid data URL we should\n // parse out any available filename and content type to send along with the\n // parameter to interpreters like `fetch-har` can make sense of it and send a usable\n // payload.\n const addtlData: { contentType?: string; fileName?: string } = {};\n\n let value = formatter(formData, param, 'body', true);\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n value.forEach((val: string) => {\n if (binaryTypes.includes(name)) {\n const parsed = parseDataUrl(val);\n if (parsed) {\n addtlData.fileName = 'name' in parsed ? parsed.name : 'unknown';\n if ('contentType' in parsed) {\n addtlData.contentType = parsed.contentType;\n }\n }\n }\n\n appendHarValue(har.postData?.params || [], name, val, addtlData);\n });\n }\n });\n }\n }\n } else {\n har.postData = { mimeType: contentType, text: '' };\n\n if (\n hasSchemaType(requestBody.schema, 'string') ||\n hasSchemaType(requestBody.schema, 'integer') ||\n hasSchemaType(requestBody.schema, 'number') ||\n hasSchemaType(requestBody.schema, 'boolean')\n ) {\n har.postData.text = JSON.stringify(JSON.parse(cleanBody));\n } else {\n /**\n * Handle formatted JSON objects that have properties that accept arbitrary JSON.\n *\n * Find all `{ type: string, format: json }` properties in the schema because we need\n * to manually `JSON.parse` them before submit, otherwise they'll be escaped instead\n * of actual objects. We also only want values that the user has entered, so we drop\n * any `undefined` `cleanBody` keys.\n */\n const jsonTypes = getTypedFormatsInSchema('json', requestBodySchema.properties, { payload: cleanBody });\n\n if (Array.isArray(jsonTypes) && jsonTypes.length) {\n try {\n jsonTypes.forEach((prop: boolean | string) => {\n try {\n set(cleanBody, String(prop), JSON.parse(get(cleanBody, String(prop))));\n } catch {\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 har.postData.text = encodeBodyForHAR(formData.body);\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 { ParameterObject, SchemaObject } from 'oas/types';\nimport type { StylizerConfig } from './style-serializer.js';\n\nimport qs from 'qs';\n\nimport { stylize } from './style-serializer.js';\n\n// Certain styles don't support empty values.\nfunction shouldNotStyleEmptyValues(parameter: ParameterObject) {\n return ['simple', 'spaceDelimited', 'pipeDelimited', 'deepObject'].includes(parameter.style || '');\n}\n\nfunction shouldNotStyleReservedHeader(parameter: ParameterObject) {\n return ['accept', 'authorization', 'content-type'].includes(parameter.name.toLowerCase());\n}\n\n/**\n * Note: This isn't necessarily part of the spec. Behavior for the value 'undefined' is, well,\n * undefined. This code makes our system look better. If we wanted to be more accurate, we might\n * want to remove this, restore the un-fixed behavior for undefined and have our UI pass in empty\n * string instead of undefined.\n */\nfunction removeUndefinedForPath(value: any) {\n let finalValue = value;\n\n if (typeof finalValue === 'undefined') {\n return '';\n }\n\n if (Array.isArray(finalValue)) {\n finalValue = finalValue.filter(val => (val === undefined ? '' : val));\n\n if (finalValue.length === 0) {\n finalValue = '';\n }\n }\n\n if (typeof finalValue === 'object') {\n Object.keys(finalValue).forEach(key => {\n finalValue[key] = finalValue[key] === undefined ? '' : finalValue[key];\n });\n }\n\n return finalValue;\n}\n\nfunction stylizeValue(value: unknown, parameter: ParameterObject) {\n let finalValue = value;\n\n // Some styles don't work with empty values. We catch those there\n if (shouldNotStyleEmptyValues(parameter) && (typeof finalValue === 'undefined' || finalValue === '')) {\n // Paths need return an unstyled empty string instead of undefined so it's ignored in the final\n // path string.\n if (parameter.in === 'path') {\n return '';\n }\n\n // Everything but path should return undefined when unstyled so it's ignored in the final\n // parameter array.\n return undefined;\n }\n\n // Every style that adds their style to empty values should use emptystring for path parameters\n // instead of undefined to avoid the string `undefined`.\n if (parameter.in === 'path') {\n finalValue = removeUndefinedForPath(finalValue);\n }\n\n /**\n * Eventhough `accept`, `authorization`, and `content-type` headers can be defined as parameters,\n * they should be completely ignored when it comes to serialization.\n *\n * > If `in` is \"header\" and the `name` field is \"Accept\", \"Content-Type\" or \"Authorization\", the\n * > parameter definition SHALL be ignored.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10}\n */\n if (parameter.in === 'header' && shouldNotStyleReservedHeader(parameter)) {\n return value;\n }\n\n /**\n * All parameter types have a default `style` format so if they don't have one prescribed we\n * should still conform to what the spec defines.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterstyle}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterstyle}\n */\n let style = parameter.style;\n if (!style) {\n if (parameter.in === 'query') {\n style = 'form';\n } else if (parameter.in === 'path') {\n style = 'simple';\n } else if (parameter.in === 'header') {\n style = 'simple';\n } else if (parameter.in === 'cookie') {\n style = 'form';\n }\n }\n\n let explode = parameter.explode;\n if (explode === undefined && style === 'form') {\n /**\n * Per the spec if no `explode` is present but `style` is `form` then `explode` should default to `true`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-parameterexplode}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#user-content-parameterexplode}\n */\n explode = true;\n }\n\n return stylize({\n location: parameter.in as StylizerConfig['location'],\n value: finalValue,\n key: parameter.name,\n style: style as StylizerConfig['style'],\n explode,\n /**\n * @todo this parameter is optional to stylize. It defaults to false, and can accept falsy, truthy, or \"unsafe\".\n * I do not know if it is correct for query to use this. See style-serializer for more info\n */\n escape: true,\n ...(parameter.in === 'query' ? { isAllowedReserved: parameter.allowReserved || false } : {}),\n });\n}\n\nfunction handleDeepObject(value: any, parameter: ParameterObject) {\n return qs\n .stringify(value, {\n encoder(str, defaultEncoder, charset, type) {\n if (type === 'key') {\n // `str` will be here as `dog[treats][0]` but because the `qs` library doesn't have any\n // awareness of our OpenAPI parameters we need to rewrite it to slap the `parameter.name`\n // to the top, like `pets[dog][treats][0]`.\n const prefixedKey = str\n .split(/[[\\]]/g)\n .filter(Boolean)\n .map((k: string) => `[${k}]`)\n .join('');\n\n return `${parameter.name}${prefixedKey}`;\n } else if (type === 'value') {\n return stylizeValue(str, parameter);\n }\n },\n })\n .split('&')\n .map(item => {\n const split = item.split('=');\n return {\n label: split[0],\n // `qs` will coerce null values into being `undefined` string but we want to preserve them.\n value: split[1] === 'undefined' ? null : split[1],\n };\n });\n}\n\n// Explode is handled on its own, because style-serializer doesn't return what we expect for proper\n// HAR output.\nfunction handleExplode(value: any, parameter: ParameterObject) {\n // This is to handle the case of arrays of objects in the querystring\n // which is something that's not technically in the spec but since we're\n // using the `qs` module already, it's fairly easy for us to add support\n // for this use case.\n //\n // An example URL would be something like this:\n // https://example.com/?line_items[0][a_string]=abc&line_items[0][quantity]=1&line_items[1][a_string]=def&line_items[1][quantity]=2\n //\n // Some open issues discussing this here:\n // https://github.com/OAI/OpenAPI-Specification/issues/1706\n // https://github.com/OAI/OpenAPI-Specification/issues/1006\n //\n // Link to the spec for this:\n // https://github.com/OAI/OpenAPI-Specification/blob/36a3a67264cc1c4f1eff110cea3ebfe679435108/versions/3.1.0.md#style-examples\n if (\n Array.isArray(value) &&\n (parameter.schema as SchemaObject)?.type === 'array' &&\n parameter.style === 'deepObject'\n ) {\n const newObj: Record<string, unknown> = {};\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n return newObj;\n }\n\n if (Array.isArray(value)) {\n return value.map(val => {\n return stylizeValue(val, parameter);\n });\n }\n\n if (typeof value === 'object' && value !== null) {\n const newObj: Record<string, unknown> = {};\n\n Object.keys(value).forEach(key => {\n if (parameter.style === 'deepObject') {\n const deepObjs = handleDeepObject(value, parameter);\n deepObjs.forEach(obj => {\n newObj[obj.label] = obj.value;\n });\n } else {\n newObj[key] = stylizeValue(value[key], parameter);\n }\n });\n\n return newObj;\n }\n\n return stylizeValue(value, parameter);\n}\n\nfunction shouldExplode(parameter: ParameterObject) {\n return (\n (parameter.explode ||\n (parameter.explode !== false && parameter.style === 'form') ||\n // style: deepObject && explode: false doesn't exist so explode it always\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples\n parameter.style === 'deepObject') &&\n // header and path doesn't explode into separate parameters like query and cookie do\n parameter.in !== 'header' &&\n parameter.in !== 'path'\n );\n}\n\nexport function formatStyle(value: unknown, parameter: ParameterObject): any {\n // Deep object style only works on objects and arrays, and only works with explode=true.\n if (parameter.style === 'deepObject' && (!value || typeof value !== 'object' || parameter.explode === false)) {\n return undefined;\n }\n\n // This custom explode logic allows us to bubble up arrays and objects to be handled differently\n // by our HAR transformer. We need this because the `stylizeValue` function assumes we're building\n // strings, not richer data types.\n //\n // The first part of this conditional checks if `explode` is enabled. Explode is disabled for\n // everything by default except for forms.\n //\n // The second part of this conditional bypasses the custom explode logic for headers, because they\n // work differently, and `stylizeValue` is accurate.\n if (shouldExplode(parameter)) {\n return handleExplode(value, parameter);\n }\n\n return stylizeValue(value, parameter);\n}\n","/**\n * This file has been extracted and modified from `swagger-client`.\n *\n * @license Apache 2.0\n * @link https://npm.im/swagger-client\n * @link https://github.com/swagger-api/swagger-js/blob/master/src/execute/oas3/style-serializer.js\n */\n\nconst isRfc3986Reserved = (char: string) => \":/?#[]@!$&'()*+,;=\".indexOf(char) > -1;\nconst isRfc3986Unreserved = (char: string) => /^[a-z0-9\\-._~]+$/i.test(char);\n\nfunction isURIEncoded(value: string) {\n try {\n return decodeURIComponent(value) !== value;\n } catch {\n // `decodeURIComponent` will throw an exception if a string that has an un-encoded percent sign\n // in it (like 20%), o if it's throwing we can just assume that the value hasn't been encoded.\n return false;\n }\n}\n\nfunction isObject(value: unknown) {\n return typeof value === 'object' && value !== null;\n}\n\nfunction encodeDisallowedCharacters(\n str: string,\n {\n escape,\n returnIfEncoded = false,\n isAllowedReserved,\n }: {\n escape?: boolean | 'unsafe';\n isAllowedReserved?: boolean;\n returnIfEncoded?: boolean;\n } = {},\n parse?: boolean,\n): any {\n if (typeof str === 'number') {\n // biome-ignore lint/style/noParameterAssign: It is what it is.\n str = (str as number).toString();\n }\n\n if (returnIfEncoded) {\n if (isURIEncoded(str)) {\n return str;\n }\n }\n\n if (typeof str !== 'string' || !str.length) {\n return str;\n }\n\n if (!escape) {\n return str;\n }\n\n if (parse) {\n return JSON.parse(str);\n }\n\n // In ES6 you can do this quite easily by using the new ... spread operator. This causes the\n // string iterator (another new ES6 feature) to be used internally, and because that iterator is\n // designed to deal with code points rather than UCS-2/UTF-16 code units.\n return [...str]\n .map(char => {\n if (isRfc3986Unreserved(char)) {\n return char;\n }\n\n if (isRfc3986Reserved(char) && (escape === 'unsafe' || isAllowedReserved)) {\n return char;\n }\n\n const encoder = new TextEncoder();\n const encoded = Array.from(encoder.encode(char))\n .map(byte => `0${byte.toString(16).toUpperCase()}`.slice(-2))\n .map(encodedByte => `%${encodedByte}`)\n .join('');\n\n return encoded;\n })\n .join('');\n}\n\nexport interface StylizerConfig {\n escape: boolean | 'unsafe';\n explode?: boolean;\n isAllowedReserved?: boolean;\n key: string;\n location: 'body' | 'query';\n style: 'deepObject' | 'form' | 'label' | 'matrix' | 'pipeDelimited' | 'simple' | 'spaceDelimited';\n value: any;\n}\n\nexport function stylize(config: StylizerConfig): any {\n const { value } = config;\n\n if (Array.isArray(value)) {\n return encodeArray(config);\n }\n\n if (isObject(value)) {\n return encodeObject(config);\n }\n\n return encodePrimitive(config);\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeArray({\n location,\n key,\n value,\n style,\n explode,\n escape,\n isAllowedReserved = false,\n}: Omit<StylizerConfig, 'value'> & { value: string[] }) {\n const valueEncoder = (str: string) => {\n // 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 return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeObject({ location, key, value, style, explode, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n const valueKeys = Object.keys(value);\n\n switch (style) {\n /**\n * @example <caption>`style: simple` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100,G=200,B=150`\n *\n * @example <caption>`style: simple` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R,100,G,200,B,150`\n */\n case 'simple':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : ',';\n const prefix = prev ? `${prev},` : '';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: label` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R=100.G=200.B=150`\n *\n * @example <caption>`style: label` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R.100.G.200.B.150`\n */\n case 'label':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : '.';\n const prefix = prev ? `${prev}.` : '.';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;R=100;G=200;B=150`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;color=R,100,G,200,B,150`\n */\n case 'matrix':\n if (explode) {\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev};` : ';';\n\n return `${prefix}${curr}=${val}`;\n }, '');\n }\n\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev},` : `;${key}=`;\n\n return `${prefix}${curr},${val}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100&G=200&B=150`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color=R,100,G,200,B,150`\n */\n case 'form':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';\n const separator = explode ? '=' : ',';\n\n return `${prefix}${curr}${separator}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R%20100%20G%20200%20B%20150`\n */\n case 'spaceDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev} ` : '';\n\n return `${prefix}${curr} ${val}`;\n }, '');\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R|100|G|200|B|150`\n */\n case 'pipeDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}|` : '';\n\n return `${prefix}${curr}|${val}`;\n }, '');\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color[R]=100&color[G]=200&color[B]=150`\n */\n case 'deepObject':\n return valueKeys.reduce(curr => {\n const val = valueEncoder(value[curr]);\n return `${val}`;\n }, '');\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodePrimitive({ location, key, value, style, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query' || location === 'body',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `blue` → `blue`\n */\n case 'simple':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: label`</caption>\n * `blue` → `.blue`\n */\n case 'label':\n return `.${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: matrix`</caption>\n * `blue` → `;color=blue`\n */\n case 'matrix':\n if (value === '') {\n return `;${key}`;\n }\n\n return `;${key}=${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: form`</caption>\n * `blue` → `color=blue`\n */\n case 'form':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `blue` → n/a\n */\n case 'deepObject':\n return valueEncoder(value);\n\n default:\n return undefined;\n }\n}\n","import type { JSONSchema, SchemaObject } from 'oas/types';\n\nimport { get } from './lodash.js';\n\n/**\n * Determine if a schema `type` is, or contains, a specific discriminator.\n *\n */\nexport function hasSchemaType(\n schema: SchemaObject,\n discriminator: 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string',\n): boolean {\n if (Array.isArray(schema.type)) {\n return schema.type.includes(discriminator);\n }\n\n return schema.type === discriminator;\n}\n\n/**\n * Because some request body schema shapes might not always be a top-level `properties`, instead\n * nesting it in an `oneOf` or `anyOf` we need to extract the first usable schema that we have. If\n * we don't do this then these non-conventional request body schema payloads may not be properly\n * represented in the HAR that we generate.\n *\n */\nexport function getSafeRequestBody(obj: any): any {\n if ('oneOf' in obj) {\n return getSafeRequestBody(obj.oneOf[0]);\n } else if ('anyOf' in obj) {\n return getSafeRequestBody(obj.anyOf[0]);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\nfunction getSubschemas(schema: any, opts: Options) {\n let subSchemaDataSize = 0;\n if (opts.parentIsArray) {\n // If we don't have data for this parent schema in our body payload then we\n // shouldn't bother spidering further into the schema looking for more `format`s\n // for data that definitely doesn't exist.\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData === undefined || !Array.isArray(parentData)) {\n return false;\n }\n\n subSchemaDataSize = parentData.length;\n }\n\n let subschemas: any[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n subschemas = subschemas.concat(\n Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, idx, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n })),\n );\n }\n } else {\n subschemas = Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n }));\n }\n\n return subschemas;\n}\n\n/**\n * With a supplied JSON Schema object, spider through it for any schemas that may contain specific\n * kind of `format` that also happen to be within the current `requestBody` payload that we're\n * creating a HAR representation for.\n *\n */\nexport function getTypedFormatsInSchema(\n format: 'binary' | 'json',\n schema: any,\n opts: Options,\n): (boolean | string)[] | boolean | string {\n try {\n if (schema?.format === format) {\n if (opts.parentIsArray) {\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData !== undefined && Array.isArray(parentData)) {\n return Object.keys(parentData)\n .map(pdk => {\n const currentKey = [opts.parentKey, pdk].join('.');\n if (get(opts.payload, currentKey) !== undefined) {\n return currentKey;\n }\n\n return false;\n })\n .filter(Boolean);\n }\n } else if (opts.parentKey && get(opts.payload, opts.parentKey) !== undefined) {\n return opts.parentKey;\n } else if (opts.payload !== undefined) {\n // If this payload is present and we're looking for a specific format then we should assume\n // that the **root** schema of the request body is that format, and we aren't trafficking in\n // a nested object or array schema.\n return true;\n }\n\n return false;\n }\n\n const subschemas = getSubschemas(schema, opts);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema }) => {\n if ('properties' in subschema) {\n return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });\n } else if ('items' in subschema) {\n if ((subschema.items as JSONSchema)?.properties) {\n return getTypedFormatsInSchema(format, (subschema.items as JSONSchema).properties, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n return getTypedFormatsInSchema(format, subschema.items, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n // If this schema has neither `properties` or `items` then it's a regular schema\n // we can re-run.\n return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });\n })\n .filter(Boolean);\n } catch {\n // If this fails for whatever reason then we should act as if we didn't find any `format`'d\n // schemas.\n return [];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","../src/index.ts","../src/lib/lodash.ts","../src/lib/style-formatting/index.ts","../src/lib/utils.ts","../src/lib/style-formatting/style-serializer.ts"],"names":["isRef"],"mappings":"AAAA;AACE;AACF,wDAAA;AACA;AACA;ACcA,6CAAsC;AACtC,4CAAuC;AACvC,0CAA0B;AAC1B,kCAAsB;AACtB,kCAAiD;AACjD,kJAAmC;ADZnC;AACA;AEHO,SAAS,GAAA,CAAI,MAAA,EAAiB,IAAA,EAAoB;AAEvD,EAAA,GAAA,CAAI,CAAC,IAAA,EAAM,OAAO,KAAA,CAAA;AAGlB,EAAA,MAAM,UAAA,EAAY,MAAA,CAAO,IAAI,CAAA,CAAE,KAAA,CAAM,aAAa,CAAA;AAGlD,EAAA,MAAM,OAAA,kBAAS,SAAA,2BAAW,MAAA,mBAAO,CAAC,OAAA,EAAS,GAAA,EAAA,mBAAQ,OAAA,4BAAA,CAAU,GA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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;ADmTuG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas-to-har/dist/index.cjs","sourcesContent":[null,"import type { PostData, PostDataParams, Request } from 'har-format';\nimport type Oas from 'oas';\nimport type { Extensions } from 'oas/extensions';\nimport type { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';\nimport type {\n HttpMethods,\n JSONSchema,\n MediaTypeObject,\n OASDocument,\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n ServerVariable,\n} from 'oas/types';\nimport type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js';\n\nimport { parse as parseDataUrl } from '@readme/data-urls';\nimport { HEADERS, PROXY_ENABLED } from 'oas/extensions';\nimport { Operation } from 'oas/operation';\nimport { isRef } from 'oas/types';\nimport { jsonSchemaTypes, matchesMimeType } from 'oas/utils';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport configureSecurity from './lib/configure-security.js';\nimport { get, set } from './lib/lodash.js';\nimport { formatStyle } from './lib/style-formatting/index.js';\nimport {\n getParameterContentSchema,\n getParameterContentType,\n getSafeRequestBody,\n getTypedFormatsInSchema,\n hasSchemaType,\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.\n if (type === 'query') {\n return formatStyle(value, param);\n }\n\n return value;\n }\n\n return undefined;\n}\n\nfunction multipartBodyToFormatterParams(payload: unknown, oasMediaTypeObject: MediaTypeObject, schema: SchemaObject) {\n const encoding = oasMediaTypeObject.encoding;\n\n if (typeof payload === 'object' && payload !== null) {\n return Object.keys(payload)\n .map(key => {\n // If we have an incoming parameter, but it's not in the schema ignore it.\n if (!schema.properties?.[key]) {\n return false;\n }\n\n const paramEncoding = encoding ? encoding[key] : undefined;\n\n return {\n name: key,\n // If the style isn't defined, use the default\n style: paramEncoding ? paramEncoding.style : undefined,\n // If explode isn't defined, use the default\n explode: paramEncoding ? paramEncoding.explode : undefined,\n required:\n (schema.required && typeof schema.required === 'boolean' && Boolean(schema.required)) ||\n (Array.isArray(schema.required) && schema.required.includes(key)),\n schema: schema.properties[key],\n in: 'body',\n };\n })\n .filter(Boolean) as ParameterObject[];\n }\n\n // Pretty sure that we'll never have anything but an object for multipart bodies, so returning\n // empty array if we get anything else.\n return [];\n}\n\nconst defaultFormDataTypes = Object.keys(jsonSchemaTypes).reduce((prev, curr) => {\n return Object.assign(prev, { [curr]: {} });\n}, {});\n\nfunction getResponseContentType(content: MediaTypeObject) {\n const types = Object.keys(content) || [];\n\n // If this response content has multiple types available we should always prefer the one that's\n // JSON-compatible. If they don't have one that is we'll return the first available, otherwise\n // if they don't have **any** repsonse content types present we'll assume it's JSON.\n if (types?.length) {\n const jsonType = types.find(t => matchesMimeType.json(t));\n if (jsonType) {\n return jsonType;\n }\n\n return types[0];\n }\n\n return 'application/json';\n}\n\nfunction isPrimitive(val: unknown) {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n\nfunction stringify(json: Record<string | 'RAW_BODY', unknown>) {\n return JSON.stringify(\n removeUndefinedObjects(typeof json.RAW_BODY !== 'undefined' ? json.RAW_BODY : json, {\n preserveNullishArrays: true,\n }),\n );\n}\n\nfunction stringifyParameter(param: any): string {\n if (param === null || isPrimitive(param)) {\n return param;\n } else if (Array.isArray(param) && param.every(isPrimitive)) {\n return String(param);\n }\n\n return JSON.stringify(param);\n}\n\nfunction appendHarValue(\n harParam: PostDataParams['params'] | Request['cookies'] | Request['headers'] | Request['queryString'],\n name: string,\n value: any,\n addtlData: {\n contentType?: string;\n fileName?: string;\n } = {},\n) {\n if (typeof value === 'undefined') return;\n\n if (Array.isArray(value)) {\n // If the formatter gives us an array, we're expected to add each array value as a new\n // parameter item with the same parameter name\n value.forEach(singleValue => {\n appendHarValue(harParam, name, singleValue);\n });\n } else if (typeof value === 'object' && value !== null) {\n // If the formatter gives us an object, we're expected to add each property value as a new\n // parameter item, each with the name of the property\n Object.keys(value).forEach(key => {\n appendHarValue(harParam, key, value[key]);\n });\n } else {\n // If the formatter gives us a non-array, non-object, we add it as is\n harParam.push({\n ...addtlData,\n name,\n value: String(value),\n });\n }\n}\n\nfunction encodeBodyForHAR(body: any) {\n if (isPrimitive(body)) {\n return body;\n } else if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n typeof body.RAW_BODY !== 'undefined'\n ) {\n // `RAW_BODY` is a ReadMe-specific thing where we'll interpret the entire payload as a\n // raw string. https://docs.readme.com/docs/raw-body-content\n if (isPrimitive(body.RAW_BODY)) {\n return body.RAW_BODY;\n }\n\n return stringify(body.RAW_BODY);\n }\n\n return stringify(body);\n}\n\n// biome-ignore lint/style/noDefaultExport: This is fine for now.\nexport default function oasToHar(\n oas: Oas,\n operationSchema?: Operation,\n values: DataForHAR = {},\n auth: AuthForHAR = {},\n opts: oasToHarOptions = { proxyUrl: '' },\n): {\n log: {\n entries: readonly [\n {\n readonly request: Request;\n },\n ];\n };\n} {\n let operation: Operation;\n if (!operationSchema || typeof operationSchema.getParameters !== 'function') {\n /**\n * If `operationSchema` was supplied as a plain object instead of an instance of `Operation`\n * then we should create a new instance of it. We're doing it with a check on `getParameters`\n * instead of checking `instanceof Operation` because JS is very weird when it comes to\n * checking `instanceof` against classes. One instance of `Operation` may not always match up\n * with another if they're being loaded between two different libraries.\n *\n * It's weird. This is easier.\n */\n operation = new Operation(\n oas as unknown as OASDocument,\n operationSchema?.path || '',\n operationSchema?.method || ('' as HttpMethods),\n (operationSchema as unknown as OperationObject) || { path: '', method: '' },\n );\n } else {\n operation = operationSchema;\n }\n\n const apiDefinition = oas.getDefinition();\n\n const formData: DataForHAR = {\n ...defaultFormDataTypes,\n ...values,\n };\n\n if (!formData.server) {\n formData.server = {\n selected: 0,\n variables: oas.defaultVariables(0),\n };\n }\n\n // If the incoming `server.variables` is missing variables let's pad it out with defaults.\n formData.server.variables = {\n ...oas.defaultVariables(formData.server.selected),\n ...(formData.server.variables ? formData.server.variables : {}),\n };\n\n const har: Request = {\n cookies: [],\n headers: [],\n headersSize: 0,\n queryString: [],\n // @ts-expect-error This is fine because we're fleshing `postData` out further down.\n postData: {},\n bodySize: 0,\n method: operation.method.toUpperCase(),\n url: `${oas.url(formData.server.selected, formData.server.variables as ServerVariable)}${operation.path}`.replace(\n /\\s/g,\n '%20',\n ),\n httpVersion: 'HTTP/1.1',\n };\n\n if (opts.proxyUrl) {\n if (oas.getExtension(PROXY_ENABLED, operation)) {\n har.url = `${opts.proxyUrl}/${har.url}`;\n }\n }\n\n const parameters = operation.getParameters();\n\n har.url = har.url.replace(/{([-_a-zA-Z0-9[\\]]+)}/g, (full, key) => {\n if (!operation || !parameters) return key; // No path params at all\n\n // Find the path parameter or set a default value if it does not exist\n const parameter = parameters.find(param => param.name === key) || ({ name: key } as ParameterObject);\n\n // The library that handles our style processing already encodes uri elements. For everything\n // else we need to handle it here.\n if (!('style' in parameter) || !parameter.style) {\n return encodeURIComponent(formatter(formData, parameter, 'path'));\n }\n\n return formatter(formData, parameter, 'path');\n });\n\n const queryStrings = parameters?.filter(param => param.in === 'query');\n if (queryStrings?.length) {\n queryStrings.forEach(queryString => {\n const value = formatter(formData, queryString, 'query', true);\n appendHarValue(har.queryString, queryString.name, value);\n });\n }\n\n // Do we have any `cookie` parameters on the operation?\n const cookies = parameters?.filter(param => param.in === 'cookie');\n if (cookies?.length) {\n cookies.forEach(cookie => {\n const value = formatter(formData, cookie, 'cookie', true);\n appendHarValue(har.cookies, cookie.name, value);\n });\n }\n\n // Does this response have any documented content types?\n if (operation.schema.responses) {\n Object.keys(operation.schema.responses).some(response => {\n if (isRef(operation.schema.responses?.[response])) return false;\n\n const content = (operation.schema.responses?.[response] as ResponseObject).content;\n if (!content) return false;\n\n // If there's no `accept` header present we should add one so their eventual code snippet\n // follows best practices.\n if (Object.keys(formData.header || {}).find(h => h.toLowerCase() === 'accept')) return true;\n\n har.headers.push({\n name: 'accept',\n value: getResponseContentType(content),\n });\n\n return true;\n });\n }\n\n // Do we have any `header` parameters on the operation?\n let hasContentType = false;\n let contentType = operation.getContentType();\n const headers = parameters?.filter(param => param.in === 'header');\n if (headers?.length) {\n headers.forEach(header => {\n const value = formatter(formData, header, 'header', true);\n if (typeof value === 'undefined') return;\n\n if (header.name.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(value);\n }\n\n appendHarValue(har.headers, header.name, value);\n });\n }\n\n // Are there `x-headers` static headers configured for this OAS?\n const userDefinedHeaders = oas.getExtension(HEADERS, operation) as Extensions['headers'];\n if (userDefinedHeaders) {\n userDefinedHeaders.forEach(header => {\n if (typeof header.key === 'string' && header.key.toLowerCase() === 'content-type') {\n hasContentType = true;\n contentType = String(header.value);\n }\n\n har.headers.push({\n name: String(header.key),\n value: String(header.value),\n });\n });\n }\n\n if (formData.header) {\n // Do we have an `accept` header set up in the form data, but it hasn't been added yet?\n const acceptHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'accept');\n if (acceptHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'accept')) {\n har.headers.push({\n name: 'accept',\n value: String(formData.header[acceptHeader]),\n });\n }\n\n // Do we have a manually-defined `authorization` header set up in the form data?\n const authorizationHeader = Object.keys(formData.header).find(h => h.toLowerCase() === 'authorization');\n if (authorizationHeader && !har.headers.find(hdr => hdr.name.toLowerCase() === 'authorization')) {\n har.headers.push({\n name: 'authorization',\n value: String(formData.header[authorizationHeader]),\n });\n }\n }\n\n let requestBody: SchemaWrapper | undefined;\n if (operation.hasRequestBody()) {\n requestBody = operation.getParametersAsJSONSchema().find(payload => {\n // `formData` is used in our API Explorer for `application/x-www-form-urlencoded` endpoints\n // and if you have an operation with that, it will only ever have a `formData`. `body` is\n // used for all other payload shapes.\n return payload.type === (operation.isFormUrlEncoded() ? 'formData' : 'body');\n });\n }\n\n if (requestBody?.schema && Object.keys(requestBody.schema).length) {\n const requestBodySchema = requestBody.schema as SchemaObject;\n\n if (operation.isFormUrlEncoded()) {\n if (Object.keys(formData.formData || {}).length) {\n const cleanFormData = removeUndefinedObjects(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, { preserveNullishArrays: true });\n\n if (isMultipart) {\n har.postData = { params: [], mimeType: 'multipart/form-data' };\n\n // Because some request body schema shapes might not always be a top-level `properties`,\n // instead nesting it in an `oneOf` or `anyOf` we need to extract the first usable\n // schema that we have in order to process this multipart payload.\n const safeBodySchema = getSafeRequestBody(requestBodySchema);\n\n /**\n * Discover all `{ type: string, format: binary }` properties, or arrays containing the\n * same, within the request body. If there are any, then that means that we're dealing\n * with a `multipart/form-data` request and need to treat the payload as\n * `postData.params` and supply filenames and content types for the files (if they're\n * available).\n *\n * @todo It'd be nice to replace this with `getTypedFormatsInSchema` instead.\n * @example `{ type: string, format: binary }`\n * @example `{ type: array, items: { type: string, format: binary } }`\n */\n const binaryTypes = Object.keys(safeBodySchema.properties).filter(key => {\n const propData = safeBodySchema.properties[key] as JSONSchema;\n if (propData.format === 'binary') {\n return true;\n } else if (\n propData.type === 'array' &&\n propData.items &&\n typeof propData.items === 'object' &&\n propData.items !== null &&\n (propData.items as JSONSchema).format === 'binary'\n ) {\n return true;\n }\n\n return false;\n });\n\n if (cleanBody !== undefined) {\n const multipartParams = multipartBodyToFormatterParams(\n formData.body,\n (operation.schema.requestBody as RequestBodyObject).content['multipart/form-data'],\n safeBodySchema,\n );\n\n if (multipartParams.length) {\n Object.keys(cleanBody).forEach(name => {\n const param = multipartParams.find(multipartParam => multipartParam.name === name);\n\n if (param) {\n // If we're dealing with a binary type, and the value is a valid data URL we should\n // parse out any available filename and content type to send along with the\n // parameter to interpreters like `fetch-har` can make sense of it and send a usable\n // payload.\n const addtlData: { contentType?: string; fileName?: string } = {};\n\n let value = formatter(formData, param, 'body', true);\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n value.forEach((val: string) => {\n if (binaryTypes.includes(name)) {\n const parsed = parseDataUrl(val);\n if (parsed) {\n addtlData.fileName = 'name' in parsed ? parsed.name : 'unknown';\n if ('contentType' in parsed) {\n addtlData.contentType = parsed.contentType;\n }\n }\n }\n\n appendHarValue(har.postData?.params || [], name, val, addtlData);\n });\n }\n });\n }\n }\n } else {\n har.postData = { mimeType: contentType, text: '' };\n\n if (\n hasSchemaType(requestBody.schema, 'string') ||\n hasSchemaType(requestBody.schema, 'integer') ||\n hasSchemaType(requestBody.schema, 'number') ||\n hasSchemaType(requestBody.schema, 'boolean')\n ) {\n har.postData.text = JSON.stringify(JSON.parse(cleanBody));\n } else {\n /**\n * Handle formatted JSON objects that have properties that accept arbitrary JSON.\n *\n * Find all `{ type: string, format: json }` properties in the schema because we need\n * to manually `JSON.parse` them before submit, otherwise they'll be escaped instead\n * of actual objects. We also only want values that the user has entered, so we drop\n * any `undefined` `cleanBody` keys.\n */\n const jsonTypes = getTypedFormatsInSchema('json', requestBodySchema.properties, { payload: cleanBody });\n\n if (Array.isArray(jsonTypes) && jsonTypes.length) {\n try {\n jsonTypes.forEach((prop: boolean | string) => {\n try {\n set(cleanBody, String(prop), JSON.parse(get(cleanBody, String(prop))));\n } catch {\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 har.postData.text = encodeBodyForHAR(formData.body);\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 { ParameterObject, SchemaObject } from 'oas/types';\nimport type { StylizerConfig } from './style-serializer.js';\n\nimport qs from 'qs';\n\nimport { getParameterContentType } from '../utils.js';\nimport { stylize } from './style-serializer.js';\n\n// Certain styles don't support empty values.\nfunction shouldNotStyleEmptyValues(parameter: ParameterObject) {\n return ['simple', 'spaceDelimited', 'pipeDelimited', 'deepObject'].includes(parameter.style || '');\n}\n\nfunction shouldNotStyleReservedHeader(parameter: ParameterObject) {\n return ['accept', 'authorization', 'content-type'].includes(parameter.name.toLowerCase());\n}\n\n/**\n * Note: This isn't necessarily part of the spec. Behavior for the value 'undefined' is, well,\n * undefined. This code makes our system look better. If we wanted to be more accurate, we might\n * want to remove this, restore the un-fixed behavior for undefined and have our UI pass in empty\n * string instead of undefined.\n */\nfunction removeUndefinedForPath(value: any) {\n let finalValue = value;\n\n if (typeof finalValue === 'undefined') {\n return '';\n }\n\n if (Array.isArray(finalValue)) {\n finalValue = finalValue.filter(val => (val === undefined ? '' : val));\n\n if (finalValue.length === 0) {\n finalValue = '';\n }\n }\n\n if (typeof finalValue === 'object') {\n Object.keys(finalValue).forEach(key => {\n finalValue[key] = finalValue[key] === undefined ? '' : finalValue[key];\n });\n }\n\n return finalValue;\n}\n\nfunction stylizeValue(value: unknown, parameter: ParameterObject) {\n let finalValue = value;\n\n // Some styles don't work with empty values. We catch those there\n if (shouldNotStyleEmptyValues(parameter) && (typeof finalValue === 'undefined' || finalValue === '')) {\n // Paths need return an unstyled empty string instead of undefined so it's ignored in the final\n // path string.\n if (parameter.in === 'path') {\n return '';\n }\n\n // Everything but path should return undefined when unstyled so it's ignored in the final\n // parameter array.\n return undefined;\n }\n\n // Every style that adds their style to empty values should use emptystring for path parameters\n // instead of undefined to avoid the string `undefined`.\n if (parameter.in === 'path') {\n finalValue = removeUndefinedForPath(finalValue);\n }\n\n /**\n * Eventhough `accept`, `authorization`, and `content-type` headers can be defined as parameters,\n * they should be completely ignored when it comes to serialization.\n *\n * > If `in` is \"header\" and the `name` field is \"Accept\", \"Content-Type\" or \"Authorization\", the\n * > parameter definition SHALL be ignored.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10}\n */\n if (parameter.in === 'header' && shouldNotStyleReservedHeader(parameter)) {\n return value;\n }\n\n /**\n * 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') {\n const contentType = getParameterContentType(parameter);\n if (!contentType) {\n return undefined;\n }\n\n /**\n * @todo Handle other content types\n */\n switch (contentType) {\n case 'application/json':\n return encodeURIComponent(JSON.stringify(value));\n default:\n return encodeURIComponent(String(value));\n }\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 { JSONSchema, ParameterObject, SchemaObject } from 'oas/types';\n\nimport { isRef } from 'oas/types';\nimport { 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 * Because some request body schema shapes might not always be a top-level `properties`, instead\n * nesting it in an `oneOf` or `anyOf` we need to extract the first usable schema that we have. If\n * we don't do this then these non-conventional request body schema payloads may not be properly\n * represented in the HAR that we generate.\n *\n */\nexport function getSafeRequestBody(obj: any): any {\n if ('oneOf' in obj) {\n return getSafeRequestBody(obj.oneOf[0]);\n } else if ('anyOf' in obj) {\n return getSafeRequestBody(obj.anyOf[0]);\n }\n\n return obj;\n}\n\ninterface Options {\n parentIsArray?: boolean;\n parentKey?: string;\n payload: unknown;\n}\n\nfunction getSubschemas(schema: any, opts: Options) {\n let subSchemaDataSize = 0;\n if (opts.parentIsArray) {\n // If we don't have data for this parent schema in our body payload then we\n // shouldn't bother spidering further into the schema looking for more `format`s\n // for data that definitely doesn't exist.\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData === undefined || !Array.isArray(parentData)) {\n return false;\n }\n\n subSchemaDataSize = parentData.length;\n }\n\n let subschemas: any[] = [];\n if (subSchemaDataSize > 0) {\n for (let idx = 0; idx < subSchemaDataSize; idx += 1) {\n subschemas = subschemas.concat(\n Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, idx, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n })),\n );\n }\n } else {\n subschemas = Object.entries<JSONSchema>(schema).map(([key, subschema]: [string, JSONSchema]) => ({\n key: opts.parentKey ? [opts.parentKey, key].join('.') : key,\n schema: getSafeRequestBody(subschema),\n }));\n }\n\n return subschemas;\n}\n\n/**\n * With a supplied JSON Schema object, spider through it for any schemas that may contain specific\n * kind of `format` that also happen to be within the current `requestBody` payload that we're\n * creating a HAR representation for.\n *\n */\nexport function getTypedFormatsInSchema(\n format: 'binary' | 'json',\n schema: any,\n opts: Options,\n): (boolean | string)[] | boolean | string {\n try {\n if (schema?.format === format) {\n if (opts.parentIsArray) {\n const parentData = get(opts.payload, opts.parentKey || '');\n if (parentData !== undefined && Array.isArray(parentData)) {\n return Object.keys(parentData)\n .map(pdk => {\n const currentKey = [opts.parentKey, pdk].join('.');\n if (get(opts.payload, currentKey) !== undefined) {\n return currentKey;\n }\n\n return false;\n })\n .filter(Boolean);\n }\n } else if (opts.parentKey && get(opts.payload, opts.parentKey) !== undefined) {\n return opts.parentKey;\n } else if (opts.payload !== undefined) {\n // If this payload is present and we're looking for a specific format then we should assume\n // that the **root** schema of the request body is that format, and we aren't trafficking in\n // a nested object or array schema.\n return true;\n }\n\n return false;\n }\n\n const subschemas = getSubschemas(schema, opts);\n if (!subschemas) {\n return false;\n }\n\n return subschemas\n .flatMap(({ key, schema: subschema }) => {\n if ('properties' in subschema) {\n return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });\n } else if ('items' in subschema) {\n if ((subschema.items as JSONSchema)?.properties) {\n return getTypedFormatsInSchema(format, (subschema.items as JSONSchema).properties, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n return getTypedFormatsInSchema(format, subschema.items, {\n payload: opts.payload,\n parentKey: key,\n parentIsArray: true,\n });\n }\n\n // If this schema has neither `properties` or `items` then it's a regular schema\n // we can re-run.\n return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });\n })\n .filter(Boolean);\n } catch {\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 * 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 // biome-ignore lint/style/noParameterAssign: It is what it is.\n str = (str as number).toString();\n }\n\n if (returnIfEncoded) {\n if (isURIEncoded(str)) {\n return str;\n }\n }\n\n if (typeof str !== 'string' || !str.length) {\n return str;\n }\n\n if (!escape) {\n return str;\n }\n\n if (parse) {\n return JSON.parse(str);\n }\n\n // In ES6 you can do this quite easily by using the new ... spread operator. This causes the\n // string iterator (another new ES6 feature) to be used internally, and because that iterator is\n // designed to deal with code points rather than UCS-2/UTF-16 code units.\n return [...str]\n .map(char => {\n if (isRfc3986Unreserved(char)) {\n return char;\n }\n\n if (isRfc3986Reserved(char) && (escape === 'unsafe' || isAllowedReserved)) {\n return char;\n }\n\n const encoder = new TextEncoder();\n const encoded = Array.from(encoder.encode(char))\n .map(byte => `0${byte.toString(16).toUpperCase()}`.slice(-2))\n .map(encodedByte => `%${encodedByte}`)\n .join('');\n\n return encoded;\n })\n .join('');\n}\n\nexport interface StylizerConfig {\n escape: boolean | 'unsafe';\n explode?: boolean;\n isAllowedReserved?: boolean;\n key: string;\n location: 'body' | 'query';\n style: 'deepObject' | 'form' | 'label' | 'matrix' | 'pipeDelimited' | 'simple' | 'spaceDelimited';\n value: any;\n}\n\nexport function stylize(config: StylizerConfig): any {\n const { value } = config;\n\n if (Array.isArray(value)) {\n return encodeArray(config);\n }\n\n if (isObject(value)) {\n return encodeObject(config);\n }\n\n return encodePrimitive(config);\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeArray({\n location,\n key,\n value,\n style,\n explode,\n escape,\n isAllowedReserved = false,\n}: Omit<StylizerConfig, 'value'> & { value: string[] }) {\n const valueEncoder = (str: string) => {\n // 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 return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodeObject({ location, key, value, style, explode, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query',\n isAllowedReserved,\n });\n\n const valueKeys = Object.keys(value);\n\n switch (style) {\n /**\n * @example <caption>`style: simple` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100,G=200,B=150`\n *\n * @example <caption>`style: simple` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R,100,G,200,B,150`\n */\n case 'simple':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : ',';\n const prefix = prev ? `${prev},` : '';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: label` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R=100.G=200.B=150`\n *\n * @example <caption>`style: label` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `.R.100.G.200.B.150`\n */\n case 'label':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const middleChar = explode ? '=' : '.';\n const prefix = prev ? `${prev}.` : '.';\n\n return `${prefix}${curr}${middleChar}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: matrix` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;R=100;G=200;B=150`\n *\n * @example <caption>`style: matrix` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `;color=R,100,G,200,B,150`\n */\n case 'matrix':\n if (explode) {\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev};` : ';';\n\n return `${prefix}${curr}=${val}`;\n }, '');\n }\n\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev},` : `;${key}=`;\n\n return `${prefix}${curr},${val}`;\n }, '');\n\n /**\n * @example <caption>`style: form` + `explode: true`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R=100&G=200&B=150`\n *\n * @example <caption>`style: form` + `explode: false` (the default behavior)</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color=R,100,G,200,B,150`\n */\n case 'form':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';\n const separator = explode ? '=' : ',';\n\n return `${prefix}${curr}${separator}${val}`;\n }, '');\n\n /**\n * @example <caption>`style: spaceDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R%20100%20G%20200%20B%20150`\n */\n case 'spaceDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev} ` : '';\n\n return `${prefix}${curr} ${val}`;\n }, '');\n\n /**\n * @example <caption>`style: pipeDelimited`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `R|100|G|200|B|150`\n */\n case 'pipeDelimited':\n return valueKeys.reduce((prev, curr) => {\n const val = valueEncoder(value[curr]);\n const prefix = prev ? `${prev}|` : '';\n\n return `${prefix}${curr}|${val}`;\n }, '');\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `{ \"R\": 100, \"G\": 200, \"B\": 150 }` → `color[R]=100&color[G]=200&color[B]=150`\n */\n case 'deepObject':\n return valueKeys.reduce(curr => {\n const val = valueEncoder(value[curr]);\n return `${val}`;\n }, '');\n\n default:\n return undefined;\n }\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples}\n */\nfunction encodePrimitive({ location, key, value, style, escape, isAllowedReserved = false }: StylizerConfig) {\n const valueEncoder = (str: string) =>\n encodeDisallowedCharacters(str, {\n escape,\n returnIfEncoded: location === 'query' || location === 'body',\n isAllowedReserved,\n });\n\n switch (style) {\n /**\n * @example <caption>`style: simple`</caption>\n * `blue` → `blue`\n */\n case 'simple':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: label`</caption>\n * `blue` → `.blue`\n */\n case 'label':\n return `.${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: matrix`</caption>\n * `blue` → `;color=blue`\n */\n case 'matrix':\n if (value === '') {\n return `;${key}`;\n }\n\n return `;${key}=${valueEncoder(value)}`;\n\n /**\n * @example <caption>`style: form`</caption>\n * `blue` → `color=blue`\n */\n case 'form':\n return valueEncoder(value);\n\n /**\n * @example <caption>`style: deepObject`</caption>\n * `blue` → n/a\n */\n case 'deepObject':\n return valueEncoder(value);\n\n default:\n return undefined;\n }\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import { parse as parseDataUrl } from "@readme/data-urls";
|
|
7
7
|
import { HEADERS, PROXY_ENABLED } from "oas/extensions";
|
|
8
8
|
import { Operation } from "oas/operation";
|
|
9
|
-
import { isRef } from "oas/types";
|
|
9
|
+
import { isRef as isRef2 } from "oas/types";
|
|
10
10
|
import { jsonSchemaTypes, matchesMimeType } from "oas/utils";
|
|
11
11
|
import removeUndefinedObjects from "remove-undefined-objects";
|
|
12
12
|
|
|
@@ -33,6 +33,119 @@ function set(object, path, value) {
|
|
|
33
33
|
// src/lib/style-formatting/index.ts
|
|
34
34
|
import qs from "qs";
|
|
35
35
|
|
|
36
|
+
// src/lib/utils.ts
|
|
37
|
+
import { isRef } from "oas/types";
|
|
38
|
+
import { getParameterContentType as getParameterContentTypeUtil } from "oas/utils";
|
|
39
|
+
function hasSchemaType(schema, discriminator) {
|
|
40
|
+
if (Array.isArray(schema.type)) {
|
|
41
|
+
return schema.type.includes(discriminator);
|
|
42
|
+
}
|
|
43
|
+
return schema.type === discriminator;
|
|
44
|
+
}
|
|
45
|
+
function getSafeRequestBody(obj) {
|
|
46
|
+
if ("oneOf" in obj) {
|
|
47
|
+
return getSafeRequestBody(obj.oneOf[0]);
|
|
48
|
+
} else if ("anyOf" in obj) {
|
|
49
|
+
return getSafeRequestBody(obj.anyOf[0]);
|
|
50
|
+
}
|
|
51
|
+
return obj;
|
|
52
|
+
}
|
|
53
|
+
function getSubschemas(schema, opts) {
|
|
54
|
+
let subSchemaDataSize = 0;
|
|
55
|
+
if (opts.parentIsArray) {
|
|
56
|
+
const parentData = get(opts.payload, opts.parentKey || "");
|
|
57
|
+
if (parentData === void 0 || !Array.isArray(parentData)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
subSchemaDataSize = parentData.length;
|
|
61
|
+
}
|
|
62
|
+
let subschemas = [];
|
|
63
|
+
if (subSchemaDataSize > 0) {
|
|
64
|
+
for (let idx = 0; idx < subSchemaDataSize; idx += 1) {
|
|
65
|
+
subschemas = subschemas.concat(
|
|
66
|
+
Object.entries(schema).map(([key, subschema]) => ({
|
|
67
|
+
key: opts.parentKey ? [opts.parentKey, idx, key].join(".") : key,
|
|
68
|
+
schema: getSafeRequestBody(subschema)
|
|
69
|
+
}))
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
subschemas = Object.entries(schema).map(([key, subschema]) => ({
|
|
74
|
+
key: opts.parentKey ? [opts.parentKey, key].join(".") : key,
|
|
75
|
+
schema: getSafeRequestBody(subschema)
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return subschemas;
|
|
79
|
+
}
|
|
80
|
+
function getTypedFormatsInSchema(format, schema, opts) {
|
|
81
|
+
try {
|
|
82
|
+
if (schema?.format === format) {
|
|
83
|
+
if (opts.parentIsArray) {
|
|
84
|
+
const parentData = get(opts.payload, opts.parentKey || "");
|
|
85
|
+
if (parentData !== void 0 && Array.isArray(parentData)) {
|
|
86
|
+
return Object.keys(parentData).map((pdk) => {
|
|
87
|
+
const currentKey = [opts.parentKey, pdk].join(".");
|
|
88
|
+
if (get(opts.payload, currentKey) !== void 0) {
|
|
89
|
+
return currentKey;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}).filter(Boolean);
|
|
93
|
+
}
|
|
94
|
+
} else if (opts.parentKey && get(opts.payload, opts.parentKey) !== void 0) {
|
|
95
|
+
return opts.parentKey;
|
|
96
|
+
} else if (opts.payload !== void 0) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const subschemas = getSubschemas(schema, opts);
|
|
102
|
+
if (!subschemas) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return subschemas.flatMap(({ key, schema: subschema }) => {
|
|
106
|
+
if ("properties" in subschema) {
|
|
107
|
+
return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });
|
|
108
|
+
} else if ("items" in subschema) {
|
|
109
|
+
if (subschema.items?.properties) {
|
|
110
|
+
return getTypedFormatsInSchema(format, subschema.items.properties, {
|
|
111
|
+
payload: opts.payload,
|
|
112
|
+
parentKey: key,
|
|
113
|
+
parentIsArray: true
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return getTypedFormatsInSchema(format, subschema.items, {
|
|
117
|
+
payload: opts.payload,
|
|
118
|
+
parentKey: key,
|
|
119
|
+
parentIsArray: true
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });
|
|
123
|
+
}).filter(Boolean);
|
|
124
|
+
} catch {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function getParameterContentType(param) {
|
|
129
|
+
if (!("content" in param) || typeof param.content !== "object" || !param.content) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const contentKeys = Object.keys(param.content);
|
|
133
|
+
if (contentKeys.length < 1) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return getParameterContentTypeUtil(contentKeys) || null;
|
|
137
|
+
}
|
|
138
|
+
function getParameterContentSchema(param, contentType) {
|
|
139
|
+
if (!("content" in param) || typeof param.content !== "object" || !param.content) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
const mediaTypeObject = param.content[contentType];
|
|
143
|
+
if (typeof mediaTypeObject === "object" && mediaTypeObject && "schema" in mediaTypeObject && mediaTypeObject.schema) {
|
|
144
|
+
return isRef(mediaTypeObject.schema) ? null : mediaTypeObject.schema;
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
36
149
|
// src/lib/style-formatting/style-serializer.ts
|
|
37
150
|
var isRfc3986Reserved = (char) => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
|
|
38
151
|
var isRfc3986Unreserved = (char) => /^[a-z0-9\-._~]+$/i.test(char);
|
|
@@ -349,6 +462,18 @@ function stylizeValue(value, parameter) {
|
|
|
349
462
|
if (parameter.in === "header" && shouldNotStyleReservedHeader(parameter)) {
|
|
350
463
|
return value;
|
|
351
464
|
}
|
|
465
|
+
if (parameter.content && parameter.in === "query") {
|
|
466
|
+
const contentType = getParameterContentType(parameter);
|
|
467
|
+
if (!contentType) {
|
|
468
|
+
return void 0;
|
|
469
|
+
}
|
|
470
|
+
switch (contentType) {
|
|
471
|
+
case "application/json":
|
|
472
|
+
return encodeURIComponent(JSON.stringify(value));
|
|
473
|
+
default:
|
|
474
|
+
return encodeURIComponent(String(value));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
352
477
|
let style = parameter.style;
|
|
353
478
|
if (!style) {
|
|
354
479
|
if (parameter.in === "query") {
|
|
@@ -432,10 +557,10 @@ function shouldExplode(parameter) {
|
|
|
432
557
|
return (parameter.explode || parameter.explode !== false && parameter.style === "form" || // style: deepObject && explode: false doesn't exist so explode it always
|
|
433
558
|
// https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples
|
|
434
559
|
parameter.style === "deepObject") && // header and path doesn't explode into separate parameters like query and cookie do
|
|
435
|
-
parameter.in !== "header" && parameter.in !== "path";
|
|
560
|
+
parameter.in !== "header" && parameter.in !== "path" && !parameter.content;
|
|
436
561
|
}
|
|
437
562
|
function formatStyle(value, parameter) {
|
|
438
|
-
if (parameter.style === "deepObject" && (!value || typeof value !== "object" || parameter.explode === false)) {
|
|
563
|
+
if (!parameter.content && parameter.style === "deepObject" && (!value || typeof value !== "object" || parameter.explode === false)) {
|
|
439
564
|
return void 0;
|
|
440
565
|
}
|
|
441
566
|
if (shouldExplode(parameter)) {
|
|
@@ -444,97 +569,6 @@ function formatStyle(value, parameter) {
|
|
|
444
569
|
return stylizeValue(value, parameter);
|
|
445
570
|
}
|
|
446
571
|
|
|
447
|
-
// src/lib/utils.ts
|
|
448
|
-
function hasSchemaType(schema, discriminator) {
|
|
449
|
-
if (Array.isArray(schema.type)) {
|
|
450
|
-
return schema.type.includes(discriminator);
|
|
451
|
-
}
|
|
452
|
-
return schema.type === discriminator;
|
|
453
|
-
}
|
|
454
|
-
function getSafeRequestBody(obj) {
|
|
455
|
-
if ("oneOf" in obj) {
|
|
456
|
-
return getSafeRequestBody(obj.oneOf[0]);
|
|
457
|
-
} else if ("anyOf" in obj) {
|
|
458
|
-
return getSafeRequestBody(obj.anyOf[0]);
|
|
459
|
-
}
|
|
460
|
-
return obj;
|
|
461
|
-
}
|
|
462
|
-
function getSubschemas(schema, opts) {
|
|
463
|
-
let subSchemaDataSize = 0;
|
|
464
|
-
if (opts.parentIsArray) {
|
|
465
|
-
const parentData = get(opts.payload, opts.parentKey || "");
|
|
466
|
-
if (parentData === void 0 || !Array.isArray(parentData)) {
|
|
467
|
-
return false;
|
|
468
|
-
}
|
|
469
|
-
subSchemaDataSize = parentData.length;
|
|
470
|
-
}
|
|
471
|
-
let subschemas = [];
|
|
472
|
-
if (subSchemaDataSize > 0) {
|
|
473
|
-
for (let idx = 0; idx < subSchemaDataSize; idx += 1) {
|
|
474
|
-
subschemas = subschemas.concat(
|
|
475
|
-
Object.entries(schema).map(([key, subschema]) => ({
|
|
476
|
-
key: opts.parentKey ? [opts.parentKey, idx, key].join(".") : key,
|
|
477
|
-
schema: getSafeRequestBody(subschema)
|
|
478
|
-
}))
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
} else {
|
|
482
|
-
subschemas = Object.entries(schema).map(([key, subschema]) => ({
|
|
483
|
-
key: opts.parentKey ? [opts.parentKey, key].join(".") : key,
|
|
484
|
-
schema: getSafeRequestBody(subschema)
|
|
485
|
-
}));
|
|
486
|
-
}
|
|
487
|
-
return subschemas;
|
|
488
|
-
}
|
|
489
|
-
function getTypedFormatsInSchema(format, schema, opts) {
|
|
490
|
-
try {
|
|
491
|
-
if (schema?.format === format) {
|
|
492
|
-
if (opts.parentIsArray) {
|
|
493
|
-
const parentData = get(opts.payload, opts.parentKey || "");
|
|
494
|
-
if (parentData !== void 0 && Array.isArray(parentData)) {
|
|
495
|
-
return Object.keys(parentData).map((pdk) => {
|
|
496
|
-
const currentKey = [opts.parentKey, pdk].join(".");
|
|
497
|
-
if (get(opts.payload, currentKey) !== void 0) {
|
|
498
|
-
return currentKey;
|
|
499
|
-
}
|
|
500
|
-
return false;
|
|
501
|
-
}).filter(Boolean);
|
|
502
|
-
}
|
|
503
|
-
} else if (opts.parentKey && get(opts.payload, opts.parentKey) !== void 0) {
|
|
504
|
-
return opts.parentKey;
|
|
505
|
-
} else if (opts.payload !== void 0) {
|
|
506
|
-
return true;
|
|
507
|
-
}
|
|
508
|
-
return false;
|
|
509
|
-
}
|
|
510
|
-
const subschemas = getSubschemas(schema, opts);
|
|
511
|
-
if (!subschemas) {
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
return subschemas.flatMap(({ key, schema: subschema }) => {
|
|
515
|
-
if ("properties" in subschema) {
|
|
516
|
-
return getTypedFormatsInSchema(format, subschema.properties, { payload: opts.payload, parentKey: key });
|
|
517
|
-
} else if ("items" in subschema) {
|
|
518
|
-
if (subschema.items?.properties) {
|
|
519
|
-
return getTypedFormatsInSchema(format, subschema.items.properties, {
|
|
520
|
-
payload: opts.payload,
|
|
521
|
-
parentKey: key,
|
|
522
|
-
parentIsArray: true
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
return getTypedFormatsInSchema(format, subschema.items, {
|
|
526
|
-
payload: opts.payload,
|
|
527
|
-
parentKey: key,
|
|
528
|
-
parentIsArray: true
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
return getTypedFormatsInSchema(format, subschema, { payload: opts.payload, parentKey: key });
|
|
532
|
-
}).filter(Boolean);
|
|
533
|
-
} catch {
|
|
534
|
-
return [];
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
572
|
// src/index.ts
|
|
539
573
|
function formatter(values, param, type, onlyIfExists = false) {
|
|
540
574
|
if (param.style) {
|
|
@@ -546,12 +580,16 @@ function formatter(values, param, type, onlyIfExists = false) {
|
|
|
546
580
|
value = values[type][param.name];
|
|
547
581
|
} else if (onlyIfExists && !param.required) {
|
|
548
582
|
value = void 0;
|
|
549
|
-
} else if (param.required && param.schema && !
|
|
583
|
+
} else if (param.required && param.schema && !isRef2(param.schema) && param.schema.default) {
|
|
550
584
|
value = param.schema.default;
|
|
585
|
+
} else if (param.required && param.content) {
|
|
586
|
+
const contentType = getParameterContentType(param);
|
|
587
|
+
const schema = contentType ? getParameterContentSchema(param, contentType) : null;
|
|
588
|
+
value = schema?.default;
|
|
551
589
|
} else if (type === "path") {
|
|
552
590
|
return param.name;
|
|
553
591
|
}
|
|
554
|
-
if (param.schema && !
|
|
592
|
+
if (param.schema && !isRef2(param.schema) && param.schema.type === "array" && param.schema.items && !isRef2(param.schema.items) && param.schema.items.format === "binary") {
|
|
555
593
|
if (Array.isArray(value)) {
|
|
556
594
|
return value;
|
|
557
595
|
}
|
|
@@ -720,7 +758,7 @@ function oasToHar(oas, operationSchema, values = {}, auth = {}, opts = { proxyUr
|
|
|
720
758
|
}
|
|
721
759
|
if (operation.schema.responses) {
|
|
722
760
|
Object.keys(operation.schema.responses).some((response) => {
|
|
723
|
-
if (
|
|
761
|
+
if (isRef2(operation.schema.responses?.[response])) return false;
|
|
724
762
|
const content = (operation.schema.responses?.[response]).content;
|
|
725
763
|
if (!content) return false;
|
|
726
764
|
if (Object.keys(formData.header || {}).find((h) => h.toLowerCase() === "accept")) return true;
|