oas 38.5.2 → 38.6.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.
Files changed (59) hide show
  1. package/dist/analyzer/index.cjs +17 -17
  2. package/dist/analyzer/index.cjs.map +1 -1
  3. package/dist/analyzer/index.js +2 -2
  4. package/dist/analyzer/types.cjs.map +1 -1
  5. package/dist/{chunk-A7BAE2SN.js → chunk-3X7ZLPYE.js} +26 -19
  6. package/dist/chunk-3X7ZLPYE.js.map +1 -0
  7. package/dist/{chunk-EARDDQSB.cjs → chunk-47FD2BIN.cjs} +5 -2
  8. package/dist/chunk-47FD2BIN.cjs.map +1 -0
  9. package/dist/{chunk-7LQKUYC7.js → chunk-5745XRSJ.js} +3 -3
  10. package/dist/chunk-7PWF3F2W.cjs.map +1 -1
  11. package/dist/chunk-COHEPMUP.cjs.map +1 -1
  12. package/dist/{chunk-T4AJWZEL.cjs → chunk-HQEDOVWO.cjs} +47 -32
  13. package/dist/chunk-HQEDOVWO.cjs.map +1 -0
  14. package/dist/{chunk-DYHV2B4Z.js → chunk-JHDEAXSK.js} +4 -1
  15. package/dist/chunk-JHDEAXSK.js.map +1 -0
  16. package/dist/{chunk-MYFJ2GV3.cjs → chunk-OBYCSKPS.cjs} +28 -21
  17. package/dist/chunk-OBYCSKPS.cjs.map +1 -0
  18. package/dist/{chunk-IV2FDFXA.js → chunk-PZR3GKKO.js} +19 -4
  19. package/dist/chunk-PZR3GKKO.js.map +1 -0
  20. package/dist/{chunk-JQGHPVGV.cjs → chunk-RUHLHK66.cjs} +74 -74
  21. package/dist/chunk-RUHLHK66.cjs.map +1 -0
  22. package/dist/extensions.cjs +4 -2
  23. package/dist/extensions.cjs.map +1 -1
  24. package/dist/extensions.d.cts +1 -1
  25. package/dist/extensions.d.ts +1 -1
  26. package/dist/extensions.js +3 -1
  27. package/dist/{index-C6OzXwLp.d.ts → index-B097koLb.d.ts} +2 -0
  28. package/dist/{index-C4bupNyk.d.cts → index-BmHgGqbY.d.cts} +2 -0
  29. package/dist/index.cjs +53 -53
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +19 -1
  32. package/dist/index.d.ts +19 -1
  33. package/dist/index.js +3 -3
  34. package/dist/operation/index.cjs +4 -4
  35. package/dist/operation/index.cjs.map +1 -1
  36. package/dist/operation/index.js +3 -3
  37. package/dist/pruner/index.cjs +5 -5
  38. package/dist/pruner/index.cjs.map +1 -1
  39. package/dist/pruner/index.d.cts +1 -1
  40. package/dist/pruner/index.d.ts +1 -1
  41. package/dist/pruner/index.js +4 -4
  42. package/dist/reducer/index.cjs +5 -5
  43. package/dist/reducer/index.cjs.map +1 -1
  44. package/dist/reducer/index.d.cts +1 -1
  45. package/dist/reducer/index.d.ts +1 -1
  46. package/dist/reducer/index.js +4 -4
  47. package/dist/types.cjs.map +1 -1
  48. package/dist/utils.cjs +3 -3
  49. package/dist/utils.cjs.map +1 -1
  50. package/dist/utils.js +2 -2
  51. package/package.json +1 -1
  52. package/dist/chunk-A7BAE2SN.js.map +0 -1
  53. package/dist/chunk-DYHV2B4Z.js.map +0 -1
  54. package/dist/chunk-EARDDQSB.cjs.map +0 -1
  55. package/dist/chunk-IV2FDFXA.js.map +0 -1
  56. package/dist/chunk-JQGHPVGV.cjs.map +0 -1
  57. package/dist/chunk-MYFJ2GV3.cjs.map +0 -1
  58. package/dist/chunk-T4AJWZEL.cjs.map +0 -1
  59. /package/dist/{chunk-7LQKUYC7.js.map → chunk-5745XRSJ.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/darrenyong/Desktop/oas-stuff/oas/packages/oas/dist/chunk-OBYCSKPS.cjs","../src/lib/matches-mimetype.ts","../src/lib/get-parameter-content-type.ts","../src/lib/refs.ts","../src/lib/helpers.ts","../src/lib/clone-object.ts","../src/lib/build-discriminator-one-of.ts","../src/lib/openapi-to-json-schema.ts","../src/operation/transformers/get-parameters-as-json-schema.ts","../src/utils.ts"],"names":["types","converted","sch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;AACD,MAAA;AAKoD,MAAA;AACM,MAAA;AACjC,MAAA;AACiB,wBAAA;AACzC,QAAA;AACF,MAAA;AAEgC,MAAA;AACgC,QAAA;AAChE,MAAA;AACF,IAAA;AAEO,IAAA;AAEW,EAAA;AACuC,IAAA;AAC1D,EAAA;AACL;AR2qCuF;AACA;AS3iDM;AAEhD;AT4iD0C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/darrenyong/Desktop/oas-stuff/oas/packages/oas/dist/chunk-OBYCSKPS.cjs","sourcesContent":[null,"function matchesMediaType(types: string[], mediaType: string): boolean {\n return types.some(type => {\n return mediaType.indexOf(type) > -1;\n });\n}\n\nexport default {\n formUrlEncoded: (mimeType: string): boolean => {\n return matchesMediaType(['application/x-www-form-urlencoded'], mimeType);\n },\n\n json: (contentType: string): boolean => {\n return matchesMediaType(\n ['application/json', 'application/x-json', 'text/json', 'text/x-json', '+json'],\n contentType,\n );\n },\n\n multipart: (contentType: string): boolean => {\n return matchesMediaType(\n ['multipart/mixed', 'multipart/related', 'multipart/form-data', 'multipart/alternative'],\n contentType,\n );\n },\n\n wildcard: (contentType: string): boolean => {\n return contentType === '*/*';\n },\n\n xml: (contentType: string): boolean => {\n return matchesMediaType(\n [\n 'application/xml',\n 'application/xml-external-parsed-entity',\n 'application/xml-dtd',\n 'text/xml',\n 'text/xml-external-parsed-entity',\n '+xml',\n ],\n contentType,\n );\n },\n};\n","import matchesMimetype from './matches-mimetype.js';\n\n/**\n * Selects a content type from an array of content type keys, prioritizing `application/json`\n * and other JSON-like content types over other content types.\n *\n * When multiple content types are present:\n * - If there's exactly one content type, it's returned\n * - If there are multiple content types, JSON-like content types (e.g., `application/json`,\n * `application/vnd.api+json`) are prioritized\n * - If no JSON-like content types are present, the first content type is returned\n *\n * @param contentKeys - Array of content type keys (e.g., ['application/json', 'application/xml'])\n * @returns The selected content type, or undefined if the array is empty\n */\nexport function getParameterContentType(contentKeys: string[]): string | undefined {\n if (contentKeys.length === 0) {\n return undefined;\n }\n\n if (contentKeys.length === 1) {\n return contentKeys[0];\n }\n\n // We should always try to prioritize `application/json` over any other possible\n // content that might be present on this schema.\n const jsonLikeContentTypes = contentKeys.filter(k => matchesMimetype.json(k));\n if (jsonLikeContentTypes.length) {\n return jsonLikeContentTypes[0];\n }\n\n return contentKeys[0];\n}\n","import type { OASDocument, SchemaObject } from '../types.js';\n\nimport jsonpointer from 'jsonpointer';\n\nimport { isRef } from '../types.js';\n\nimport { isPrimitive } from './helpers.js';\n\n/**\n * Normalize a `$ref` pointer (`#/components/schemas/Pet`) into a plain JSON pointer\n * (`/components/schemas/Pet`) so it can be compared against `jsonpath-plus` result pointers, which\n * never carry the leading `#`.\n *\n */\nexport function toPointer($ref: string): string {\n return $ref.startsWith('#') ? $ref.slice(1) : $ref;\n}\n\n/**\n * Decorate component schemas within the API definition with a `x-readme-ref-name` property so we\n * can retin their original schema names during dereferencing or `$ref` resolution operations.\n *\n */\nexport function decorateComponentSchemasWithRefName(api: OASDocument): void {\n if (!api?.components?.schemas || typeof api.components.schemas !== 'object') {\n return;\n }\n\n Object.keys(api.components.schemas).forEach(schemaName => {\n // As of OpenAPI 3.1 component schemas can be primitives or arrays. If this happens then we\n // shouldn't try to add `x-readme-ref-name` properties because we can't. We'll have some data\n // loss on these schemas but as they aren't objects they likely won't be used in ways that\n // would require needing a `title` or `x-readme-ref-name` anyways.\n if (\n isPrimitive(api.components?.schemas?.[schemaName]) ||\n Array.isArray(api.components?.schemas?.[schemaName]) ||\n api.components?.schemas?.[schemaName] === null\n ) {\n return;\n }\n\n // oxlint-disable-next-line no-unsafe-optional-chaining\n (api.components?.schemas?.[schemaName] as SchemaObject)['x-readme-ref-name'] = schemaName;\n });\n}\n\n/**\n * Encode a string to be used as a JSON pointer.\n *\n * @see {@link https://tools.ietf.org/html/rfc6901}\n * @param str String to encode into string that can be used as a JSON pointer.\n */\nexport function encodePointer(str: string): string {\n return str.replaceAll('~', '~0').replaceAll('/', '~1');\n}\n\n/**\n * Decode a JSON pointer string.\n *\n * Per RFC 6901, `~0` is unescaped to `~` and `~1` to `/`. A single-pass replacement is required:\n * the sequence `~01` must decode to `~1` (tilde then one), not `~/`. Replacing `~1` before `~0`\n * would incorrectly turn `~01` into `~/`.\n *\n * @see {@link https://tools.ietf.org/html/rfc6901}\n * @param str String to decode a JSON pointer from\n */\nexport function decodePointer(str: string): string {\n return str.replace(/~([01])/g, (_, digit) => (digit === '0' ? '~' : '/'));\n}\n\n/**\n * Lookup a reference pointer within an a JSON object and return the schema that it resolves to.\n *\n * @param $ref Reference to look up a schema for.\n * @param definition OpenAPI definition to look for the `$ref` pointer in.\n */\nfunction findRef($ref: string, definition: OASDocument | SchemaObject): any {\n let currRef = $ref.trim();\n if (currRef === '') {\n // If this ref is empty, don't bother trying to look for it.\n return false;\n }\n\n if (currRef.startsWith('#')) {\n // Decode URI fragment representation.\n currRef = decodeURIComponent(currRef.substring(1));\n } else {\n throw new Error(`Could not find a definition for ${$ref}.`);\n }\n\n const current = jsonpointer.get(definition, currRef);\n if (current === undefined) {\n throw new Error(`Could not find a definition for ${$ref}.`);\n }\n\n return current;\n}\n\n/**\n * Dereference a `$ref` pointer if present, otherwise return the value as-is.\n *\n * This function handles `$ref` pointers on-the-fly without requiring full dereferencing and\n * prevents infinite loops by tracking seen `$ref` pointers and not re-processing circular\n * references.\n *\n * @param value The value that may contain a `$ref` pointer.\n * @param definition OpenAPI definition to look for the `$ref` pointer in.\n * @param seenRefs Optional Set to track `$ref` pointers that have already been processed to prevent circular references.\n * @returns The dereferenced value if it was a `$ref`, otherwise the original value. Returns the original `$ref` if it's circular.\n */\nexport function dereferenceRef<T>(\n value: T,\n definition?: OASDocument | SchemaObject,\n seenRefs: Set<string> = new Set<string>(),\n): T {\n if (value === undefined) {\n return undefined as T;\n }\n\n if (isRef(value)) {\n if (!definition) {\n return value as T;\n }\n\n const ref = value.$ref;\n\n // If we've seen this `$ref` before then it's circular and we should return the original `$ref`\n // to prevent infinite loops\n if (seenRefs.has(ref)) {\n return value as T;\n }\n\n // Track this `$ref` as having been seen so we can avoid infinitely processing circular\n // references.\n seenRefs.add(ref);\n\n try {\n const dereferenced = findRef(ref, definition);\n\n // If the dereferenced value is itself a `$ref` then recursively dereference it (but with\n // `seenRefs` tracking).\n if (isRef(dereferenced)) {\n return dereferenceRef(dereferenced, definition, seenRefs) as T;\n }\n\n return {\n ...dereferenced,\n } as T;\n } catch {\n // If dereferencing fails return the original `$ref`.\n return value as T;\n }\n }\n\n return value;\n}\n\n/**\n * Recursively resolve `$ref` pointers inside a given schema.\n *\n * Uses the same `seenRefs` logic as `dereferenceRef` for protection against circular references.\n *\n * @see {@link dereferenceRef}\n */\nexport function dereferenceRefDeep<T>(\n value: T,\n definition?: OASDocument | SchemaObject,\n seenRefs: Set<string> = new Set<string>(),\n): T {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n if (isRef(value)) {\n if (!definition) return value;\n\n const resolved = dereferenceRef(value, definition, seenRefs);\n if (isRef(resolved)) return resolved as T;\n\n return dereferenceRefDeep(resolved, definition, seenRefs) as T;\n }\n\n if (Array.isArray(value)) {\n return value.map(entry => dereferenceRefDeep(entry, definition, seenRefs)) as T;\n }\n\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n out[key] = dereferenceRefDeep((value as Record<string, unknown>)[key], definition, seenRefs);\n }\n\n return out as T;\n}\n\n/**\n * Recursively collect all `$ref` pointers in a schema.\n *\n */\nexport function collectRefsInSchema(schema: unknown): Set<string> {\n const refs = new Set<string>();\n if (!schema || typeof schema !== 'object') return refs;\n const obj = schema as Record<string, unknown>;\n if (isRef(obj)) {\n refs.add(obj.$ref);\n }\n\n for (const value of Object.values(obj)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n for (const r of collectRefsInSchema(item)) refs.add(r);\n }\n } else if (value && typeof value === 'object') {\n for (const r of collectRefsInSchema(value)) refs.add(r);\n }\n }\n\n return refs;\n}\n\n/**\n * Given a set of `$ref` pointers and a full set of schema objects, mapped to their reference\n * locations, return only the schemas that are transitively referenced from those schemas.\n *\n */\nexport function filterRequiredRefsToReferenced(\n requiredRefs: Set<string>,\n usedSchemas: Map<string, SchemaObject>,\n): Map<string, SchemaObject> {\n const referenced = new Set(requiredRefs);\n\n let prevSize = 0;\n while (referenced.size > prevSize) {\n prevSize = referenced.size;\n for (const ref of referenced) {\n const schema = usedSchemas.get(ref);\n if (schema) {\n for (const r of collectRefsInSchema(schema)) {\n referenced.add(r);\n }\n }\n }\n }\n\n const filtered = new Map<string, SchemaObject>();\n for (const ref of referenced) {\n const s = usedSchemas.get(ref);\n if (s !== undefined) {\n filtered.set(ref, s);\n }\n }\n\n return filtered;\n}\n\n/**\n * Parse a `$ref` pointers (e.g. `#/x-definitions/MySchema` or `#/components/schemas/Foo`) into\n * path segments. Returns `null` if the first segment is reserved (we should not embed at root\n * under that key).\n *\n */\nfunction getRefPathSegments(ref: string): string[] | null {\n if (!ref.startsWith('#/')) return null;\n const path = ref\n .slice(2)\n .split('/')\n .map(seg => {\n // We need to decode these segments twice because the first decode is to decode encoded JSON\n // pointer segments, and the second is to decode any URI-encoded segments.\n return decodeURIComponent(decodePointer(seg));\n });\n\n if (path.length < 2) {\n // We need at least two pieces of a `$ref` for it to be valid. e.g. `#/x-definitions/MySchema`\n // or `#/components/schemas/Foo`.\n return null;\n }\n\n return path;\n}\n\nfunction isArrayIndexSegment(seg: string): boolean {\n return /^\\d+$/.test(seg);\n}\n\nfunction childShouldBeSchemaArray(parentKey: string, childSeg: string | undefined): boolean {\n if (!childSeg || !isArrayIndexSegment(childSeg)) {\n return false;\n }\n\n return parentKey === 'allOf' || parentKey === 'anyOf' || parentKey === 'oneOf';\n}\n\n/**\n * Merge referenced schemas into the root schema at the paths defined by their reference location.\n *\n * @example `#/components/schemas/MySchema` -> `root.components.schemas.MySchema`\n */\nexport function mergeReferencedSchemasIntoRoot(root: SchemaObject, refToSchema: Map<string, unknown>): void {\n // we need to sort this so parent schemas are placed before child schemas to\n // prevent a parent from overwriting a child's synthetically created path\n // sorting by path depth (shallowest first)\n const sortedEntries = [...refToSchema.entries()].toSorted((a, b) => {\n const aDepth = a[0].split('/').length;\n const bDepth = b[0].split('/').length;\n return aDepth - bDepth;\n });\n\n for (const [ref, schema] of sortedEntries) {\n const segments = getRefPathSegments(ref);\n if (!segments || segments.length === 0) {\n continue;\n }\n\n let current: SchemaObject = root;\n let pathInvalid = false;\n\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i] as keyof SchemaObject;\n const nextSeg = segments[i + 1];\n\n if (Array.isArray(current)) {\n const idx = Number(seg);\n if (!Number.isInteger(idx) || idx < 0) {\n pathInvalid = true;\n break;\n }\n\n const slot: SchemaObject = current[idx];\n if (slot === undefined || slot === null || typeof slot !== 'object' || Array.isArray(slot)) {\n const nextObj: SchemaObject = {};\n current[idx] = nextObj;\n current = nextObj;\n } else {\n current = slot;\n }\n\n continue;\n }\n\n const cur = current;\n const existing = cur[seg] as SchemaObject;\n\n if (childShouldBeSchemaArray(seg, nextSeg)) {\n if (!Array.isArray(existing)) {\n cur[seg] = [];\n }\n\n current = cur[seg] as unknown[];\n continue;\n }\n\n let next: Record<string, unknown>;\n if (existing !== undefined && existing !== null && typeof existing === 'object' && !Array.isArray(existing)) {\n next = existing as Record<string, unknown>;\n } else {\n next = {};\n cur[seg] = next;\n }\n\n current = next;\n }\n\n if (pathInvalid) {\n continue;\n }\n\n const lastSeg = segments[segments.length - 1] as keyof SchemaObject;\n if (Array.isArray(current)) {\n const idx = Number(lastSeg);\n if (!Number.isInteger(idx) || idx < 0) {\n continue;\n }\n\n current[idx] = schema;\n } else {\n current[lastSeg] = schema;\n }\n }\n}\n","import type { SchemaObject } from '../types.js';\n\nexport function hasSchemaType(schema: SchemaObject, discriminator: 'array' | 'object'): boolean {\n if (Array.isArray(schema.type)) {\n return schema.type.includes(discriminator);\n }\n\n return schema.type === discriminator;\n}\n\nexport function isObject(val: unknown): val is Record<string, unknown> {\n return typeof val === 'object' && val !== null && !Array.isArray(val);\n}\n\nexport function isPrimitive(val: unknown): val is boolean | number | string {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n","/**\n * @deprecated Use `structuredClone` instead\n */\nexport function cloneObject<T>(obj: T): T {\n if (typeof obj === 'undefined') {\n return undefined as T;\n }\n\n // oxlint-disable-next-line readme/json-parse-try-catch\n return JSON.parse(JSON.stringify(obj));\n}\n","import type { DiscriminatorChildrenMap, DiscriminatorObject, OASDocument, SchemaObject } from '../types.js';\n\nimport { isRef } from '../types.js';\n\nimport { cloneObject } from './clone-object.js';\nimport { decodePointer, encodePointer } from './refs.js';\n\n/**\n * Determines if a schema has a discriminator but is missing oneOf/anyOf polymorphism.\n *\n * @param schema Schema to check.\n * @returns If the schema has a discriminator but no oneOf/anyOf.\n */\nfunction hasDiscriminatorWithoutPolymorphism(schema: SchemaObject): boolean {\n if (!schema || typeof schema !== 'object') return false;\n if (!('discriminator' in schema)) return false;\n if ('oneOf' in schema || 'anyOf' in schema) return false;\n return true;\n}\n\n/**\n * Checks if a schema's allOf contains a $ref to a specific schema name.\n *\n * @param schema Schema to check.\n * @param targetSchemaName The schema name to look for (e.g., 'Pet').\n * @returns If the schema's allOf contains a $ref to the target schema.\n */\nfunction allOfReferencesSchema(schema: SchemaObject, targetSchemaName: string): boolean {\n if (!schema || typeof schema !== 'object') return false;\n if (!('allOf' in schema) || !Array.isArray(schema.allOf)) return false;\n\n return schema.allOf.some(item => {\n if (isRef(item)) {\n // Check if the $ref points to the target schema\n // Format: #/components/schemas/SchemaName\n const refParts = item.$ref.split('/');\n const refSchemaName = decodePointer(refParts[refParts.length - 1]);\n return refSchemaName === targetSchemaName;\n }\n\n return false;\n });\n}\n\n/**\n * Phase 1: Before dereferencing, identify discriminator schemas and their children via allOf\n * inheritance. Returns a mapping that can be used after dereferencing.\n *\n * We don't add oneOf here because that would create circular references\n * (Pet → Cat → Pet via allOf) which would break dereferencing.\n *\n * Note: Schemas defined in mapping but NOT declared using anyOf, allOf or oneOf will not be considered\n * a valid child. The discriminator object is legal only when using one of the composite keywords oneOf, anyOf, allOf.\n * @link https://spec.openapis.org/oas/v3.1.0.html#fixed-fields-20\n *\n * @param api The OpenAPI definition to process (before dereferencing).\n * @returns Maps of discriminator schema names to their child schema names and `$ref` pointers.\n */\nexport function findDiscriminatorChildren(definition: Pick<OASDocument, 'components'>): {\n children: DiscriminatorChildrenMap;\n refs: Map<string, string>;\n} {\n const childrenMap: DiscriminatorChildrenMap = new Map();\n const childrenRefMap = new Map<string, string>();\n\n if (!definition?.components?.schemas || typeof definition.components.schemas !== 'object') {\n return { children: childrenMap, refs: childrenRefMap };\n }\n\n const schemas = definition.components.schemas as Record<string, SchemaObject>;\n const schemaNames = Object.keys(schemas);\n\n // Find all schemas with discriminator but no oneOf/anyOf\n const discriminatorSchemas: string[] = schemaNames.filter(name => {\n return hasDiscriminatorWithoutPolymorphism(schemas[name]);\n });\n\n // For each discriminator schema, record child schema names\n for (const baseName of discriminatorSchemas) {\n const baseSchema = schemas[baseName] as SchemaObject & { discriminator: DiscriminatorObject };\n const discriminator = baseSchema.discriminator;\n\n let childSchemaNames: string[] = [];\n\n // If there's already a mapping defined, use it but only include schemas that\n // actually inherit from this parent via allOf. A mapping entry for a schema\n // that doesn't use allOf is just a value resolution hint, not a declaration\n // of inheritance.\n if (discriminator.mapping && typeof discriminator.mapping === 'object') {\n const mappingRefs = Object.values(discriminator.mapping);\n if (mappingRefs.length > 0) {\n childSchemaNames = mappingRefs\n .map(value => {\n // Bare schema names are literal keys; only decode names extracted from ref pointers.\n if (Object.hasOwn(schemas, value)) {\n return value;\n }\n\n const encodedName = value.split('/').pop() ?? '';\n return decodePointer(encodedName);\n })\n .filter((name): name is string => {\n if (!name) return false;\n const childSchema = schemas[name];\n return !!childSchema && allOfReferencesSchema(childSchema, baseName);\n });\n }\n }\n\n // Otherwise, scan for schemas that extend this base via allOf\n if (!childSchemaNames.length) {\n childSchemaNames = schemaNames.filter(name => {\n if (name === baseName) return false;\n return allOfReferencesSchema(schemas[name], baseName);\n });\n }\n\n // Store child schema names in the map\n if (childSchemaNames.length) {\n for (const childName of childSchemaNames) {\n childrenRefMap.set(childName, `#/components/schemas/${encodePointer(childName)}`);\n }\n\n childrenMap.set(baseName, childSchemaNames);\n childrenRefMap.set(baseName, `#/components/schemas/${encodePointer(baseName)}`);\n }\n }\n\n return { children: childrenMap, refs: childrenRefMap };\n}\n\n/**\n * Apply discriminator oneOf to a map of used schemas (e.g. from `getParametersAsJSONSchema` and\n * `getResponseAsJSONSchema`). For each discriminator base in `usedSchemas`, it ensures children\n * are in the map via `getOrAddSchema`, then sets `oneOf` on the base.\n *\n * Optionally this also strips `oneOf` from the base when it appears inside a child's `allOf`\n * schema.\n *\n * @param api The OpenAPI definition (for findDiscriminatorChildren).\n * @param usedSchemas Map of schema name -> JSON Schema to update.\n * @param getOrAddSchema Callback that resolves, converts, and adds a schema by name; returns the converted schema or undefined.\n */\nexport function applyDiscriminatorOneOfToUsedSchemas(\n definition: Pick<OASDocument, 'components'>,\n usedSchemas: Map<string, SchemaObject>,\n getOrAddSchema: (ref: string) => SchemaObject | undefined,\n): void {\n const { children: childrenMap, refs: childrenRefMap } = findDiscriminatorChildren(definition);\n if (!childrenMap.size) return;\n\n // Build oneOf for each discriminator schema\n for (const [baseName, childNames] of childrenMap) {\n const baseRef = childrenRefMap.get(baseName);\n if (!baseRef) continue;\n\n const baseSchema = usedSchemas.get(baseRef);\n if (!baseSchema || typeof baseSchema !== 'object') continue;\n\n // Build `oneOf` from raw child schema `$ref` pointers.\n const oneOf: SchemaObject[] = [];\n for (const childName of childNames) {\n const childRef = childrenRefMap.get(childName);\n if (!childRef) continue;\n\n const childSchema = getOrAddSchema(childRef);\n if (childSchema) {\n oneOf.push({\n $ref: childRef,\n });\n }\n }\n\n if (oneOf.length > 0) {\n (baseSchema as Record<string, unknown>).oneOf = oneOf;\n }\n }\n\n // Strip `oneOf` from discriminator schemas embedded in child `allOf` structures.\n //\n // When `Cat` extends `Pet` via an `allOf` and `Pet` has a `discriminator` with a `oneOf` the\n // embedded `Pet` inside `Cat`'s `allOf` should NOT have `oneOf` because this would create a\n // circular `Cat.allOf[0].oneOf[0] = Cat` reference.\n //\n // We only strip from `allOf` entries to preserve `oneOf` in direct references.\n for (const [parentSchemaName, childNames] of childrenMap) {\n for (const childName of childNames) {\n const childRef = childrenRefMap.get(childName);\n if (!childRef) continue;\n\n const childSchema = usedSchemas.get(childRef);\n if (!childSchema || !('allOf' in childSchema) || !Array.isArray(childSchema.allOf)) {\n continue;\n }\n\n for (let i = 0; i < childSchema.allOf.length; i++) {\n const item = childSchema.allOf[i];\n if (\n item &&\n typeof item === 'object' &&\n 'x-readme-ref-name' in item &&\n item['x-readme-ref-name'] === parentSchemaName &&\n 'oneOf' in item\n ) {\n // Clone the allOf entry and strip oneOf from the clone to avoid mutating the shared reference.\n // This ensures Pet in components.schemas keeps its oneOf while embedded Pet in Cat's allOf doesn't.\n const clonedItem = cloneObject(item);\n delete clonedItem.oneOf;\n childSchema.allOf[i] = clonedItem;\n }\n }\n }\n }\n}\n","import type {\n ExampleObject,\n JSONSchema,\n OASDocument,\n ReferenceObject,\n RequestBodyObject,\n SchemaObject,\n} from '../types.js';\nimport type { JSONSchema4, JSONSchema7TypeName } from 'json-schema';\nimport type { Options as JSONSchemaMergeAllOfOptions } from 'json-schema-merge-allof';\n\nimport mergeJSONSchemaAllOf from 'json-schema-merge-allof';\nimport jsonpointer from 'jsonpointer';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport { isOpenAPI30, isRef, isSchema } from '../types.js';\n\nimport { hasSchemaType, isObject, isPrimitive } from './helpers.js';\nimport { collectRefsInSchema, dereferenceRef, encodePointer } from './refs.js';\n\n/**\n * This list has been pulled from `openapi-schema-to-json-schema` but been slightly modified to fit\n * within the constraints in which ReadMe uses the output from this library in schema form\n * rendering as while properties like `readOnly` aren't represented within JSON Schema, we support\n * it within that library's handling of OpenAPI-friendly JSON Schema.\n *\n * @see {@link https://github.com/openapi-contrib/openapi-schema-to-json-schema/blob/main/src/consts.ts}\n */\nconst UNSUPPORTED_SCHEMA_PROPS = [\n 'example', // OpenAPI supports `example` but we're mapping it to `examples` in this library.\n 'externalDocs',\n 'xml',\n] as const;\n\n/**\n * Annotation-only keywords we preserve when they appear as siblings of `$ref` inside `allOf`\n * properties. Validation keywords (`type`, `properties`, `items`, etc.) are intentionally\n * excluded, they would conflict with the resolved schema. `x-` extensions are also preserved\n * (handled separately at the call site).\n */\nconst METADATA_SIBLING_KEYS = new Set(['description', 'summary', 'title']);\n\nconst mergeAllOfSchemasOptions: JSONSchemaMergeAllOfOptions = {\n ignoreAdditionalProperties: true,\n resolvers: {\n // `merge-json-schema-allof` by default takes the first `description` when you're merging an\n // `allOf` but because generally when you're merging two schemas together with an `allOf` you\n // want data in the subsequent schemas to be applied to the first and `description` should be a\n // part of that.\n description: (obj: string[]) => {\n return obj.slice(-1)[0];\n },\n\n // `merge-json-schema-allof` doesn't support merging enum arrays but since that's a safe and\n // simple operation as enums always contain primitives we can handle it ourselves with a custom\n // resolver. We intersect the arrays so that child schemas can narrow a parent's broad enum\n // (e.g. [1,2,20,50] ∩ [1] = [1]).\n //\n // We unfortunately need to cast our return value as `any[]` because the internal types of\n // `merge-json-schema-allof`'s `enum` resolver are not portable.\n enum: (obj: unknown[]) => {\n const arrays = obj as any[][];\n const intersection = arrays.reduce((acc, e) => acc.filter(v => e.includes(v)));\n return intersection.length > 0 ? intersection : arrays.reduce((acc, e) => acc.concat(e), []);\n },\n\n // For any unknown keywords (e.g., `example`, `format`, `x-readme-ref-name`), we fallback to\n // using the `title` resolver (which uses the first value found).\n // https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/src/index.js#L292\n // https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/README.md?plain=1#L147\n defaultResolver: mergeJSONSchemaAllOf.options.resolvers.title,\n },\n};\n\nexport interface toJSONSchemaOptions {\n /**\n * Whether or not to extend descriptions with a list of any present enums.\n */\n addEnumsToDescriptions?: boolean;\n\n /**\n * Current location within the schema -- this is a JSON pointer.\n */\n currentLocation?: string;\n\n /**\n * An OpenAPI definition to use for schema `$ref` pointer resolutions.\n */\n definition?: OASDocument;\n\n /**\n * Object containing a global set of defaults that we should apply to schemas that match it.\n */\n globalDefaults?: Record<string, unknown>;\n\n /**\n * If you wish to hide properties that are marked as being `readOnly`.\n */\n hideReadOnlyProperties?: boolean;\n\n /**\n * If you wish to hide properties that are marked as being `writeOnly`.\n */\n hideWriteOnlyProperties?: boolean;\n\n /**\n * Is this schema the child of a polymorphic `allOf` schema?\n */\n isPolymorphicAllOfChild?: boolean;\n\n /**\n * Array of parent `default` schemas to utilize when attempting to path together schema defaults.\n */\n prevDefaultSchemas?: SchemaObject[];\n\n /**\n * Array of parent `example` schemas to utilize when attempting to path together schema examples.\n */\n prevExampleSchemas?: SchemaObject[];\n\n /**\n * A function that's called anytime a (circular) `$ref` is found.\n */\n refLogger?: (ref: string, type: 'discriminator' | 'ref') => void;\n\n /**\n * Tracks component `$ref` pointers that were already emitted as bare `{ $ref }` stubs in this\n * conversion. Used so a later duplicate bare `$ref` to the same component keeps the stub,\n * while a bare `$ref` that follows an `allOf` merge of the same ref still inlines the expanded\n * schema.\n */\n refsEmittedAsStub?: Set<string>;\n\n /**\n * A set of `$ref` pointers that have been seen during JSON Schema generation.\n */\n seenRefs?: Set<string>;\n\n /**\n * A dictionary of referenced schema names to their compiled JSON Schema objects.\n */\n usedSchemas?: Map<string, SchemaObject>;\n}\n\n/**\n * Placeholder value in `usedSchemas` while a schema is being converted (used for circular\n * references).\n */\nconst PENDING_SCHEMA = { __pending: true } as unknown as SchemaObject;\n\nfunction isPendingSchema(s: SchemaObject): boolean {\n return isObject(s) && '__pending' in s && (s as Record<string, unknown>).__pending === true;\n}\n\nexport function getSchemaVersionString(schema: SchemaObject, api: OASDocument): string {\n // If we're not on OpenAPI 3.1+ then we should fall back to the default schema version.\n if (isOpenAPI30(api)) {\n // This should remain as an HTTP url, not HTTPS.\n return 'http://json-schema.org/draft-04/schema#';\n }\n\n // If the schema indicates the version, prefer that.\n if (schema.$schema) {\n return schema.$schema;\n }\n\n // If the user defined a global schema version on their OAS document, prefer that.\n if (api.jsonSchemaDialect) {\n return api.jsonSchemaDialect;\n }\n\n return 'https://json-schema.org/draft/2020-12/schema#';\n}\n\nfunction isPolymorphicSchema(schema: SchemaObject): boolean {\n return 'allOf' in schema || 'anyOf' in schema || 'oneOf' in schema;\n}\n\nfunction formatEnumDescription(values: unknown[]): string {\n return values\n .filter(value => value !== undefined && (typeof value !== 'string' || value.trim() !== ''))\n .map(value => `\\`${value}\\``)\n .join(' ');\n}\n\nfunction withoutGeneratedEnumDescription(schema: SchemaObject): SchemaObject {\n if (!Array.isArray(schema.enum) || typeof schema.description !== 'string') {\n return schema;\n }\n\n const enumDescription = formatEnumDescription(schema.enum);\n if (!enumDescription) {\n return schema;\n }\n\n const paragraphs = schema.description.split(/\\n\\n+/);\n if (!paragraphs.includes(enumDescription)) {\n return schema;\n }\n\n const description = paragraphs.filter(paragraph => paragraph !== enumDescription).join('\\n\\n');\n const updatedSchema = { ...schema };\n\n if (description) {\n updatedSchema.description = description;\n } else {\n delete updatedSchema.description;\n }\n\n return updatedSchema;\n}\n\n/**\n * Decides if a single `oneOf` / `anyOf` entry should be merged with the parent schemas' sibling\n * `items` by wrapping both in `allOf` and running them through `toJSONSchema` (which merges\n * `allOf` schemas together).\n *\n * The reason this exists is that end-users sometimes place `items` next to `oneOf` and `anyOf`\n * declarations within the same schema and we want to attach those element constraints to each\n * polymorphic branch. This however only works when the branch and `items` can be merged, otherwise\n * `json-schema-merge-allof` will throw an exception (eg. you can't merge `object` and `array`\n * together), resulting in us returning an invalid schema of `{}`.\n *\n */\nfunction shouldFoldParentItemsIntoPolymorphBranch(item: unknown): boolean {\n if (!isObject(item)) return false;\n if (isRef(item)) return true;\n\n const branch: SchemaObject = item;\n if (!('type' in branch) || branch.type === undefined) return true;\n if (!hasSchemaType(branch, 'array')) return false;\n\n return !('items' in branch) || branch.items === undefined;\n}\n\n/**\n * Determine if a polymorphic schema is comprised of empty schemas.\n *\n */\nfunction isEmptyPolymorphicSchema(list: unknown): boolean {\n if (!Array.isArray(list)) return false;\n if (!list.length) return true;\n\n return list.every(branch => {\n if (branch === null || branch === undefined) return true;\n if (typeof branch !== 'object' || Array.isArray(branch)) return false;\n return Array.isArray(branch) ? !branch.length : !Object.keys(branch as object).length;\n });\n}\n\n/**\n * Inline any `$ref` pointer into an objects schema so that `json-schema-merge-allof` can merge\n * them together. We need to do this because `json-schema-merge-allof` does not support `$ref`\n * pointer resolution.\n */\nfunction inlinePropertyRefsForMerge(\n schema: SchemaObject,\n usedSchemas: Map<string, SchemaObject>,\n refLogger: NonNullable<toJSONSchemaOptions['refLogger']>,\n conflictPaths?: Set<string>,\n currentPath?: string,\n): SchemaObject {\n const out = structuredClone(schema);\n if (!('properties' in out) || typeof out.properties !== 'object' || out.properties === null) {\n return out;\n }\n\n for (const key of Object.keys(out.properties)) {\n const path = currentPath ? `${currentPath}.${key}` : key;\n const val = out.properties[key];\n if (isRef(val)) {\n // Do not inline `#/paths/...` refs when we merge `allOf` schemas together, they should\n // remain untouched so we can preserve them later.\n if (val.$ref.startsWith('#/paths/')) {\n refLogger(val.$ref, 'ref');\n continue;\n }\n\n const resolved = usedSchemas.get(val.$ref);\n if (resolved !== undefined && !isPendingSchema(resolved)) {\n const isConflictPath = conflictPaths?.has(path) ?? false;\n\n // At conflict paths, recurse so nested `$ref`s in the chain are inlined too\n // otherwise the merge sees a surviving `$ref` and drops sibling properties.\n // NOTE: we only recurse down to the first non conflict path and not the full resolution\n const inlined: SchemaObject = isConflictPath\n ? inlinePropertyRefsForMerge(structuredClone(resolved), usedSchemas, refLogger, conflictPaths, path)\n : structuredClone(resolved);\n\n // Preserve metadata-only siblings (e.g. `description`, `title`) alongside a `$ref` so\n // they survive `allOf` merging. Validation keywords (`properties`, `items`, `type`, etc.)\n // are dropped.\n //\n // The spec treats `{$ref: \"...\"}` in a schema slot differently across versions:\n //\n // - OAS 3.0: it becomes a Reference Object (the Schema Object section says \"a Reference\n // Object can be used in its place\"), and Reference Objects forbid siblings. So 3.0\n // strips everything.\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#schema-object\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#reference-object\n //\n // - OAS 3.1: it stays a Schema Object with `$ref` as a JSON Schema 2020-12 keyword. Per\n // JSON Schema 2020-12 §8.2.3.1, \"$ref\" is an applicator whose \"results are the results\n // of the referenced schema\", and the spec explicitly notes that \"other keywords can\n // appear alongside of '$ref' in the same schema object\". Those siblings are part of\n // the same schema; the spec doesn't say a `$ref` causes them to be dropped.\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#schema-object\n // https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.3.1\n //\n // Since we flatten via spread instead of evaluating siblings alongside the resolved\n // schema, validation keywords would silently overwrite the referenced schema's\n // constraints. We drop them to avoid that; annotation-only siblings (and `x-` extensions)\n // are safe to carry through. This is a deliberate, narrow deviation from the spec.\n\n const siblings: Record<string, unknown> = {};\n for (const siblingKey of Object.keys(val)) {\n if (METADATA_SIBLING_KEYS.has(siblingKey) || siblingKey.startsWith('x-')) {\n siblings[siblingKey] = (val as Record<string, unknown>)[siblingKey];\n }\n }\n out.properties[key] = {\n ...inlined,\n ...siblings,\n };\n }\n } else if (val && typeof val === 'object' && !Array.isArray(val)) {\n if ('properties' in val) {\n out.properties[key] = inlinePropertyRefsForMerge(\n val as SchemaObject,\n usedSchemas,\n refLogger,\n conflictPaths,\n path,\n );\n }\n\n // Inline allOf-path refs inside oneOf/anyOf to prevent synthetic allOf scaffolding.\n inlineAllOfRefsDeep((out.properties[key] ?? val) as SchemaObject, usedSchemas);\n }\n }\n\n return out;\n}\n\n/**\n * Finds property paths that appear in two or more `allOf` branches. These are the paths where a\n * surviving `$ref` would cause `json-schema-merge-allof` to drop sibling properties, so callers\n * use this set to know where to deep-resolve refs before merging.\n *\n * usedSchemas isnt actually a must here. the walk does use that map for $ref resolution, but missing\n * entries or a completely empty map will not cause any errors, it just wont find all the conflict paths.\n * however, in theory, usedSchemas should already contain all the possible $refs since that should\n * be resolved and populated by toJSONSchema, the only caller of this function\n */\nfunction collectConflictPaths(allOfBranches: SchemaObject[], usedSchemas: Map<string, SchemaObject>): Set<string> {\n // Maps each property path to the number of branches that reach it.\n const pathBranchCount = new Map<string, number>();\n\n // Reset between branches.\n const pathsSeenInThisBranch = new Set<string>();\n const refsCurrentlyResolving = new Set<string>();\n\n function recordPath(path: string): void {\n if (pathsSeenInThisBranch.has(path)) return;\n pathsSeenInThisBranch.add(path);\n pathBranchCount.set(path, (pathBranchCount.get(path) ?? 0) + 1);\n }\n\n function walk(schema: unknown, path?: string): void {\n if (!isObject(schema)) return;\n\n // Resolve `$ref`s and keep walking from the resolved schema. If we re-enter a ref we're\n // already resolving, that's a circular reference. bail\n if (typeof schema.$ref === 'string') {\n const ref = schema.$ref;\n const resolved = usedSchemas.get(ref);\n\n // bail out if we see a ref we're already resolving, or if the ref is not resolved or is pending\n // or even if the resolved schema doesnt exists in useSchemas\n if (refsCurrentlyResolving.has(ref) || !resolved || isPendingSchema(resolved)) return;\n\n refsCurrentlyResolving.add(ref);\n walk(resolved, path);\n refsCurrentlyResolving.delete(ref);\n return;\n }\n\n if (!isObject(schema.properties)) return;\n for (const [propertyName, childSchema] of Object.entries(schema.properties)) {\n const childPath = path ? `${path}.${propertyName}` : propertyName;\n recordPath(childPath);\n walk(childSchema, childPath);\n }\n }\n\n for (const branch of allOfBranches) {\n pathsSeenInThisBranch.clear();\n refsCurrentlyResolving.clear();\n walk(branch);\n }\n\n const conflictPaths = new Set<string>();\n for (const [path, branchCount] of pathBranchCount) {\n if (branchCount > 1) conflictPaths.add(path);\n }\n return conflictPaths;\n}\n\n/**\n * Some OAS specs use `$ref` pointers that path through `allOf`, e.g.\n * `#/components/schemas/Foo/allOf/1/properties/bar`. After `toJSONSchema` merges the `allOf` flat,\n * these paths become stale, the `allOf` no longer exists in the output. If left as stubs,\n * `mergeReferencedSchemasIntoRoot` recreates a synthetic `allOf` to make them resolvable, which\n * causes downstream consumers to re-merge it and duplicate `oneOf`/`anyOf` entries.\n *\n * This function walks `oneOf`/`anyOf` options and their nested `properties` to find and inline\n * these stale refs. Only refs containing `/allOf/` are replaced and regular component refs are\n * left as stubs for render-time resolution.\n */\nfunction inlineAllOfRefsDeep(schema: SchemaObject, usedSchemas: Map<string, SchemaObject>): void {\n const allOfKey = '/allOf';\n\n for (const keyword of ['oneOf', 'anyOf'] as const) {\n if (!Array.isArray(schema[keyword])) continue;\n for (let i = 0; i < schema[keyword].length; i++) {\n const option = schema[keyword][i] as SchemaObject | undefined;\n if (!option || typeof option !== 'object') continue;\n if (isRef(option) && option.$ref.includes(allOfKey)) {\n const resolved = usedSchemas.get(option.$ref);\n if (resolved !== undefined && !isPendingSchema(resolved)) {\n schema[keyword][i] = structuredClone(resolved);\n }\n } else if (!isRef(option)) {\n inlineAllOfRefsDeep(option, usedSchemas);\n }\n }\n }\n\n // We cant rely on `inlinePropertyRefsForMerge` here because it inlines ALL refs, we only\n // want to inline refs through `/allOf/` paths, leaving component refs as stubs.\n if ('properties' in schema && typeof schema.properties === 'object' && schema.properties !== null) {\n for (const key of Object.keys(schema.properties)) {\n const val = schema.properties[key];\n if (isRef(val) && val.$ref.includes(allOfKey)) {\n const resolved = usedSchemas.get(val.$ref);\n if (resolved !== undefined && !isPendingSchema(resolved)) {\n schema.properties[key] = structuredClone(resolved);\n }\n } else if (val && typeof val === 'object' && !Array.isArray(val) && !isRef(val)) {\n inlineAllOfRefsDeep(val as SchemaObject, usedSchemas);\n }\n }\n }\n\n // refs through `allOf/` in `items` and `additionalProperties` are resolved via the depth-sorted\n // scaffold in `mergeReferencedSchemasIntoRoot` (refs.ts)\n}\n\n/**\n * Resolve and convert a `$ref` schema, caching the converted result in `usedSchemas`.\n *\n * This helper always attempts to dereference and convert the target schema while guarding against\n * circular/invalid refs with `PENDING_SCHEMA`. The `returnMode` controls whether the caller gets\n * back the original `$ref` pointer or the converted JSON Schema representation.\n */\nfunction resolveAndCacheRefSchema({\n schema,\n definition,\n usedSchemas,\n seenRefs,\n conversionOptions,\n returnMode,\n refLogger,\n}: {\n schema: ReferenceObject;\n definition: OASDocument;\n usedSchemas: Map<string, SchemaObject>;\n seenRefs: Set<string>;\n conversionOptions: toJSONSchemaOptions;\n returnMode: 'ref' | 'converted';\n refLogger: NonNullable<toJSONSchemaOptions['refLogger']>;\n}): SchemaObject {\n const ref = schema.$ref;\n const refsEmittedAsStub = conversionOptions.refsEmittedAsStub;\n const existing = usedSchemas.get(ref);\n if (existing !== undefined && !isPendingSchema(existing)) {\n if (returnMode === 'converted') {\n return existing;\n }\n\n // If we have already seen this bare `$ref` pointer before, and emitted it as a stub, then we\n // should do the same again here.\n if (refsEmittedAsStub?.has(ref)) {\n return { $ref: ref };\n }\n\n // If this existing schema isn't a `$ref` pointer then we should return it as-is.\n if (!isRef(existing)) {\n return structuredClone(existing);\n }\n\n return { $ref: ref };\n }\n\n // If our `$ref` was never resolved away from an in-progress schema then it's either invalid\n // or a circular reference and we should return it as-is.\n if (existing !== undefined && isPendingSchema(existing)) {\n refsEmittedAsStub?.add(ref);\n return { $ref: ref };\n }\n\n usedSchemas.set(ref, PENDING_SCHEMA);\n\n if (returnMode === 'ref') {\n // If we want to return the original `$ref` pointer then we should make an attempt to resolve\n // and lazily dereference it into our `usedSchemas` store.\n let resolved: SchemaObject;\n try {\n const dereferenced = dereferenceRef(schema, definition, seenRefs);\n if (isRef(dereferenced)) {\n refLogger(dereferenced.$ref, 'ref');\n\n let converted: SchemaObject;\n try {\n // `jsonpointer` doesn't understand the `#` prefix that `$ref` pointers have so we need\n // to shave it off.\n const pointer = ref.startsWith('#') ? decodeURIComponent(ref.substring(1)) : ref;\n const rawSchema = jsonpointer.get(definition, pointer);\n if (rawSchema && typeof rawSchema === 'object') {\n converted = toJSONSchema(structuredClone(rawSchema), { ...conversionOptions, seenRefs });\n } else {\n converted = { $ref: ref };\n }\n } catch {\n converted = { $ref: ref };\n }\n\n usedSchemas.set(ref, converted);\n refLogger(ref, 'ref');\n refsEmittedAsStub?.add(ref);\n return { $ref: ref };\n }\n\n resolved = dereferenced;\n } catch {\n refLogger(ref, 'ref');\n usedSchemas.set(ref, { $ref: ref });\n refsEmittedAsStub?.add(ref);\n return { $ref: ref };\n }\n\n const converted = toJSONSchema(structuredClone(resolved), { ...conversionOptions, seenRefs });\n usedSchemas.set(ref, converted);\n refLogger(ref, 'ref');\n refsEmittedAsStub?.add(ref);\n return { $ref: ref };\n }\n\n try {\n // If we want to return the generated and converted JSON Schema object then, if we have a `$ref`\n // pointer we should make an attempt to resolve and lazily dereference that into our converted\n // schema. If that fails then we'll return the original schema.\n const dereferenced = dereferenceRef(schema, definition, seenRefs);\n if (isRef(dereferenced)) {\n let converted: SchemaObject;\n try {\n // `jsonpointer` doesn't understand the `#` prefix that `$ref` pointers have so\n // we need to shave it off.\n const pointer = ref.startsWith('#') ? decodeURIComponent(ref.substring(1)) : ref;\n const rawSchema = jsonpointer.get(definition, pointer);\n if (rawSchema && typeof rawSchema === 'object') {\n converted = toJSONSchema(structuredClone(rawSchema), { ...conversionOptions, seenRefs });\n } else {\n converted = { $ref: ref };\n }\n } catch {\n converted = { $ref: ref };\n }\n\n usedSchemas.set(ref, converted);\n return converted;\n }\n\n const converted = toJSONSchema(structuredClone(dereferenced), { ...conversionOptions, seenRefs });\n usedSchemas.set(ref, converted);\n return converted;\n } catch {\n usedSchemas.set(ref, { $ref: ref });\n return { $ref: ref };\n }\n}\n\nfunction isRequestBodySchema(schema: unknown): schema is RequestBodyObject {\n return 'content' in (schema as RequestBodyObject);\n}\n\n/**\n * Given a JSON pointer, a type of property to look for, and an array of schemas do a reverse\n * search through them until we find the JSON pointer, or part of it, within the array.\n *\n * This function will allow you to take a pointer like `/tags/name` and return back `buster` from\n * the following array:\n *\n * ```\n * [\n * {\n * example: {id: 20}\n * },\n * {\n * examples: {\n * distinctName: {\n * tags: {name: 'buster'}\n * }\n * }\n * }\n * ]\n * ```\n *\n * Within each example the most specific pointer is tried first, so `tags.id` picks up the example's\n * own `tags.id` rather than an `id` further up the stack. If the example has nothing at `tags.id`,\n * the trailing segments of the path (`/id`) are tried next, since that's how an example declared on\n * a nested schema reaches its own properties. This fallback behaviour means a property without an\n * example can inadvertently pick up the value of a shallower property that shares its name - which\n * is okay as any example is usually better than no example regardless.\n *\n * @see {@link https://tools.ietf.org/html/rfc6901}\n * @param property Specific type of schema property to look for a value for.\n * @param pointer JSON pointer to search for an example for.\n * @param schemas Array of previous schemas we've found relating to this pointer.\n */\nfunction searchForValueByPropAndPointer(\n property: 'default' | 'example',\n pointer: string,\n schemas: toJSONSchemaOptions['prevDefaultSchemas'] | toJSONSchemaOptions['prevExampleSchemas'] = [],\n) {\n if (!schemas.length || !pointer.length) {\n return;\n }\n\n const locSplit = pointer.split('/').filter(Boolean).toReversed();\n const pointers = [];\n\n let point = '';\n for (let i = 0; i < locSplit.length; i += 1) {\n point = `/${locSplit[i]}${point}`;\n pointers.push(point);\n }\n\n let foundValue: any;\n const rev = [...schemas].toReversed();\n\n for (let ii = 0; ii < rev.length; ii += 1) {\n let schema = rev[ii];\n\n if (property === 'example') {\n if ('example' in schema) {\n schema = schema.example;\n } else {\n if (!Array.isArray(schema.examples) || !schema.examples.length) {\n continue;\n }\n\n // Prevent us from crashing if `examples` is a completely empty object.\n schema = [...schema.examples].shift();\n }\n } else {\n schema = schema.default;\n }\n\n for (let i = pointers.length - 1; i >= 0; i -= 1) {\n try {\n foundValue = jsonpointer.get(schema, pointers[i]);\n } catch {\n // If the schema we're looking at is `{obj: null}` and our pointer is `/obj/propertyName`\n // `jsonpointer` will throw an error. If that happens, we should silently catch and toss it\n // and return no example.\n }\n\n if (foundValue !== undefined) {\n break;\n }\n }\n\n if (foundValue !== undefined) {\n break;\n }\n }\n\n return foundValue;\n}\n\n/**\n * Given an OpenAPI-flavored JSON Schema, make an effort to modify it so it's shaped more towards\n * stock JSON Schema.\n *\n * Why do this?\n *\n * 1. OpenAPI 3.0.x supports its own flavor of JSON Schema that isn't fully compatible with most\n * JSON Schema tooling (like `@readme/oas-form` or `@rjsf/core`).\n * 2. While validating an OpenAPI definition will prevent corrupted or improper schemas from\n * occuring, we have a lot of legacy schemas in ReadMe that were ingested before we had proper\n * validation in place, and as a result have some API definitions that will not pass validation\n * right now. In addition to reshaping OAS-JSON Schema into JSON Schema this library will also\n * fix these improper schemas: things like `type: object` having `items` instead of `properties`,\n * or `type: array` missing `items`.\n * 3. To ease the burden of polymorphic handling on our form rendering engine we make an attempt\n * to merge `allOf` schemas here.\n * 4. Additionally due to OpenAPI 3.0.x not supporting JSON Schema, in order to support the\n * `example` keyword that OAS supports, we need to do some work in here to remap it into\n * `examples`. However, since all we care about in respect to examples for usage within\n * `@readme/oas-form`, we're only retaining primitives. This *slightly* deviates from JSON\n * Schema in that JSON Schema allows for any schema to be an example, but since\n * `@readme/oas-form` can only actually **render** primitives, that's what we're retaining.\n * 5. Though OpenAPI 3.1 does support full JSON Schema, this library should be able to handle it\n * without any problems.\n *\n * And why use this over `@openapi-contrib/openapi-schema-to-json-schema`? Fortunately and\n * unfortunately we've got a lot of API definitions in our database that aren't currently valid so\n * we need to have a lot of bespoke handling for odd quirks, typos, and missing declarations that\n * might be present.\n *\n * @todo add support for `schema: false` and `not` cases.\n * @todo tighten up `data` to allow for `SchemaObject | ReferenceObject`\n * @see {@link https://json-schema.org/draft/2019-09/json-schema-validation.html}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schema-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object}\n * @param data OpenAPI Schema Object to convert to pure JSON Schema.\n */\nexport function toJSONSchema(data: SchemaObject | boolean, opts?: toJSONSchemaOptions): SchemaObject {\n let schema = data === true ? {} : { ...data };\n const schemaAdditionalProperties = isSchema(schema) ? schema.additionalProperties : null;\n\n const {\n addEnumsToDescriptions,\n currentLocation,\n definition,\n globalDefaults,\n hideReadOnlyProperties,\n hideWriteOnlyProperties,\n isPolymorphicAllOfChild,\n prevDefaultSchemas = [],\n prevExampleSchemas = [],\n refLogger,\n seenRefs,\n usedSchemas,\n refsEmittedAsStub = new Set<string>(),\n } = {\n addEnumsToDescriptions: false,\n currentLocation: '',\n globalDefaults: {},\n hideReadOnlyProperties: false,\n hideWriteOnlyProperties: false,\n isPolymorphicAllOfChild: false,\n prevDefaultSchemas: [] as toJSONSchemaOptions['prevDefaultSchemas'],\n prevExampleSchemas: [] as toJSONSchemaOptions['prevExampleSchemas'],\n refLogger: () => true,\n seenRefs: new Set<string>(),\n usedSchemas: new Map<string, SchemaObject>(),\n refsEmittedAsStub: new Set<string>(),\n ...opts,\n };\n\n const polyOptions: toJSONSchemaOptions = {\n addEnumsToDescriptions,\n currentLocation,\n definition,\n globalDefaults,\n hideReadOnlyProperties,\n hideWriteOnlyProperties,\n isPolymorphicAllOfChild: false,\n prevDefaultSchemas,\n prevExampleSchemas,\n refLogger,\n seenRefs,\n usedSchemas,\n refsEmittedAsStub,\n };\n\n function convertExamples(obj: SchemaObject): void {\n if ('example' in obj) {\n if (isPrimitive(obj.example)) {\n obj.examples = [obj.example];\n } else if (Array.isArray(obj.example)) {\n obj.examples = (obj.example as unknown[]).filter(example => isPrimitive(example));\n if (!(obj.examples as unknown[]).length) {\n delete obj.examples;\n }\n } else {\n prevExampleSchemas.push({ example: obj.example });\n }\n delete obj.example;\n } else if ('examples' in obj) {\n let reshapedExamples = false;\n if (typeof obj.examples === 'object' && obj.examples !== null && !Array.isArray(obj.examples)) {\n const examples: unknown[] = [];\n\n Object.entries(obj.examples as Record<string, unknown>).forEach(([name, example]) => {\n let currentExample = example as ExampleObject | ReferenceObject;\n if (name === '$ref') {\n currentExample = dereferenceRef({ $ref: currentExample } as ReferenceObject, definition, seenRefs);\n if (!currentExample || isRef(currentExample)) {\n refLogger(currentExample.$ref, 'ref');\n return;\n }\n }\n\n if ('value' in currentExample) {\n if (isPrimitive(currentExample.value)) {\n examples.push(currentExample.value);\n reshapedExamples = true;\n } else if (Array.isArray(currentExample.value) && isPrimitive(currentExample.value[0])) {\n examples.push(currentExample.value[0]);\n reshapedExamples = true;\n } else {\n prevExampleSchemas.push({ example: currentExample.value });\n }\n }\n });\n\n if (examples.length) {\n reshapedExamples = true;\n obj.examples = examples;\n }\n } else if (Array.isArray(obj.examples) && isPrimitive((obj.examples as unknown[])[0])) {\n reshapedExamples = true;\n } else if (Array.isArray(obj.examples) && isObject((obj.examples as unknown[])[0])) {\n prevExampleSchemas.push({ example: (obj.examples as unknown[])[0] });\n }\n\n if (!reshapedExamples) {\n delete obj.examples;\n }\n }\n }\n\n // If this schema contains a `$ref` make an attempt to resolve and convert it into our\n // `usedSchemas` store, but still return the `$ref` in output so we preserve reference identity\n // instead of inlining a duplicate converted schema at this location.\n if (isRef(schema)) {\n if (definition && usedSchemas) {\n const resolved = resolveAndCacheRefSchema({\n schema,\n definition,\n usedSchemas,\n seenRefs,\n conversionOptions: polyOptions,\n returnMode: 'ref',\n refLogger,\n });\n\n // Preserve metadata siblings (e.g. description, summary) alongside `$ref` pointers because\n // OpenAPI 3.1 allows those to exist as local overrides. The `properties` keyword at the same\n // level as `$ref` however is invalid in JSON Schema and should be ignored.\n const { $ref: _$ref, properties: _propertiesWithRef, ...siblings } = schema as Record<string, unknown>;\n if (Object.keys(siblings).length > 0) {\n // An `example` sibling (common when a parameter-level `example` is merged onto a `$ref`\n // schema) never reaches the `isSchema` normalization branch below, so normalize it here.\n convertExamples(siblings);\n return { ...resolved, ...siblings };\n }\n\n return resolved;\n }\n\n refLogger(schema.$ref, 'ref');\n return schema;\n }\n\n // If we don't have a set type, but are dealing with an `anyOf`, `oneOf`, or `allOf`\n // representation let's run through them and make sure they're good.\n if (isSchema(schema, isPolymorphicAllOfChild)) {\n // If this is an `allOf` schema we should make an attempt to merge so as to ease the burden on\n // the tooling that ingests these schemas.\n if ('allOf' in schema && Array.isArray(schema.allOf)) {\n // A `description` alongside `allOf` overrides the desciption resolved\n // by `json-schema-merge-allof` (last-wins).\n //\n // Using allOf + description is a widely adopted workaround for the oas 3.0 limitation\n // that $ref cannot have sibling properties. Swagger, for example, resolves it exactly this way.\n const siblingDescription =\n typeof schema.description === 'string' && schema.description.length > 0 ? schema.description : undefined;\n\n // `json-schema-merge-allof` does not resolve `$ref` pointers so if this schema has sibling\n // `properties` whose internal schemas _also_ contain an `allOf` with multiple `$ref`\n // pointers, merging the parent `allOf` first can drop those pointers. We should instead\n // convert each individual property schema first.\n if (\n 'properties' in schema &&\n schema.properties !== undefined &&\n typeof schema.properties === 'object' &&\n schema.properties !== null &&\n !Array.isArray(schema.properties)\n ) {\n const preprocessed: SchemaObject['properties'] = {};\n for (const prop of Object.keys(schema.properties)) {\n const val = schema.properties[prop];\n if (Array.isArray(val) || (typeof val === 'object' && val !== null)) {\n const converted = toJSONSchema(val as SchemaObject, {\n ...polyOptions,\n currentLocation: `${currentLocation}/${encodePointer(prop)}`,\n prevDefaultSchemas,\n prevExampleSchemas,\n });\n\n // Drop the property entirely when it was non-empty originally but came back empty —\n // i.e. `hideReadOnlyProperties` / `hideWriteOnlyProperties` filtered it away. Carrying\n // an empty placeholder past the `allOf` merge causes the later deletion guard to think\n // the prop was always empty and skip the delete. Also drop a bare `$ref` whose cached\n // resolution is empty (same reason).\n if (hideReadOnlyProperties || hideWriteOnlyProperties) {\n let resolvedRefIsEmpty = false;\n if (isRef(converted) && usedSchemas) {\n const cached = usedSchemas.get(converted.$ref);\n if (cached && !isRef(cached) && !isPendingSchema(cached) && Object.keys(cached).length === 0) {\n resolvedRefIsEmpty = true;\n }\n }\n const originallyNonEmpty = Object.keys(val as SchemaObject).length > 0;\n if (originallyNonEmpty && (!Object.keys(converted).length || resolvedRefIsEmpty)) {\n continue;\n }\n }\n\n preprocessed[prop] = converted;\n } else {\n preprocessed[prop] = val;\n }\n }\n schema = { ...schema, properties: preprocessed } as SchemaObject;\n }\n\n // If we have an API definition present then we should attempt to resolve each `$ref` in an\n // `allOf` before merging them together with `json-schema-merge-allof` so that that has access\n // to the full and actual schemas.\n let allOfSchemas = schema.allOf as SchemaObject[];\n if (definition && usedSchemas) {\n // When merging multiple `allOf` schemas together `$ref` pointers that are present are\n // merged away so we shouldn't log them. When an `allOf` has a single item we're just\n // unwrapping the schema, so `$ref` pointers _do_ appear in the output then we **should**\n // log those.\n const allOfOptions: toJSONSchemaOptions =\n allOfSchemas.length > 1 ? { ...polyOptions, refLogger: () => {} } : polyOptions;\n\n allOfSchemas = allOfSchemas.map(item => {\n if (isRef(item)) {\n // `isRef` is true for any object with a `$ref` key. When other keywords (e.g. `title`,\n // `properties`) sit alongside `$ref` in an `allOf` branch, which can be common after\n // `json-schema-merge-allof` merges a polymorphic schema, resolving only the `$ref`\n // drops those siblings.\n //\n // We should always try to merge the converted target with its converted siblings.\n if (Object.keys(item).length === 1) {\n return resolveAndCacheRefSchema({\n schema: item,\n definition,\n usedSchemas,\n seenRefs,\n conversionOptions: allOfOptions,\n returnMode: 'converted',\n refLogger,\n });\n }\n\n const { $ref, ...siblings } = item as SchemaObject & ReferenceObject;\n const resolved = resolveAndCacheRefSchema({\n schema: { $ref },\n definition,\n usedSchemas,\n seenRefs,\n conversionOptions: allOfOptions,\n returnMode: 'converted',\n refLogger,\n });\n\n // If all we had was a `$ref` schema then we should return whatever it resolved to.\n if (!Object.keys(siblings).length) {\n return resolved;\n }\n\n const siblingSchema = toJSONSchema(siblings as SchemaObject, allOfOptions);\n try {\n return mergeJSONSchemaAllOf(\n { allOf: [resolved as JSONSchema4, siblingSchema as JSONSchema4] },\n mergeAllOfSchemasOptions,\n ) as SchemaObject;\n } catch {\n return resolved;\n }\n }\n\n return toJSONSchema(item as SchemaObject, allOfOptions);\n });\n\n if (addEnumsToDescriptions) {\n // Enum values are added to descriptions during response schema conversion. They are\n // generated display metadata, so they should not participate in `allOf` description\n // precedence and overwrite an authored description alongside the `allOf`. Remove the\n // generated paragraph from each converted branch before merging; the final enum handling\n // below will append it once to the merged schema.\n allOfSchemas = allOfSchemas.map(withoutGeneratedEnumDescription);\n }\n\n // Find paths reached by 2+ branches, then inline each branch with deep recursion at\n // those conflict paths.\n const conflictPaths = collectConflictPaths(allOfSchemas, usedSchemas);\n schema = {\n ...schema,\n allOf: allOfSchemas.map(s => inlinePropertyRefsForMerge(s, usedSchemas, refLogger, conflictPaths)),\n } as SchemaObject;\n }\n\n try {\n schema = mergeJSONSchemaAllOf(schema as JSONSchema, mergeAllOfSchemasOptions) as SchemaObject;\n\n // Reinstate the schema's own sibling `description` so it always wins over any `description`\n // merged in from json-schema-merge-allof.\n if (siblingDescription !== undefined && isObject(schema) && !isRef(schema)) {\n schema.description = siblingDescription;\n }\n } catch {\n // The merge can throw on irreconcilable conflicts (eg. `properties.foo.type` being `array`\n // in one branch and `object` in another). Dropping the entire `allOf` here would leave the\n // schema with no `type` / `properties` at all, and downstream renderers would have nothing\n // to show. Instead, do a best-effort shallow merge of each branch's `properties` (later\n // branches win on conflict) and union `required`, so consumers still see most of the shape.\n const branches = (schema.allOf as SchemaObject[]) ?? [];\n const { allOf: _allOf, ...rest } = schema as SchemaObject & { allOf?: SchemaObject[] };\n const fallback: SchemaObject = { ...rest };\n const mergedProperties: Record<string, SchemaObject> = {\n ...(fallback as { properties?: Record<string, SchemaObject> }).properties,\n };\n const requiredSet = new Set<string>(Array.isArray(fallback.required) ? (fallback.required as string[]) : []);\n for (const branch of branches) {\n if (!branch || typeof branch !== 'object' || isRef(branch)) continue;\n if (fallback.type === undefined && 'type' in branch && branch.type !== undefined) {\n fallback.type = branch.type;\n }\n if (fallback.title === undefined && typeof branch.title === 'string' && branch.title.length > 0) {\n fallback.title = branch.title;\n }\n if (\n fallback.description === undefined &&\n typeof branch.description === 'string' &&\n branch.description.length > 0\n ) {\n fallback.description = branch.description;\n }\n if (branch.properties && typeof branch.properties === 'object') {\n for (const [key, value] of Object.entries(branch.properties)) {\n mergedProperties[key] = value as SchemaObject;\n }\n }\n if (Array.isArray(branch.required)) {\n for (const required of branch.required) requiredSet.add(required);\n }\n }\n if (Object.keys(mergedProperties).length > 0) {\n (fallback as { properties?: unknown }).properties = mergedProperties;\n if (fallback.type === undefined) fallback.type = 'object';\n }\n if (requiredSet.size > 0) {\n (fallback as SchemaObject & { required?: string[] }).required = [...requiredSet];\n }\n schema = fallback;\n }\n\n // This is a little messy but because `json-schema-merge-allof` doesn't support attaching a\n // resolver to a deeply nested `$ref` pointer, which we would need to do in order to emit\n // that a `$ref` is present in this schema, we need to instead scan the resulting schema\n // for them.\n collectRefsInSchema(schema).forEach(ref => {\n refLogger(ref, 'ref');\n });\n\n // If after merging the `allOf` this schema still contains a `$ref` then it's circular and\n // we shouldn't do anything else. Preserve sibling properties alongside the `$ref`.\n if (isRef(schema)) {\n refLogger(schema.$ref, 'ref');\n\n return schema;\n }\n }\n\n (['anyOf', 'oneOf'] as const).forEach((polyType: 'anyOf' | 'oneOf') => {\n if (polyType in schema && Array.isArray(schema[polyType])) {\n const discriminatorPropertyName =\n 'discriminator' in schema && schema.discriminator && isObject(schema.discriminator)\n ? schema.discriminator.propertyName\n : undefined;\n\n schema[polyType].forEach((item, idx) => {\n if (!schema[polyType]?.[idx]) {\n // We should never hit this because `anyOf` and `oneOf` ara guaranteed by this point to\n // be arrays but TS isn't smart enough to carry this inferrence down to this block.\n return;\n }\n\n const itemOptions: toJSONSchemaOptions = {\n ...polyOptions,\n currentLocation: `${currentLocation}/${idx}`,\n };\n\n // When `properties` or `items` are present alongside a polymorphic schema instead of\n // letting whatever JSON Schema interpreter is handling these constructed schemas we can\n // guide its hand a bit by manually transforming it into an inferred `allOf` of the\n // `properties` + the polymorph schema.\n //\n // This `allOf` schema will be merged together when fed through `toJSONSchema`.\n if ('properties' in schema) {\n schema[polyType][idx] = toJSONSchema(\n {\n required: schema.required,\n allOf: [item, { properties: schema.properties }],\n } as SchemaObject,\n itemOptions,\n );\n } else if ('items' in schema) {\n if (shouldFoldParentItemsIntoPolymorphBranch(item)) {\n schema[polyType][idx] = toJSONSchema(\n {\n allOf: [item, { items: schema.items }],\n } as SchemaObject,\n itemOptions,\n );\n } else {\n schema[polyType][idx] = toJSONSchema(item as SchemaObject, itemOptions);\n }\n } else {\n schema[polyType][idx] = toJSONSchema(item as SchemaObject, itemOptions);\n }\n\n // Ensure that we don't have any invalid `required` booleans or empty arrays lying around.\n if ('required' in (schema[polyType][idx] as SchemaObject)) {\n if (Array.isArray(schema[polyType][idx].required) && schema[polyType][idx].required.length === 0) {\n delete (schema[polyType][idx] as SchemaObject).required;\n } else if (\n isObject(schema[polyType][idx]) &&\n typeof (schema[polyType][idx] as SchemaObject).required === 'boolean'\n ) {\n delete (schema[polyType][idx] as SchemaObject).required;\n }\n }\n\n // When a parent schema has a discriminator and child schemas inherit via allOf, the child\n // schemas can inherit the parent's discriminator, oneOf, and anyOf. We remove these\n // from child schemas to avoid nested discriminator UIs where each child incorrectly shows\n // all other children as options. This keeps the discriminator only at the parent level.\n if (discriminatorPropertyName) {\n const childSchema = schema[polyType][idx] as SchemaObject;\n if (isObject(childSchema)) {\n if ('discriminator' in childSchema) {\n delete (childSchema as Record<string, unknown>).discriminator;\n }\n if ('oneOf' in childSchema) {\n delete (childSchema as Record<string, unknown>).oneOf;\n }\n if ('anyOf' in childSchema) {\n delete (childSchema as Record<string, unknown>).anyOf;\n }\n }\n\n // When the child is a `$ref` the actual schema lives in `usedSchemas` so we should\n // strip these polymorphic keywords there too.\n if (definition && usedSchemas && isRef(childSchema)) {\n const resolved = usedSchemas.get(childSchema.$ref);\n if (resolved && typeof resolved === 'object' && !isPendingSchema(resolved)) {\n if ('discriminator' in resolved) {\n delete (resolved as Record<string, unknown>).discriminator;\n }\n if ('oneOf' in resolved) {\n delete (resolved as Record<string, unknown>).oneOf;\n }\n if ('anyOf' in resolved) {\n delete (resolved as Record<string, unknown>).anyOf;\n }\n\n // Instead of relying on the `resolved` reference populating back into `usedSchemas`\n // we should make sure that that schema is refreshed with our new schema.\n usedSchemas.set(childSchema.$ref, resolved);\n }\n }\n }\n });\n }\n });\n\n if (schema?.discriminator?.mapping && typeof schema.discriminator.mapping === 'object') {\n // Discriminator mappings aren't written as traditional `$ref` pointers so in order to log\n // them to the supplied `refLogger`.\n const mapping = schema.discriminator.mapping;\n Object.keys(mapping).forEach(k => {\n refLogger(mapping[k], 'discriminator');\n });\n }\n }\n\n // If this schema is malformed for some reason, let's do our best to repair it.\n if (!('type' in schema) && !isPolymorphicSchema(schema) && !isRequestBodySchema(schema)) {\n if ('properties' in schema) {\n schema.type = 'object';\n } else if ('items' in schema) {\n schema.type = 'array';\n } else {\n // If there's still no `type` on the schema we should leave it alone because we don't have a\n // great way to know if it's part of a nested schema that should, and couldn't be merged,\n // into another, or it's just purely malformed.\n //\n // Whatever tooling that ingests the generated schema should handle it however it needs to.\n }\n }\n\n if ('type' in schema && schema.type !== undefined) {\n // `nullable` isn't a thing in JSON Schema but it was in OpenAPI 3.0 so we should retain and\n // translate it into something that's compatible with JSON Schema.\n if ('nullable' in schema) {\n if (schema.nullable) {\n if (Array.isArray(schema.type)) {\n schema.type.push('null');\n } else if (schema.type !== null && schema.type !== 'null') {\n schema.type = [schema.type, 'null'];\n }\n }\n\n delete schema.nullable;\n }\n\n if (schema.type === null) {\n // `type: null` is possible in JSON Schema but we're translating it to a string version\n // so we don't need to worry about asserting nullish types in our implementations of this\n // generated schema.\n (schema as SchemaObject).type = 'null';\n } else if (Array.isArray(schema.type)) {\n // @ts-expect-error -- `null` is not valid in JSON Schema but it can be done in OpenAPI 3.0.\n if (schema.type.includes(null)) {\n // @ts-expect-error -- `null` is not valid in JSON Schema but it can be done in OpenAPI 3.0.\n schema.type[schema.type.indexOf(null)] = 'null';\n }\n\n schema.type = Array.from(new Set(schema.type));\n\n // We don't need `type: [<type>]` when we can just as easily make it `type: <type>`.\n if (schema.type.length === 1) {\n schema.type = schema.type.shift();\n } else if (schema.type.includes('array') || schema.type.includes('boolean') || schema.type.includes('object')) {\n // If we have a `null` type but there's only two types present then we can remove `null`\n // as an option and flag the whole schema as `nullable`.\n const isNullable = schema.type.includes('null');\n\n if (schema.type.length === 2 && isNullable) {\n // If this is `array | null` or `object | null` then we don't need to do anything.\n } else {\n // If this mixed type has non-primitives then we for convenience of our implementation\n // we're moving them into a `oneOf`.\n const nonPrimitives: any[] = [];\n\n // Because arrays, booleans, and objects are not compatible with any other schem type\n // other than null we're moving them into an isolated `oneOf`, and as such want to take\n // with it its specific properties that may be present on our current schema.\n Object.entries({\n // https://json-schema.org/understanding-json-schema/reference/array.html\n array: [\n 'additionalItems',\n 'contains',\n 'items',\n 'maxContains',\n 'maxItems',\n 'minContains',\n 'minItems',\n 'prefixItems',\n 'uniqueItems',\n ],\n\n // https://json-schema.org/understanding-json-schema/reference/boolean.html\n boolean: [\n // Booleans don't have any boolean-specific properties.\n ],\n\n // https://json-schema.org/understanding-json-schema/reference/object.html\n object: [\n 'additionalProperties',\n 'maxProperties',\n 'minProperties',\n 'nullable',\n 'patternProperties',\n 'properties',\n 'propertyNames',\n 'required',\n ],\n } as Record<string, (keyof SchemaObject)[]>).forEach(([typeKey, keywords]) => {\n if (!schema.type?.includes(typeKey as JSONSchema7TypeName)) {\n return;\n }\n\n const reducedSchema: any = removeUndefinedObjects({\n type: isNullable ? [typeKey, 'null'] : typeKey,\n\n allowEmptyValue: (schema as any).allowEmptyValue ?? undefined,\n deprecated: schema.deprecated ?? undefined,\n description: schema.description ?? undefined,\n readOnly: schema.readOnly ?? undefined,\n title: schema.title ?? undefined,\n writeOnly: schema.writeOnly ?? undefined,\n });\n\n keywords.forEach(keyword => {\n if (keyword in schema) {\n reducedSchema[keyword] = schema[keyword];\n delete schema[keyword];\n }\n });\n\n nonPrimitives.push(reducedSchema);\n });\n\n schema.type = schema.type.filter(t => t !== 'array' && t !== 'boolean' && t !== 'object');\n if (schema.type.length === 1) {\n schema.type = schema.type.shift();\n }\n\n // Because we may have encountered a fully mixed non-primitive type like `array | object`\n // we only want to retain the existing schema object if we still have types remaining\n // in it.\n if (schema.type && schema.type.length > 1) {\n schema = { oneOf: [schema, ...nonPrimitives] };\n } else {\n schema = { oneOf: nonPrimitives };\n }\n }\n }\n }\n }\n\n if (isSchema(schema, isPolymorphicAllOfChild)) {\n if ('default' in schema && isObject(schema.default)) {\n prevDefaultSchemas.push({ default: schema.default });\n }\n\n // JSON Schema doesn't support OpenAPI-style examples so we need to reshape them a bit.\n convertExamples(schema as Record<string, unknown>);\n\n // If we didn't have any immediately defined examples, let's search backwards and see if we can\n // find one. But as we're only looking for primitive example, only try to search for one if\n // we're dealing with a primitive schema.\n if (!hasSchemaType(schema, 'array') && !hasSchemaType(schema, 'object') && !schema.examples) {\n const foundExample = searchForValueByPropAndPointer('example', currentLocation, prevExampleSchemas);\n if (foundExample !== undefined) {\n // We can only really deal with primitives, so only promote those as the found example if\n // it is.\n if (isPrimitive(foundExample) || (Array.isArray(foundExample) && isPrimitive(foundExample[0]))) {\n schema.examples = [foundExample];\n }\n }\n }\n\n if (hasSchemaType(schema, 'array')) {\n if ('items' in schema && schema.items !== undefined) {\n if (\n !(definition && usedSchemas) &&\n !Array.isArray(schema.items) &&\n Object.keys(schema.items).length === 1 &&\n isRef(schema.items)\n ) {\n // When not resolving refs, `items` that is a lone `$ref` is treated as circular; log and leave as-is.\n refLogger(schema.items.$ref, 'ref');\n } else if (schema.items !== true) {\n // Run through the arrays contents and clean them up (including resolving $ref in items when in ref-resolution mode).\n // Do not pass prevDefaultSchemas: the array's default (e.g. [12, 34, 56]) belongs on the array,\n // not on items (we must not set default: 12 on items when the default is already on tags).\n schema.items = toJSONSchema(schema.items as SchemaObject, {\n ...polyOptions,\n currentLocation: `${currentLocation}/0`,\n prevDefaultSchemas: [],\n prevExampleSchemas,\n });\n\n // If we have a non-array, or empty array, `required` entry in our `items` schema then\n // it's invalid and we should remove it. We only support non-array boolean `required`\n // properties inside object properties.\n if ('required' in schema.items) {\n if (Array.isArray(schema.items.required) && schema.items.required.length === 0) {\n delete schema.items.required;\n } else if (isObject(schema.items) && !Array.isArray(schema.items.required)) {\n delete schema.items.required;\n }\n }\n }\n } else if ('properties' in schema || 'additionalProperties' in schema) {\n // This is a fix to handle cases where someone may have typod `items` as `properties` on an\n // array. Since throwing a complete failure isn't ideal, we can see that they meant for the\n // type to be `object`, so we can do our best to shape the data into what they were\n // intending it to be.\n schema.type = 'object';\n } else {\n // This is a fix to handle cases where we have a malformed array with no `items` property\n // present.\n (schema as any).items = {};\n }\n } else if (hasSchemaType(schema, 'object')) {\n if ('properties' in schema && schema.properties !== undefined) {\n Object.keys(schema.properties).forEach(prop => {\n if (\n Array.isArray(schema.properties?.[prop]) ||\n (typeof schema.properties?.[prop] === 'object' && schema.properties?.[prop] !== null)\n ) {\n const newPropSchema = toJSONSchema(schema.properties[prop] as SchemaObject, {\n ...polyOptions,\n currentLocation: `${currentLocation}/${encodePointer(prop)}`,\n // Keep parent defaults visible to this child, but isolate mutations that happen while\n // walking its descendants. Otherwise a default pushed by one sibling can be found by\n // later siblings with the same nested property name.\n prevDefaultSchemas: [...prevDefaultSchemas],\n prevExampleSchemas,\n });\n\n // If this property is read or write only then we should fully hide it from its parent schema.\n let propShouldBeUpdated = true;\n if (hideReadOnlyProperties || hideWriteOnlyProperties) {\n // When the property is a bare `$ref` whose resolved schema was filtered away the recursive call\n // returns the `$ref` pointer rather than `{}`. Look up the cached resolution so we can drop the\n // property here too.\n let resolvedRefIsEmpty = false;\n if (isRef(newPropSchema) && usedSchemas) {\n const cached = usedSchemas.get(newPropSchema.$ref);\n if (cached && !isRef(cached) && !isPendingSchema(cached) && Object.keys(cached).length === 0) {\n resolvedRefIsEmpty = true;\n }\n }\n\n if (!Object.keys(newPropSchema).length || resolvedRefIsEmpty) {\n // We should only delete this schema if it wasn't already empty though. We do this\n // because we (un)fortunately have handling in our API Explorer form system for\n // schemas that are devoid of any `type` declaration.\n if (Object.keys(schema.properties[prop]).length > 0) {\n delete schema.properties[prop];\n propShouldBeUpdated = false;\n }\n }\n }\n\n if (propShouldBeUpdated) {\n schema.properties[prop] = newPropSchema;\n\n /**\n * JSON Schema does not have any support for `required: <boolean>` but because some\n * of our users do this, and it does not throw OpenAPI validation errors thanks to\n * some extremely loose typings around `schema` in the official JSON Schema\n * definitions that the OAI offers, we're opting to support these users and upgrade\n * their invalid `required` definitions into ones that our tooling can interpret.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/schema.json#L1114-L1121}\n */\n if (\n isObject(newPropSchema) &&\n 'required' in newPropSchema &&\n typeof newPropSchema.required === 'boolean' &&\n newPropSchema.required === true\n ) {\n if ('required' in schema && Array.isArray(schema.required)) {\n schema.required.push(prop);\n } else {\n schema.required = [prop];\n }\n\n delete (schema.properties[prop] as SchemaObject).required;\n }\n }\n }\n });\n\n // If we want to hide all readOnly or writeOnly properites and it happens to be that this\n // object was comprised of only those then we shouldn't render this object.\n if (hideReadOnlyProperties || hideWriteOnlyProperties) {\n if (!Object.keys(schema.properties).length) {\n return {};\n }\n }\n }\n\n if (typeof schemaAdditionalProperties === 'object' && schemaAdditionalProperties !== null) {\n // If this `additionalProperties` is completely empty and devoid of any sort of schema,\n // treat it as such. Otherwise let's recurse into it and see if we can sort it out.\n if (\n !('type' in schemaAdditionalProperties) &&\n !('$ref' in schemaAdditionalProperties) &&\n // We know it will be a schema object because it's dereferenced\n !isPolymorphicSchema(schemaAdditionalProperties as SchemaObject)\n ) {\n schema.additionalProperties = true;\n } else {\n // We know it will be a schema object because it's dereferenced\n schema.additionalProperties = toJSONSchema(schemaAdditionalProperties as SchemaObject, {\n ...polyOptions,\n currentLocation,\n prevDefaultSchemas,\n prevExampleSchemas,\n });\n }\n }\n\n // Since neither `properties` and `additionalProperties` are actually required to be present\n // on an object, since we construct this schema work to build up a form we still need\n // *something* for the user to enter in for this object so we'll add back in\n // `additionalProperties` for that.\n if (!isPolymorphicSchema(schema) && !('properties' in schema) && !('additionalProperties' in schema)) {\n schema.additionalProperties = true;\n }\n }\n }\n\n /**\n * Users can pass in parameter defaults via JWT User Data. We're checking to see if the defaults\n * being passed in exist on endpoints via jsonpointer\n *\n * @see {@link https://docs.readme.com/docs/passing-data-to-jwt}\n */\n if (\n isSchema(schema, isPolymorphicAllOfChild) &&\n globalDefaults &&\n Object.keys(globalDefaults).length > 0 &&\n currentLocation\n ) {\n try {\n const userJwtDefault = jsonpointer.get(globalDefaults, currentLocation);\n if (userJwtDefault) {\n schema.default = userJwtDefault;\n }\n } catch {\n // If jsonpointer returns an error, we won't show any defaults for that path.\n }\n }\n\n // Only add a default value if we actually have one.\n if ('default' in schema && typeof schema.default !== 'undefined') {\n if (hasSchemaType(schema, 'object')) {\n // Defaults for `object` and types have been dereferenced into their children schemas already\n // above so we don't need to preserve this default anymore.\n delete schema.default;\n } else if (\n ('allowEmptyValue' in schema && schema.allowEmptyValue && schema.default === '') ||\n schema.default !== ''\n ) {\n // If we have `allowEmptyValue` present, and the default is actually an empty string, let it\n // through as it's allowed.\n } else {\n // If the default is empty and we don't want to allowEmptyValue, we need to remove the\n // default.\n delete schema.default;\n }\n } else if (prevDefaultSchemas.length) {\n const foundDefault = searchForValueByPropAndPointer('default', currentLocation, prevDefaultSchemas);\n\n // We shouldn't ever set an object default out of the parent lineage tree defaults because\n // the contents of that object will be set on the schema that they're a part of. Setting\n // that object as well would result us in duplicating the defaults for that schema in two\n // places.\n if (\n isPrimitive(foundDefault) ||\n foundDefault === null ||\n (Array.isArray(foundDefault) && hasSchemaType(schema, 'array'))\n ) {\n (schema as SchemaObject).default = foundDefault;\n }\n }\n\n if (isSchema(schema, isPolymorphicAllOfChild) && 'enum' in schema && Array.isArray(schema.enum)) {\n // Enums should not have duplicated items as those will break AJV validation.\n // If we ever target ES6 for typescript we can drop this array.from.\n // https://stackoverflow.com/questions/33464504/using-spread-syntax-and-new-set-with-typescript/56870548\n schema.enum = Array.from(new Set(schema.enum));\n\n // If we want to add enums to descriptions (like in the case of response JSON Schema)\n // generation we need to convert them into a list of Markdown tilda'd strings. We're also\n // filtering away empty and falsy strings here because adding empty `` blocks to the description\n // will serve nobody any good.\n if (addEnumsToDescriptions) {\n const enums = formatEnumDescription(schema.enum);\n\n if (enums.length) {\n const currentDescription =\n 'description' in schema && typeof schema.description === 'string' ? schema.description : '';\n\n if (!currentDescription) {\n schema.description = enums;\n } else {\n const paragraphs = currentDescription.split(/\\n\\n+/).map(p => p.trim());\n const enumParagraphCount = paragraphs.filter(p => p === enums).length;\n\n // After `allOf` merging nested properties are run through `toJSONSchema` again however\n // enum description additions may already be present from the first pass, we should avoid\n // duplicating thoes addendums.\n if (enumParagraphCount > 1) {\n const withoutEnum = paragraphs.filter(p => p !== enums);\n schema.description = withoutEnum.length > 0 ? `${withoutEnum.join('\\n\\n')}\\n\\n${enums}` : enums;\n } else if (paragraphs.some(p => p === enums)) {\n // noop\n } else {\n schema.description = `${currentDescription}\\n\\n${enums}`;\n }\n }\n }\n }\n }\n\n // Clean up any remaining `items` or `properties` schema fragments lying around if there's also\n // polymorphism present.\n if ('anyOf' in schema || 'oneOf' in schema) {\n // If this polymorphic schema is comprised of schemas that were unable to be merged and are now\n // empty objects then we should wipe them out because they're fully invalid.\n for (const key of ['anyOf', 'oneOf'] as const) {\n if (key in schema && isEmptyPolymorphicSchema(schema[key])) {\n delete schema[key];\n }\n }\n\n if ('anyOf' in schema || 'oneOf' in schema) {\n if ('properties' in schema) {\n delete schema.properties;\n }\n\n if ('items' in schema) {\n delete schema.items;\n if ('type' in schema && schema.type === 'array') {\n delete schema.type;\n }\n }\n }\n }\n\n // Remove unsupported JSON Schema props.\n for (let i = 0; i < UNSUPPORTED_SCHEMA_PROPS.length; i += 1) {\n // Using the as here because the purpose is to delete keys we don't expect, so of course the\n // typing won't work\n delete (schema as Record<string, unknown>)[UNSUPPORTED_SCHEMA_PROPS[i]];\n }\n\n // If we want to hide any `readOnly` or `writeOnly` schemas, and this one is that, then we\n // shouldn't return anything.\n if (hideReadOnlyProperties && 'readOnly' in schema && schema.readOnly === true) {\n return {};\n } else if (hideWriteOnlyProperties && 'writeOnly' in schema && schema.writeOnly === true) {\n return {};\n }\n\n return schema;\n}\n","import type { toJSONSchemaOptions } from '../../lib/openapi-to-json-schema.js';\nimport type { ExampleObject, OASDocument, ParameterObject, SchemaObject, SchemaWrapper } from '../../types.js';\nimport type { Operation } from '../index.js';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport { getExtension, PARAMETER_ORDERING } from '../../extensions.js';\nimport { applyDiscriminatorOneOfToUsedSchemas } from '../../lib/build-discriminator-one-of.js';\nimport { cloneObject } from '../../lib/clone-object.js';\nimport { getParameterContentType } from '../../lib/get-parameter-content-type.js';\nimport { isPrimitive } from '../../lib/helpers.js';\nimport { getSchemaVersionString, toJSONSchema } from '../../lib/openapi-to-json-schema.js';\nimport {\n collectRefsInSchema,\n dereferenceRef,\n filterRequiredRefsToReferenced,\n mergeReferencedSchemasIntoRoot,\n} from '../../lib/refs.js';\nimport { isRef } from '../../types.js';\n\n// `Accept` and `Content-Type` are always reserved: ReadMe computes them from the operation's\n// response media types and request body, so rendering them as editable header params is redundant\n// and can interfere with request body serialization.\nconst RESERVED_HEADER_PARAMETERS = new Set(['accept', 'content-type']);\n\n/**\n * `Authorization` is also reserved by the OpenAPI spec, but unlike `Accept`/`Content-Type` nothing\n * auto-computes it — it's only ever supplied when the operation has a security scheme. So we only\n * treat a custom `Authorization` header param as reserved when the operation actually has security\n * requirements; otherwise stripping it would remove the only affordance to authenticate the\n * request, silently breaking docs that model auth this way (CX-3611).\n */\nfunction isReservedHeaderParameter(param: ParameterObject, hasSecurity: boolean) {\n if (param.in !== 'header') return false;\n\n const name = param.name.toLowerCase();\n if (RESERVED_HEADER_PARAMETERS.has(name)) return true;\n\n return hasSecurity && name === 'authorization';\n}\n\n/**\n * The order of this object determines how they will be sorted in the compiled JSON Schema\n * representation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameter-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object}\n */\nexport const types: Record<keyof OASDocument, string> = {\n path: 'Path Params',\n query: 'Query Params',\n body: 'Body Params',\n cookie: 'Cookie Params',\n formData: 'Form Data',\n header: 'Headers',\n metadata: 'Metadata', // This a special type reserved for https://npm.im/api\n};\n\nexport interface getParametersAsJSONSchemaOptions {\n /**\n * If provided, the request body schema will be derived from this specific content type\n * rather than the default preferred one (first JSON-like, then first available).\n */\n contentType?: string;\n\n /**\n * Contains an object of user defined schema defaults.\n */\n globalDefaults?: Record<string, unknown>;\n\n /**\n * If you wish to hide properties that are marked as being `readOnly`.\n */\n hideReadOnlyProperties?: boolean;\n\n /**\n * If you wish to hide properties that are marked as being `writeOnly`.\n */\n hideWriteOnlyProperties?: boolean;\n\n /**\n * If you wish to include discriminator mapping `$ref` components alongside your\n * `discriminator` in schemas. Defaults to `true`.\n */\n includeDiscriminatorMappingRefs?: boolean;\n\n /**\n * If you want the output to be two objects: body (contains `body` and `formData` JSON\n * Schema) and metadata (contains `path`, `query`, `cookie`, and `header`).\n */\n mergeIntoBodyAndMetadata?: boolean;\n}\n\nexport function getParametersAsJSONSchema(\n operation: Operation,\n api: OASDocument,\n opts?: getParametersAsJSONSchemaOptions,\n): SchemaWrapper[] | null {\n const seenRefs = new Set<string>();\n const refsByGroup = new Map<string, Set<string>>();\n const usedSchemasByGroup = new Map<string, Map<string, SchemaObject>>();\n\n function refLoggerForSchemaGroup(group: string) {\n let set = refsByGroup.get(group);\n if (!set) {\n set = new Set();\n refsByGroup.set(group, set);\n }\n\n return set;\n }\n\n function usedSchemasForSchemaGroup(group: string) {\n let map = usedSchemasByGroup.get(group);\n if (!map) {\n map = new Map<string, SchemaObject>();\n usedSchemasByGroup.set(group, map);\n }\n\n return map;\n }\n\n const baseSchemaOptions: toJSONSchemaOptions = {\n definition: api,\n globalDefaults: opts?.globalDefaults,\n hideReadOnlyProperties: opts?.hideReadOnlyProperties,\n hideWriteOnlyProperties: opts?.hideWriteOnlyProperties,\n seenRefs,\n };\n\n function transformRequestBody(): SchemaWrapper | null {\n const requestBody = operation.getRequestBody(opts?.contentType);\n\n if (!requestBody) return null;\n\n const { mediaType, mediaTypeObject, description } = requestBody;\n const type = mediaType === 'application/x-www-form-urlencoded' ? 'formData' : 'body';\n\n // If this schema is completely empty, don't bother processing it.\n if (!mediaTypeObject.schema || !Object.keys(mediaTypeObject.schema).length) {\n return null;\n }\n\n const prevExampleSchemas: toJSONSchemaOptions['prevExampleSchemas'] = [];\n if ('example' in mediaTypeObject) {\n prevExampleSchemas.push({ example: mediaTypeObject.example });\n } else if ('examples' in mediaTypeObject) {\n prevExampleSchemas.push({\n examples: Object.values(mediaTypeObject.examples || {})\n .map(ex => {\n let example = ex;\n if (!example) return;\n if (isRef(example)) {\n example = dereferenceRef(example, operation.api);\n if (!example || isRef(example)) return;\n }\n\n return example.value;\n })\n .filter((item): item is ExampleObject => item !== undefined),\n });\n }\n\n // We're cloning the request schema because we've had issues with request schemas that were\n // dereferenced being processed multiple times because their component is also processed.\n const requestSchema = cloneObject(mediaTypeObject.schema);\n\n const cleanedSchema = toJSONSchema(requestSchema, {\n ...baseSchemaOptions,\n usedSchemas: usedSchemasForSchemaGroup(type),\n prevExampleSchemas,\n refLogger: ref => refLoggerForSchemaGroup(type).add(ref),\n });\n\n // If this schema is **still** empty, don't bother returning it.\n if (!Object.keys(cleanedSchema).length) {\n return null;\n }\n\n return {\n type,\n label: types[type],\n schema: isPrimitive(cleanedSchema)\n ? cleanedSchema\n : {\n ...cleanedSchema,\n $schema: getSchemaVersionString(cleanedSchema, api),\n },\n ...(description ? { description } : {}),\n };\n }\n\n function transformParameters(): SchemaWrapper[] {\n const operationParams = operation.getParameters();\n const hasSecurity = operation.getSecurity().length > 0;\n\n const transformed = Object.keys(types)\n .map(type => {\n const required: string[] = [];\n\n const parameters = operationParams.filter(param => {\n return param.in === type && !isReservedHeaderParameter(param, hasSecurity);\n });\n if (parameters.length === 0) {\n return null;\n }\n\n const properties = parameters.reduce((prev: Record<string, SchemaObject>, current: ParameterObject) => {\n let schema: SchemaObject = {};\n if ('schema' in current) {\n const currentSchema: SchemaObject = current.schema ? cloneObject(current.schema) : {};\n\n if (current.example) {\n // `example` can be present outside of the `schema` block so if it's there we should\n // pull it in so it can be handled and returned if it's valid.\n currentSchema.example = current.example;\n } else if (current.examples) {\n // `examples` isn't actually supported here in OAS 3.0, but we might as well support\n // it because `examples` is JSON Schema and that's fully supported in OAS 3.1.\n currentSchema.examples = current.examples as unknown as unknown[];\n }\n\n if (current.deprecated) currentSchema.deprecated = current.deprecated;\n\n const interimSchema = toJSONSchema(currentSchema, {\n ...baseSchemaOptions,\n usedSchemas: usedSchemasForSchemaGroup(type),\n currentLocation: `/${current.name}`,\n refLogger: ref => refLoggerForSchemaGroup(type).add(ref),\n });\n\n schema = isPrimitive(interimSchema) ? interimSchema : { ...interimSchema };\n } else if ('content' in current && typeof current.content === 'object') {\n const contentKeys = Object.keys(current.content);\n if (contentKeys.length) {\n const contentType = getParameterContentType(contentKeys);\n if (\n contentType &&\n typeof current.content[contentType] === 'object' &&\n 'schema' in current.content[contentType]\n ) {\n const currentSchema: SchemaObject = current.content[contentType].schema\n ? cloneObject(current.content[contentType].schema)\n : {};\n\n if (current.example) {\n // `example` can be present outside of the `schema` block so if it's there we\n // should pull it in so it can be handled and returned if it's valid.\n currentSchema.example = current.example;\n } else if (current.examples) {\n // `examples` isn't actually supported here in OAS 3.0, but we might as well\n // support it because `examples` is JSON Schema and that's fully supported in OAS\n // 3.1.\n currentSchema.examples = current.examples as unknown as unknown[];\n }\n\n if (current.deprecated) currentSchema.deprecated = current.deprecated;\n\n const interimSchema = toJSONSchema(currentSchema, {\n ...baseSchemaOptions,\n usedSchemas: usedSchemasForSchemaGroup(type),\n currentLocation: `/${current.name}`,\n refLogger: ref => refLoggerForSchemaGroup(type).add(ref),\n });\n\n schema = isPrimitive(interimSchema) ? interimSchema : { ...interimSchema };\n }\n }\n }\n\n // Parameter descriptions don't exist in `current.schema` so `constructSchema` will never\n // have access to it.\n if (current.description) {\n if (!isPrimitive(schema)) {\n schema.description = current.description;\n }\n }\n\n prev[current.name] = schema;\n\n if (current.required) {\n required.push(current.name);\n }\n\n return prev;\n }, {});\n\n const schema: OpenAPIV3_1.SchemaObject = {\n $schema: getSchemaVersionString({}, api),\n type: 'object',\n properties: properties as Record<string, OpenAPIV3_1.SchemaObject>,\n ...(required.length > 0 ? { required } : {}),\n };\n\n return {\n type,\n label: types[type],\n schema,\n };\n })\n .filter(item => item !== null);\n\n if (!opts?.mergeIntoBodyAndMetadata) {\n return transformed;\n } else if (!transformed.length) {\n return [];\n }\n\n // If we want to merge parameters into a single metadata entry then we need to pull all\n // available schemas under one roof.\n return [\n {\n type: 'metadata',\n label: types.metadata,\n schema: {\n allOf: transformed.map(r => r.schema),\n },\n },\n ];\n }\n\n // If this operation neither has any parameters or a request body then we should return `null`\n // because there won't be any JSON Schema.\n if (!operation.hasParameters() && !operation.hasRequestBody()) {\n return null;\n }\n\n // `metadata` is `api` SDK specific, is not a part of the `PARAMETER_ORDERING` extension, and\n // should always be sorted last. We also define `formData` as `form` in the extension because\n // we don't want folks to have to deal with casing issues so we need to rewrite it to `formData`.\n const typeKeys = (getExtension(PARAMETER_ORDERING, api, operation) as string[]).map(k => k.toLowerCase());\n typeKeys[typeKeys.indexOf('form')] = 'formData';\n typeKeys.push('metadata');\n\n const jsonSchema = [transformRequestBody()]\n .concat(...transformParameters())\n .filter((item): item is SchemaWrapper => item !== null);\n\n // For each group include only schemas that are referenced or otherwise used within that groups'\n // schema. This allows us to avoid having to include schemas or components that are not used,\n // which would otherwise add to the overall bloat and memory footprint of the generated JSON\n // Schema object.\n return jsonSchema\n .map(group => {\n if (group.schema && typeof group.schema === 'object') {\n const usedSchemas = usedSchemasByGroup.get(group.type) ?? new Map<string, SchemaObject>();\n\n // Apply discriminator `oneOf` arrays to used schemas.\n applyDiscriminatorOneOfToUsedSchemas(api, usedSchemas, (ref: string) => {\n if (usedSchemas.has(ref)) {\n return usedSchemas.get(ref);\n }\n\n try {\n const resolved = dereferenceRef({ $ref: ref }, api, seenRefs);\n if (isRef(resolved)) return;\n const converted = toJSONSchema(structuredClone(resolved) as SchemaObject, {\n ...baseSchemaOptions,\n usedSchemas,\n seenRefs,\n });\n\n usedSchemas.set(ref, converted);\n return converted;\n } catch {\n // no-op\n }\n });\n\n // Because the `refLogger` does not see every `$ref` that is present in the generated\n // schema (eg. nested refs inside an `anyOf` branch that was inlined from cache) we need to\n // collect everything else.\n const refsInOutput = collectRefsInSchema(group.schema);\n const refsInGroup = refsByGroup.get(group.type) ?? new Set();\n const referencedSchemas = filterRequiredRefsToReferenced(\n new Set([...refsInGroup, ...refsInOutput]),\n usedSchemas,\n );\n\n if (referencedSchemas.size > 0) {\n mergeReferencedSchemasIntoRoot(group.schema, referencedSchemas);\n }\n }\n\n return group;\n })\n .toSorted((a, b) => {\n return typeKeys.indexOf(a.type) - typeKeys.indexOf(b.type);\n });\n}\n","import { getParameterContentType } from './lib/get-parameter-content-type.js';\nimport matchesMimeType from './lib/matches-mimetype.js';\nimport { dereferenceRef, dereferenceRefDeep } from './lib/refs.js';\nimport { types as jsonSchemaTypes } from './operation/transformers/get-parameters-as-json-schema.js';\n\nexport const supportedMethods = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] as const;\n\nexport const SERVER_VARIABLE_REGEX: RegExp = /{([-_a-zA-Z0-9:.[\\]]+)}/g;\n\nexport { getParameterContentType, jsonSchemaTypes, matchesMimeType, dereferenceRef, dereferenceRefDeep };\n"]}
@@ -3,12 +3,13 @@ import {
3
3
  } from "./chunk-QTPMJRIE.js";
4
4
  import {
5
5
  Operation
6
- } from "./chunk-7LQKUYC7.js";
6
+ } from "./chunk-5745XRSJ.js";
7
7
  import {
8
8
  decodePointer,
9
9
  encodePointer,
10
+ findDiscriminatorChildren,
10
11
  supportedMethods
11
- } from "./chunk-A7BAE2SN.js";
12
+ } from "./chunk-3X7ZLPYE.js";
12
13
  import {
13
14
  isOpenAPI31,
14
15
  isRef
@@ -102,6 +103,8 @@ var OpenAPITransformer = class {
102
103
  * retaining them would result in an invalid OpenAPI definition.
103
104
  */
104
105
  $refs = /* @__PURE__ */ new Set();
106
+ /** Inheritance dependencies discovered by the same helper used for JSON Schema generation. */
107
+ discriminatorChildrenByParentRef = /* @__PURE__ */ new Map();
105
108
  /**
106
109
  * A collection of OpenAPI tags that are used within the transformed API definition.
107
110
  */
@@ -153,6 +156,16 @@ var OpenAPITransformer = class {
153
156
  constructor(definition, options) {
154
157
  this.definition = structuredClone(definition);
155
158
  this.mode = options.mode;
159
+ const { children, refs } = findDiscriminatorChildren(this.definition);
160
+ children.forEach((childNames, parentName) => {
161
+ const parentRef = refs.get(parentName);
162
+ if (parentRef) {
163
+ this.discriminatorChildrenByParentRef.set(
164
+ parentRef,
165
+ childNames.flatMap((name) => refs.get(name) ?? [])
166
+ );
167
+ }
168
+ });
156
169
  }
157
170
  /**
158
171
  * Select an OpenAPI tag. Operations with this tag are retained when reducing and removed when
@@ -298,7 +311,9 @@ var OpenAPITransformer = class {
298
311
  if ($refSchema === void 0) {
299
312
  return;
300
313
  }
301
- this.queryForRefPointers($refSchema).forEach(({ value: currRef }) => {
314
+ const referencedValues = this.queryForRefPointers($refSchema).map(({ value }) => value);
315
+ referencedValues.push(...this.discriminatorChildrenByParentRef.get($ref) ?? []);
316
+ referencedValues.forEach((currRef) => {
302
317
  const foundRef = this.toRefString(currRef);
303
318
  if (!foundRef) {
304
319
  return;
@@ -822,4 +837,4 @@ var OpenAPITransformer = class {
822
837
  export {
823
838
  OpenAPITransformer
824
839
  };
825
- //# sourceMappingURL=chunk-IV2FDFXA.js.map
840
+ //# sourceMappingURL=chunk-PZR3GKKO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/transformer/index.ts","../src/lib/transformer/operation-selection.ts"],"sourcesContent":["import type {\n ComponentsObject,\n HttpMethods,\n OASDocument,\n OperationObject,\n PathItemObject,\n TagObject,\n} from '../../types.js';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport jsonPointer from 'jsonpointer';\n\nimport { query } from '../../analyzer/util.js';\nimport { Operation } from '../../operation/index.js';\nimport { isOpenAPI31, isRef } from '../../types.js';\nimport { supportedMethods } from '../../utils.js';\nimport { findDiscriminatorChildren } from '../build-discriminator-one-of.js';\nimport { decodePointer, encodePointer } from '../refs.js';\n\nimport { OperationSelection } from './operation-selection.js';\n\ninterface OpenAPITransformerOptions {\n /** Whether selected paths, operations, and webhooks should be retained or removed. */\n mode: 'prune' | 'reduce';\n}\n\n/**\n * Internal engine for selecting operations and transforming an OpenAPI definition down to its\n * reachable paths, webhooks, components, and tags.\n */\nexport class OpenAPITransformer {\n private definition: OASDocument;\n\n private readonly mode: 'prune' | 'reduce';\n\n /**\n * A collection of `$ref` pointers that are used within our transformed API definition. This is\n * used to ensure that all referenced schemas are retained in our resulting API definition. Not\n * retaining them would result in an invalid OpenAPI definition.\n */\n private $refs: Set<string> = new Set();\n\n /** Inheritance dependencies discovered by the same helper used for JSON Schema generation. */\n private discriminatorChildrenByParentRef = new Map<string, string[]>();\n\n /**\n * A collection of OpenAPI tags that are used within the transformed API definition.\n */\n private usedTags: Set<string> = new Set();\n\n /**\n * A collection of OpenAPI paths and operations that are cross-referenced from any other paths\n * and operations that we're retaining. This collection is used to ensure that those operations\n * are retained in our resulting API definition. Not retaining them would result in an invalid\n * OpenAPI definition.\n *\n * A `*` method means the entire Path Item is referenced (e.g. `$ref: '#/paths/~1pets'`).\n */\n private retainPathMethods: Set<`${string}|${string}`> = new Set();\n\n /**\n * Paths whose Path Item *fields* (parameters, servers, summary, …) are referenced without\n * targeting a specific operation. The path container must remain even if every HTTP operation is\n * filtered out.\n */\n private retainPathContainers: Set<string> = new Set();\n\n /**\n * A collection of OpenAPI webhook names and methods that are cross-referenced from any other\n * schemas. This collection, like `retainPathMethods`, is used to ensure that those operations are\n * retained in our resulting API definition. Not retaining them would result in an invalid\n * OpenAPI definition.\n *\n * A `*` method means the entire webhook Path Item is referenced (e.g. `$ref: '#/webhooks/newPet'`).\n */\n private retainWebhookMethods: Set<`${string}|${string}`> = new Set();\n\n /**\n * Webhooks whose Path Item fields are referenced without targeting a specific operation.\n */\n private retainWebhookContainers: Set<string> = new Set();\n\n /** An array of OpenAPI tags selected for the current transformation. */\n private tagSelection: string[] = [];\n\n /** A collection of operation IDs selected for the current transformation. */\n private operationIdSelection = new Set<string>();\n\n /** A collection of OpenAPI paths and operations selected for the current transformation. */\n private pathSelection = new OperationSelection();\n\n /** A collection of OpenAPI webhooks selected for the current transformation. */\n private webhookSelection = new OperationSelection();\n\n private hasTagSelection: boolean = false;\n private hasOperationIdSelection: boolean = false;\n private hasPathSelection: boolean = false;\n private hasWebhookSelection: boolean = false;\n\n /**\n * @param definition OpenAPI definition to transform.\n * @param options Transformation mode.\n */\n protected constructor(definition: OASDocument, options: OpenAPITransformerOptions) {\n this.definition = structuredClone(definition);\n this.mode = options.mode;\n\n const { children, refs } = findDiscriminatorChildren(this.definition);\n children.forEach((childNames, parentName) => {\n const parentRef = refs.get(parentName);\n if (parentRef) {\n this.discriminatorChildrenByParentRef.set(\n parentRef,\n childNames.flatMap(name => refs.get(name) ?? []),\n );\n }\n });\n }\n\n /**\n * Select an OpenAPI tag. Operations with this tag are retained when reducing and removed when\n * pruning. Tag casing does not matter.\n *\n * @param tag Tag to select.\n */\n protected selectTag(tag: string): void {\n this.tagSelection.push(tag.toLowerCase());\n }\n\n /**\n * Select an entire OpenAPI path and all operations that it contains. Selected paths are retained\n * when reducing and removed when pruning. Path casing does not matter.\n *\n * @param path Path to select.\n */\n protected selectPath(path: string): void {\n this.pathSelection.addAll(path);\n }\n\n /**\n * Select a single OpenAPI operation. Selected operations are retained when reducing and removed\n * when pruning. Path and method casing does not matter.\n *\n * In reduce mode, selecting an operation after its entire path replaces the all-operation\n * selection with that operation and any operations selected afterward. Prune mode keeps the\n * entire path selected.\n *\n * @param path Path containing the operation.\n * @param method HTTP method of the operation to select.\n */\n protected selectOperation(path: string, method: string): void {\n if (this.mode === 'reduce' && this.pathSelection.matchesAll(path)) {\n this.pathSelection.clear(path);\n }\n\n this.pathSelection.addOperation(path, method);\n }\n\n /**\n * Select an OpenAPI operation by its operation ID. IDs are matched exactly and are generated\n * from the operation path and method when one is not authored in the definition.\n *\n * @param operationId Operation ID to select.\n */\n protected selectOperationId(operationId: string): void {\n this.operationIdSelection.add(operationId);\n }\n\n /**\n * Select an OpenAPI webhook or one of its operations. Selected webhooks are retained when\n * reducing and removed when pruning. Webhook and method casing does not matter.\n *\n * @param webhookName Webhook to select.\n * @param method Optional HTTP method of an individual webhook operation to select.\n */\n protected selectWebhook(webhookName: string, method?: string): void {\n if (!method) {\n this.webhookSelection.addAll(webhookName);\n return;\n }\n\n if (this.mode === 'reduce' && this.webhookSelection.matchesAll(webhookName)) {\n this.webhookSelection.clear(webhookName);\n }\n\n this.webhookSelection.addOperation(webhookName, method);\n }\n\n /** Transform the OpenAPI definition according to the configured mode and selections. */\n protected transform(): OASDocument {\n if (!this.definition.openapi) {\n throw new Error('Sorry, only OpenAPI definitions are supported.');\n }\n\n this.hasTagSelection = Boolean(this.tagSelection.length);\n this.hasOperationIdSelection = this.operationIdSelection.size > 0;\n this.hasPathSelection = this.pathSelection.hasSelections;\n this.hasWebhookSelection = this.webhookSelection.hasSelections;\n\n // Retain any root-level security definitions, regardless if they're used or not on operations\n // that we're retaining.\n if ('security' in this.definition) {\n Object.values(this.definition.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n }\n\n this.walkPaths();\n this.walkWebhooks();\n\n // Recursively accumulate any components that are in use.\n this.$refs.forEach($ref => {\n this.accumulateUsedRefs(this.definition, this.$refs, $ref);\n });\n\n this.$refs.forEach(ref => {\n this.recordPathRef(ref);\n this.recordWebhookRef(ref);\n });\n\n /**\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n * Targets of those `$ref`s are already retained (see `retainReferencedPathItem`).\n */\n this.transformPaths();\n this.transformWebhooks();\n\n // Require at least one path or one webhook in the result.\n const hasPaths = Boolean(this.definition.paths && Object.keys(this.definition.paths).length);\n const hasWebhooks = Boolean(\n 'webhooks' in this.definition && this.definition.webhooks && Object.keys(this.definition.webhooks).length,\n );\n\n // If we don't have any paths or webhooks left, retain the reducer's no-match error to help catch\n // invalid selections. An empty definition is valid OpenAPI so we allow it when pruning.\n if (this.mode === 'reduce' && !hasPaths && !hasWebhooks) {\n throw new Error(\n 'All paths and webhooks in the API definition were removed. Did you supply the right path, operation, or webhook to reduce by?',\n );\n }\n\n // Remove any unused components.\n if ('components' in this.definition) {\n Object.keys(this.definition.components || {}).forEach(componentType => {\n Object.keys(this.definition.components?.[componentType as keyof ComponentsObject] || {}).forEach(component => {\n // Authored `$ref`s JSON-Pointer-encode `/` and `~` in the component name\n // (`foo/bar` → `foo~1bar`). Compare against that encoded form or cleanup\n // deletes a still-referenced target.\n const componentPointer = `#/components/${componentType}/${encodePointer(component)}`;\n const refIsUsed =\n this.$refs.has(componentPointer) ||\n Array.from(this.$refs).some(ref => {\n // Because you can have a `$ref` like `#/components/examples/event-min/value`, which\n // would be accumulated via our `$refs` query, we want to make sure we account for them.\n // If we don't look for these then we'll end up removing them from the transformed\n // definition, resulting in data loss and schema corruption.\n return ref.startsWith(`${componentPointer}/`);\n });\n\n if (!refIsUsed) {\n delete this.definition.components?.[componentType as keyof ComponentsObject]?.[component];\n }\n });\n\n // If this component group is now empty, delete it.\n if (!Object.keys(this.definition.components?.[componentType as keyof ComponentsObject] || {}).length) {\n delete this.definition.components?.[componentType as keyof ComponentsObject];\n }\n });\n\n // If this path no longer has any components, delete it.\n if (!Object.keys(this.definition.components || {}).length) {\n delete this.definition.components;\n }\n }\n\n // Remove any unused tags.\n if ('tags' in this.definition) {\n this.definition.tags = (this.definition.tags ?? []).filter((tag): tag is TagObject => {\n return Boolean(tag) && this.usedTags.has(tag.name);\n });\n\n if (!this.definition.tags?.length) {\n delete this.definition.tags;\n }\n }\n\n return this.definition;\n }\n\n /**\n * Recursively process a `$ref` pointer and accumulate any other `$ref` pointers that it or its\n * children use. This handles circular references by skipping `$ref` pointers we have already seen.\n * Additionally when a `$ref` points to `#/paths` we record the used path + method so we can\n * retain cross-operation references within the transformed definition.\n *\n * @param schema JSON Schema object to look for and accumulate any `$ref` pointers that it may have.\n * @param $refs Known set of `$ref` pointers.\n * @param $ref `$ref` pointer to fetch a schema from out of the supplied schema.\n */\n private accumulateUsedRefs(schema: Record<string, unknown>, $refs: Set<string>, $ref: string): void {\n // Record `$ref` pointers aimed at `#/paths` or `#/webhooks` so we can retain any\n // cross-operation or Path Item references.\n this.recordPathRef($ref);\n this.recordWebhookRef($ref);\n\n let $refSchema: unknown;\n if (typeof $ref === 'string') $refSchema = jsonPointer.get(schema, $ref.substring(1));\n if ($refSchema === undefined) {\n // If the schema we have wasn't fully dereferenced or bundled for whatever reason and this\n // `$ref` that we have doesn't exist here we shouldn't try to search for more `$ref` pointers\n // in a schema that doesn't exist.\n return;\n }\n\n const referencedValues = this.queryForRefPointers($refSchema).map(({ value }) => value);\n // allOf children point back to their parent, so ordinary forward $ref traversal misses them.\n referencedValues.push(...(this.discriminatorChildrenByParentRef.get($ref) ?? []));\n\n referencedValues.forEach(currRef => {\n // Because it's possible to have a schema property named `$ref` that is not a `$ref` pointer,\n // which our JSONPath query would pick up as a false positive, we want to exclude that from\n // `$ref` matching as it's not a reference pointer.\n const foundRef = this.toRefString(currRef);\n if (!foundRef) {\n return;\n }\n\n // If we've already processed this `$ref` then don't send us into an infinite loop of processing\n // circular references.\n if ($refs.has(foundRef)) {\n return;\n }\n\n $refs.add(foundRef);\n this.accumulateUsedRefs(schema, $refs, foundRef);\n });\n }\n\n /**\n * Query a JSON Schema object for any `$ref` pointers using JSONPath and return any pointers that\n * exist.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc9535}\n * @param schema JSON Schema object to look for any `$ref` pointers within it.\n */\n private queryForRefPointers(schema: any) {\n return query([\"$..['$ref']\"], schema);\n }\n\n /**\n * Normalize a value from a `jsonpath-plus` `$ref` query to a `$ref` pointer because JSONPath\n * queries may return the property value or the parent.\n *\n */\n private toRefString(value: unknown): string | null {\n if (typeof value === 'string') {\n return value;\n } else if (value && typeof value === 'object' && '$ref' in value && typeof value.$ref === 'string') {\n return value.$ref;\n }\n\n return null;\n }\n\n /**\n * If the given `$ref` points into a path, classify how that path must be retained:\n *\n * - `#/paths/~1pets` — the entire Path Item (operations included)\n * - `#/paths/~1pets/get/...` — a single operation\n * - `#/paths/~1pets/parameters/...` — a Path Item field, so the container must remain\n */\n private parsePathRef(\n $ref: string,\n ):\n | { path: string; retention: 'all' }\n | { path: string; retention: 'operation'; method: string }\n | { path: string; retention: 'container' }\n | null {\n if (typeof $ref !== 'string' || !$ref.startsWith('#/paths/')) {\n return null;\n }\n\n const match = $ref.match(/^#\\/paths\\/([^/]+)(?:\\/([^/]+))?(?:\\/|$)/);\n if (!match?.[1]) {\n return null;\n }\n\n const path = decodePointer(match[1]);\n const segment = match[2];\n if (!segment) {\n return { path, retention: 'all' };\n }\n\n if (supportedMethods.includes(segment.toLowerCase() as HttpMethods)) {\n return { path, method: segment, retention: 'operation' };\n }\n\n return { path, retention: 'container' };\n }\n\n /**\n * If the given `$ref` points into webhooks, classify how that webhook must be retained. Same\n * retention rules as {@link parsePathRef}.\n */\n private parseWebhookRef(\n $ref: string,\n ):\n | { name: string; retention: 'all' }\n | { name: string; retention: 'operation'; method: string }\n | { name: string; retention: 'container' }\n | null {\n if (typeof $ref !== 'string' || !$ref.startsWith('#/webhooks/')) {\n return null;\n }\n\n const match = $ref.match(/^#\\/webhooks\\/([^/]+)(?:\\/([^/]+))?(?:\\/|$)/);\n if (!match?.[1]) {\n return null;\n }\n\n const name = decodePointer(match[1]);\n const segment = match[2];\n if (!segment) {\n return { name, retention: 'all' };\n }\n\n if (supportedMethods.includes(segment.toLowerCase() as HttpMethods)) {\n return { name, method: segment, retention: 'operation' };\n }\n\n return { name, retention: 'container' };\n }\n\n /**\n * If a Path Item we must keep is itself a `$ref`, retain that target and walk it for further\n * `$ref`s. `#/paths/~1foo/get/…` (and the webhook equivalent) do not resolve through a\n * ref-only `/foo` via JSON Pointer, so without this the component is deleted while `/foo`\n * remains as a dangling `$ref`.\n */\n private retainReferencedPathItem(pathItem: PathItemObject | undefined): void {\n if (!isRef(pathItem) || this.$refs.has(pathItem.$ref)) {\n return;\n }\n\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n }\n\n /**\n * Record a security scheme so component cleanup keeps it. Scheme names are JSON-Pointer-encoded\n * so they match the same form used for authored `$ref`s (`foo/bar` → `foo~1bar`).\n */\n private retainSecurityScheme(scheme: string): void {\n this.$refs.add(`#/components/securitySchemes/${encodePointer(scheme)}`);\n }\n\n /** Record a `#/paths` `$ref` so the target Path Item or operation is not dropped. */\n private recordPathRef($ref: string): void {\n const parsed = this.parsePathRef($ref);\n if (!parsed) {\n return;\n }\n\n const pathLC = parsed.path.toLowerCase();\n if (parsed.retention === 'all') {\n this.retainPathMethods.add(`${pathLC}|*`);\n } else if (parsed.retention === 'operation') {\n this.retainPathMethods.add(`${pathLC}|${parsed.method.toLowerCase()}`);\n } else if (!this.retainPathContainers.has(pathLC)) {\n // Field-level pointers keep every sibling Path Item field, so walk those fields for\n // component `$ref`s. Traversing only the pointed-to entry would let component cleanup\n // delete a sibling's target and leave a dangling pointer.\n this.retainPathContainers.add(pathLC);\n this.accumulateContainerFieldRefs(this.findPathItem(parsed.path));\n }\n\n this.retainReferencedPathItem(this.findPathItem(parsed.path));\n }\n\n /** Record a `#/webhooks` `$ref` so the target webhook Path Item or operation is not dropped. */\n private recordWebhookRef($ref: string): void {\n const parsed = this.parseWebhookRef($ref);\n if (!parsed) {\n return;\n }\n\n const nameLC = parsed.name.toLowerCase();\n if (parsed.retention === 'all') {\n this.retainWebhookMethods.add(`${nameLC}|*`);\n } else if (parsed.retention === 'operation') {\n this.retainWebhookMethods.add(`${nameLC}|${parsed.method.toLowerCase()}`);\n } else if (!this.retainWebhookContainers.has(nameLC)) {\n this.retainWebhookContainers.add(nameLC);\n this.accumulateContainerFieldRefs(this.findWebhook(parsed.name));\n }\n\n this.retainReferencedPathItem(this.findWebhook(parsed.name));\n }\n\n /** Look up a Path Item by its path, ignoring key casing. */\n private findPathItem(path: string): PathItemObject | undefined {\n const pathLC = path.toLowerCase();\n const key = Object.keys(this.definition.paths || {}).find(candidate => candidate.toLowerCase() === pathLC);\n return key ? this.definition.paths?.[key] : undefined;\n }\n\n /** Look up a webhook Path Item by name, ignoring key casing. */\n private findWebhook(name: string): PathItemObject | undefined {\n if (!isOpenAPI31(this.definition) || !this.definition.webhooks) {\n return undefined;\n }\n\n const nameLC = name.toLowerCase();\n const key = Object.keys(this.definition.webhooks).find(candidate => candidate.toLowerCase() === nameLC);\n return key ? (this.definition.webhooks[key] as PathItemObject | undefined) : undefined;\n }\n\n /**\n * Accumulate `$ref` pointers from the Path Item fields we keep when a container is retained\n * (parameters, servers, summary, … — everything except HTTP operations).\n */\n private accumulateContainerFieldRefs(pathItem: PathItemObject | undefined): void {\n if (!pathItem) {\n return;\n }\n\n if (isRef(pathItem)) {\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n return;\n }\n\n Object.entries(pathItem).forEach(([key, value]) => {\n if (supportedMethods.includes(key.toLowerCase() as HttpMethods) || value === undefined) {\n return;\n }\n\n this.queryForRefPointers(value).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n });\n }\n\n /** Whether any `$ref` requires this path (or one of its operations) to remain. */\n private isPathRetainedByRef(pathLC: string): boolean {\n return (\n this.retainPathContainers.has(pathLC) ||\n Array.from(this.retainPathMethods).some(key => key.startsWith(`${pathLC}|`))\n );\n }\n\n /** Whether a `$ref` requires this specific path operation — or the entire Path Item — to remain. */\n private isPathOperationRetainedByRef(pathLC: string, methodLC: string): boolean {\n return this.retainPathMethods.has(`${pathLC}|*`) || this.retainPathMethods.has(`${pathLC}|${methodLC}`);\n }\n\n /**\n * Whether the path container must remain after its operations have been filtered. Whole-path\n * `$ref`s also keep the container (and its operations).\n */\n private isPathContainerKept(pathLC: string): boolean {\n return this.retainPathContainers.has(pathLC) || this.retainPathMethods.has(`${pathLC}|*`);\n }\n\n /** Whether any `$ref` requires this webhook (or one of its operations) to remain. */\n private isWebhookRetainedByRef(nameLC: string): boolean {\n return (\n this.retainWebhookContainers.has(nameLC) ||\n Array.from(this.retainWebhookMethods).some(key => key.startsWith(`${nameLC}|`))\n );\n }\n\n /** Whether a `$ref` requires this specific webhook operation — or the entire webhook — to remain. */\n private isWebhookOperationRetainedByRef(nameLC: string, methodLC: string): boolean {\n return this.retainWebhookMethods.has(`${nameLC}|*`) || this.retainWebhookMethods.has(`${nameLC}|${methodLC}`);\n }\n\n /**\n * Whether the webhook container must remain after its operations have been filtered.\n */\n private isWebhookContainerKept(nameLC: string): boolean {\n return this.retainWebhookContainers.has(nameLC) || this.retainWebhookMethods.has(`${nameLC}|*`);\n }\n\n /** Determine whether a path or webhook is excluded in the current transformation mode. */\n private isContainerExcluded(selection: OperationSelection, key: string): boolean {\n if (this.mode === 'prune') {\n return selection.matchesAll(key);\n }\n\n return !selection.has(key);\n }\n\n /**\n * Determine whether an operation passes the configured filters before cross-operation references\n * are considered.\n */\n private shouldRetainOperation(\n selection: OperationSelection,\n key: string,\n method: string,\n operation: OperationObject,\n ): boolean {\n if (this.mode === 'reduce') {\n // Reduction filters intersect, so an operation must match every configured filter.\n if (selection.hasSelections && !selection.matches(key, method)) return false;\n if (\n this.hasOperationIdSelection &&\n !this.operationIdSelection.has(Operation.getOperationId(key, method, operation))\n ) {\n return false;\n }\n if (this.hasTagSelection && !(operation.tags || []).some(tag => this.tagSelection.includes(tag.toLowerCase()))) {\n return false;\n }\n } else {\n // Pruning filters are additive, so matching any configured filter removes an operation.\n if (selection.hasSelections && selection.matches(key, method)) return false;\n if (\n this.hasOperationIdSelection &&\n this.operationIdSelection.has(Operation.getOperationId(key, method, operation))\n ) {\n return false;\n }\n if (this.hasTagSelection && (operation.tags || []).some(tag => this.tagSelection.includes(tag.toLowerCase()))) {\n return false;\n }\n }\n\n // No configured filter excluded this operation, so retain it in the transformed definition.\n return true;\n }\n\n /** Determine whether a path item contains at least one HTTP operation. */\n private hasOperations(pathItem: PathItemObject | undefined): boolean {\n return Boolean(pathItem && supportedMethods.some(method => method in pathItem));\n }\n\n /**\n * Accumulate any `$ref` pointers that are used by common Path Item parameters.\n *\n * @param parameters Common Path Item parameters to inspect for `$ref` pointers.\n */\n private accumulateParameterRefs(parameters: PathItemObject['parameters'] | undefined): void {\n if (!parameters) {\n return;\n }\n\n this.queryForRefPointers(parameters).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n }\n\n /**\n * Walk through the `paths` in our OpenAPI definition and determine which operations we want to\n * retain. Accumulate any `$ref` pointers that they use so their referenced schemas can also be\n * retained in our resulting API definition.\n *\n */\n private walkPaths(): void {\n if (!('paths' in this.definition) || !this.definition.paths) {\n return;\n }\n\n Object.keys(this.definition.paths).forEach(path => {\n // When only webhooks were requested (no path/operation filter), ignore all paths, but don't\n // delete them yet because a selected webhook may reference one of their operations. We'll\n // remove any that aren't referenced later.\n if (this.mode === 'reduce' && this.hasWebhookSelection && !this.hasPathSelection) {\n return;\n } else if (this.hasPathSelection && this.isContainerExcluded(this.pathSelection, path)) {\n return;\n }\n\n const pathItem = this.definition.paths?.[path];\n\n /**\n * Referenced Path Items that remain in the result are preserved intact rather than partially\n * transformed. Retain the target and continue walking any local sibling fields so that we\n * retain their dependencies too.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(pathItem)) {\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n }\n\n // If this Path Item has no operations then it will remain in our resulting API definition,\n // so we need to retain any components referenced by its common parameters.\n if (!this.hasOperations(pathItem)) {\n this.accumulateParameterRefs(pathItem?.parameters);\n }\n\n Object.keys(pathItem || {}).forEach(method => {\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(method.toLowerCase() as HttpMethods)) {\n return;\n }\n\n const operation = this.definition.paths?.[path]?.[method as HttpMethods] as OperationObject;\n if (!operation) {\n throw new Error(`Operation \\`${method} ${path}\\` not found`);\n }\n\n // If this operation isn't part of our resulting API definition then ignore it. We'll\n // remove it later.\n if (!this.shouldRetainOperation(this.pathSelection, path, method, operation)) {\n return;\n }\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n // Skipped by the `method === 'parameters'` guard above; accumulate here so refs are only\n // retained when at least one operation on this path passes all filters.\n this.accumulateParameterRefs(pathItem?.parameters);\n\n this.queryForRefPointers(operation).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n\n // Re-run through any `$ref` pointers that we found within this operation and search for\n // any `$ref` pointers that they also may be using. This also records `#/paths` and\n // `#/webhooks` targets so they are retained.\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n });\n }\n\n /**\n * Walk through the `webhooks` in our OpenAPI definition and determine which operations we want\n * to retain. Accumulate any `$ref` pointers that they use so their referenced schemas can also be\n * retained in our resulting API definition.\n *\n */\n private walkWebhooks() {\n if (!isOpenAPI31(this.definition)) {\n return;\n } else if (!('webhooks' in this.definition) || !this.definition.webhooks) {\n return;\n }\n\n const definition = this.definition satisfies OpenAPIV3_1.Document;\n\n Object.keys(definition.webhooks || {}).forEach(webhookName => {\n if (this.hasWebhookSelection && this.isContainerExcluded(this.webhookSelection, webhookName)) {\n return;\n }\n\n const webhook: PathItemObject | undefined = definition.webhooks?.[webhookName];\n if (!webhook || typeof webhook !== 'object') {\n return;\n }\n\n /**\n * Referenced webhook Path Items that remain in the result are preserved intact rather than\n * partially transformed. Retain the target and continue walking any local sibling fields so\n * that we retain their dependencies too.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (typeof webhook.$ref === 'string') {\n this.$refs.add(webhook.$ref);\n this.accumulateUsedRefs(definition, this.$refs, webhook.$ref);\n }\n\n // If this webhook has no operations then it will remain in our resulting API definition, so\n // we need to retain any components referenced by its common parameters.\n if (!this.hasOperations(webhook)) {\n this.accumulateParameterRefs(webhook.parameters);\n }\n\n Object.keys(webhook).forEach(method => {\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(method.toLowerCase() as HttpMethods)) {\n return;\n }\n\n const operation = webhook[method as HttpMethods] as OperationObject;\n if (!operation) {\n throw new Error(`Webhook operation \\`${method} ${webhookName}\\` not found`);\n }\n\n // If this operation isn't part of our resulting API definition then ignore it. We'll\n // remove it later.\n if (!this.shouldRetainOperation(this.webhookSelection, webhookName, method, operation)) {\n return;\n }\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n // Skipped by the `method === 'parameters'` guard above; accumulate here so refs are only\n // retained when at least one operation on this webhook passes all filters.\n this.accumulateParameterRefs(webhook.parameters);\n\n this.queryForRefPointers(operation).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(definition, this.$refs, refStr);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n });\n }\n\n /**\n * Transform our `paths` object according to the paths and operations that we've selected.\n */\n private transformPaths(): void {\n if (!('paths' in this.definition) || !this.definition.paths) {\n return;\n }\n\n Object.keys(this.definition.paths).forEach(path => {\n const pathLC = path.toLowerCase();\n const excludePathItem =\n (this.hasPathSelection && this.isContainerExcluded(this.pathSelection, path)) ||\n (this.mode === 'reduce' && this.hasWebhookSelection && !this.hasPathSelection);\n\n if (this.mode === 'prune' && excludePathItem) {\n if (this.isPathRetainedByRef(pathLC)) {\n throw new Error(`Cannot remove path \\`${path}\\` because one of its operations is referenced.`);\n }\n\n delete this.definition.paths?.[path];\n return;\n }\n\n const pathItem = this.definition.paths?.[path];\n\n /**\n * Referenced Path Items are preserved intact during operation-level filtering. If the whole\n * Path Item is excluded, remove it unless a surviving operation references it.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(pathItem)) {\n if (excludePathItem && !this.isPathRetainedByRef(pathLC)) {\n delete this.definition.paths?.[path];\n }\n\n return;\n }\n\n let removedOperation = false;\n Object.keys(pathItem || {}).forEach(method => {\n const methodLC = method.toLowerCase();\n\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(methodLC as HttpMethods)) {\n return;\n }\n\n const retainedByRef = this.isPathOperationRetainedByRef(pathLC, methodLC);\n\n const operation = this.definition.paths?.[path]?.[method as HttpMethods];\n if (!operation) {\n throw new Error(`Operation \\`${method} ${path}\\` not found`);\n }\n\n if (excludePathItem || !this.shouldRetainOperation(this.pathSelection, path, method, operation)) {\n if (this.mode === 'prune' && retainedByRef) {\n throw new Error(`Cannot remove operation \\`${method.toUpperCase()} ${path}\\` because it is referenced.`);\n }\n\n if (!retainedByRef) {\n delete this.definition.paths?.[path]?.[method as HttpMethods];\n removedOperation = true;\n return;\n }\n }\n\n // This operation remains in the transformed definition, so retain any components\n // referenced by its common Path Item parameters.\n this.accumulateParameterRefs(pathItem?.parameters);\n\n // Accumulate a list of used tags so we can filter out any ones that we don't need later.\n if ('tags' in operation) {\n operation.tags?.forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n }\n\n // Accumulate any used operation-level security schemas that we need to retain.\n if ('security' in operation) {\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n }\n });\n\n // If filtering removed every operation from this path then remove its path-level properties\n // as well. We leave path items that were authored without operations untouched.\n if (\n !this.isPathContainerKept(pathLC) &&\n (((removedOperation || (this.mode === 'reduce' && excludePathItem)) && !this.hasOperations(pathItem)) ||\n (this.mode === 'reduce' && !Object.keys(this.definition.paths?.[path] || {}).length))\n ) {\n delete this.definition.paths?.[path];\n }\n });\n\n // If we don't have any paths left then retain the reducer's no-match error. An empty Paths\n // Object is valid OpenAPI so we allow it when pruning.\n if (!Object.keys(this.definition.paths || {}).length) {\n if (this.mode === 'reduce' && !(this.definition.webhooks && Object.keys(this.definition.webhooks).length)) {\n throw new Error(\n 'All paths in the API definition were removed. Did you supply the right path name to reduce by?',\n );\n }\n\n if (this.definition.webhooks && Object.keys(this.definition.webhooks).length) {\n delete this.definition.paths;\n }\n }\n }\n\n /**\n * Transform our `webhooks` object according to the webhooks and operations that we've selected.\n */\n private transformWebhooks(): void {\n if (!isOpenAPI31(this.definition)) {\n return;\n } else if (!('webhooks' in this.definition) || !this.definition.webhooks) {\n return;\n }\n\n const definition = this.definition satisfies OpenAPIV3_1.Document;\n\n Object.keys(definition.webhooks || {}).forEach(webhookName => {\n const nameLC = webhookName.toLowerCase();\n const excludeWebhook = this.hasWebhookSelection && this.isContainerExcluded(this.webhookSelection, webhookName);\n\n if (this.mode === 'prune' && excludeWebhook) {\n if (this.isWebhookRetainedByRef(nameLC)) {\n throw new Error(`Cannot remove webhook \\`${webhookName}\\` because one of its operations is referenced.`);\n }\n\n delete definition.webhooks?.[webhookName];\n return;\n }\n\n const webhook = definition.webhooks?.[webhookName];\n if (!webhook || typeof webhook !== 'object') {\n return;\n }\n\n /**\n * Referenced webhook Path Items are preserved intact during operation-level filtering. If\n * the whole webhook is excluded, remove it unless a surviving operation references it.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(webhook)) {\n if (excludeWebhook && !this.isWebhookRetainedByRef(nameLC)) {\n delete definition.webhooks?.[webhookName];\n }\n\n return;\n }\n\n let removedOperation = false;\n Object.keys(webhook).forEach(method => {\n const methodLC = method.toLowerCase();\n if (method === 'parameters' || !supportedMethods.includes(methodLC as HttpMethods)) {\n return;\n }\n\n const operation = webhook[method as HttpMethods];\n if (!operation) {\n throw new Error(`Webhook operation \\`${method} ${webhookName}\\` not found`);\n }\n\n const retainedByRef = this.isWebhookOperationRetainedByRef(nameLC, methodLC);\n if (excludeWebhook || !this.shouldRetainOperation(this.webhookSelection, webhookName, method, operation)) {\n if (this.mode === 'prune' && retainedByRef) {\n throw new Error(\n `Cannot remove operation \\`${method.toUpperCase()} ${webhookName}\\` because it is referenced.`,\n );\n }\n\n if (!retainedByRef) {\n delete webhook[method as HttpMethods];\n removedOperation = true;\n return;\n }\n }\n\n // This operation remains in the transformed definition, so retain any components\n // referenced by its common Path Item parameters.\n this.accumulateParameterRefs(webhook.parameters);\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n\n if (\n !this.isWebhookContainerKept(nameLC) &&\n (((removedOperation || (this.mode === 'reduce' && excludeWebhook)) && !this.hasOperations(webhook)) ||\n (this.mode === 'reduce' && !Object.keys(definition.webhooks?.[webhookName] || {}).length))\n ) {\n delete definition.webhooks?.[webhookName];\n }\n });\n\n if (definition.webhooks && !Object.keys(definition.webhooks).length) {\n delete definition.webhooks;\n }\n }\n}\n","/**\n * Track selected HTTP operations within OpenAPI paths or webhooks. Container keys and HTTP methods\n * are matched without regard to casing.\n */\nexport class OperationSelection {\n private selections: Map<string, '*' | Set<string>> = new Map();\n\n /** Whether any paths or webhooks have been selected. */\n get hasSelections(): boolean {\n return this.selections.size > 0;\n }\n\n /**\n * Select every operation within a path or webhook.\n *\n * @param key Path or webhook key whose operations should be selected.\n */\n addAll(key: string): void {\n this.selections.set(this.normalize(key), '*');\n }\n\n /**\n * Add an operation to the selection for a path or webhook. If every operation for the key is\n * already selected, that selection remains unchanged.\n *\n * @param key Path or webhook key that contains the operation.\n * @param method HTTP method of the operation to select.\n */\n addOperation(key: string, method: string): void {\n const normalizedKey = this.normalize(key);\n const normalizedMethod = this.normalize(method);\n const selection = this.selections.get(normalizedKey);\n\n if (selection === '*') {\n return;\n }\n\n if (selection instanceof Set) {\n selection.add(normalizedMethod);\n return;\n }\n\n this.selections.set(normalizedKey, new Set([normalizedMethod]));\n }\n\n /**\n * Clear every operation selection for a path or webhook.\n *\n * @param key Path or webhook key to clear.\n */\n clear(key: string): void {\n this.selections.delete(this.normalize(key));\n }\n\n /**\n * Determine whether a path or webhook has any selected operations.\n *\n * @param key Path or webhook key to check.\n */\n has(key: string): boolean {\n return this.selections.has(this.normalize(key));\n }\n\n /**\n * Determine whether every operation within a path or webhook is selected.\n *\n * @param key Path or webhook key to check.\n */\n matchesAll(key: string): boolean {\n return this.selections.get(this.normalize(key)) === '*';\n }\n\n /**\n * Determine whether an operation is selected.\n *\n * @param key Path or webhook key that contains the operation.\n * @param method HTTP method of the operation to check.\n */\n matches(key: string, method: string): boolean {\n const selection = this.selections.get(this.normalize(key));\n return selection === '*' || Boolean(selection?.has(this.normalize(method)));\n }\n\n /** Normalize path, webhook, and method casing for comparisons. */\n private normalize(value: string): string {\n return value.toLowerCase();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,OAAO,iBAAiB;;;ACNjB,IAAM,qBAAN,MAAyB;AAAA,EACtB,aAA6C,oBAAI,IAAI;AAAA;AAAA,EAG7D,IAAI,gBAAyB;AAC3B,WAAO,KAAK,WAAW,OAAO;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,KAAmB;AACxB,SAAK,WAAW,IAAI,KAAK,UAAU,GAAG,GAAG,GAAG;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,KAAa,QAAsB;AAC9C,UAAM,gBAAgB,KAAK,UAAU,GAAG;AACxC,UAAM,mBAAmB,KAAK,UAAU,MAAM;AAC9C,UAAM,YAAY,KAAK,WAAW,IAAI,aAAa;AAEnD,QAAI,cAAc,KAAK;AACrB;AAAA,IACF;AAEA,QAAI,qBAAqB,KAAK;AAC5B,gBAAU,IAAI,gBAAgB;AAC9B;AAAA,IACF;AAEA,SAAK,WAAW,IAAI,eAAe,oBAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAmB;AACvB,SAAK,WAAW,OAAO,KAAK,UAAU,GAAG,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,KAAsB;AACxB,WAAO,KAAK,WAAW,IAAI,KAAK,UAAU,GAAG,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAW,KAAsB;AAC/B,WAAO,KAAK,WAAW,IAAI,KAAK,UAAU,GAAG,CAAC,MAAM;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAQ,KAAa,QAAyB;AAC5C,UAA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