@kubb/adapter-oas 5.0.0-beta.21 → 5.0.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +35 -17
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/extension.yaml +144 -57
- package/package.json +2 -2
- package/src/adapter.ts +14 -6
- package/src/types.ts +21 -11
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#options","#transformParam","#eachParam"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/object.ts","../../../internals/utils/src/promise.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/constants.ts","../src/guards.ts","../src/factory.ts","../src/refs.ts","../src/resolvers.ts","../src/parser.ts","../src/discriminator.ts","../src/stream.ts","../src/adapter.ts","../src/types.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n *\n * Empty segments are filtered before joining. They arise when the text starts with\n * a dot followed immediately by a letter (e.g. `..Schema` splits into `['..', 'Schema']`\n * and `'..'` transforms to an empty string). Without this filter the join would produce\n * a leading `/`, which `path.resolve` would interpret as an absolute path, allowing\n * generated files to escape the configured output directory.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => transformPart(part, i === parts.length - 1))\n .filter(Boolean)\n .join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\n * Returns `true` when `value` is a plain (non-null, non-array) object.\n *\n * @example\n * ```ts\n * isPlainObject({}) // true\n * isPlainObject([]) // false\n * isPlainObject(null) // false\n * ```\n */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype\n}\n\n/**\n * Recursively merges `source` into `target`, combining nested plain objects.\n * Arrays and non-object values from `source` override the corresponding values in `target`.\n *\n * @example\n * ```ts\n * mergeDeep({ a: { x: 1 } }, { a: { y: 2 } })\n * // { a: { x: 1, y: 2 } }\n * ```\n */\nexport function mergeDeep(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target }\n for (const key of Object.keys(source)) {\n const sv = source[key]\n const tv = result[key]\n result[key] =\n sv !== null && typeof sv === 'object' && !Array.isArray(sv) && tv !== null && typeof tv === 'object' && !Array.isArray(tv)\n ? mergeDeep(tv as Record<string, unknown>, sv as Record<string, unknown>)\n : sv\n }\n return result\n}\n\n/**\n * Strips functions, symbols, and `undefined` values from plugin options for safe JSON transport.\n *\n * @example\n * ```ts\n * serializePluginOptions({ output: './src', onWrite: () => {} })\n * // { output: './src' } (function stripped)\n * ```\n */\nexport function serializePluginOptions<TOptions extends object>(options: TOptions): TOptions {\n if (options === null || options === undefined) return {} as TOptions\n if (typeof options !== 'object') return options\n if (Array.isArray(options)) return options.map(serializePluginOptions) as unknown as TOptions\n\n const serialized: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(options)) {\n if (typeof value === 'function' || typeof value === 'symbol' || value === undefined) continue\n serialized[key] = value !== null && typeof value === 'object' ? serializePluginOptions(value as object) : value\n }\n return serialized as TOptions\n}\n","function* chunks<T>(arr: readonly T[], size: number): Generator<T[]> {\n for (let i = 0; i < arr.length; i += size) {\n yield arr.slice(i, i + size)\n }\n}\n\nexport type ForBatchesOptions = {\n /**\n * Maximum batch size handed to `process`.\n * Parallel dispatch within a batch is the caller's responsibility\n * (typically via `Promise.all(batch.map(...))`).\n */\n concurrency: number\n /**\n * Called after every batch.\n *\n * Use a cheap, idempotent callback (e.g. one that short-circuits when there\n * is nothing new to do). The helper does not coalesce calls — if you need\n * throttling, do it inside `flush` itself.\n */\n flush?: () => Promise<void>\n}\n\n/**\n * Slices `source` into batches of `concurrency` items and awaits `process` for each batch.\n * Accepts both plain arrays (sync) and `AsyncIterable` (streaming).\n *\n * `process` controls whether items inside a batch run in parallel; this helper only\n * controls batch size and per-batch flushing.\n *\n * @example\n * ```ts\n * // parallel dispatch inside each batch\n * await forBatches(schemas, (batch) => Promise.all(batch.map(process)), { concurrency: 8 })\n *\n * // async iterable with a flush after every batch\n * await forBatches(stream.schemas, (batch) => dispatch(batch), { concurrency: 8, flush })\n * ```\n */\nexport async function forBatches<T>(\n source: readonly T[] | AsyncIterable<T>,\n process: (batch: T[]) => Promise<unknown>,\n options: ForBatchesOptions,\n): Promise<void> {\n const { concurrency, flush } = options\n\n if (Array.isArray(source)) {\n for (const batch of chunks(source, concurrency)) {\n await process(batch)\n if (flush) await flush()\n }\n return\n }\n\n const batch: T[] = []\n for await (const item of source) {\n batch.push(item)\n if (batch.length >= concurrency) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n }\n if (batch.length > 0) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n}\n\n/**\n * Runs `work`, passing `flush` as its periodic-flush callback, then calls\n * `flush` once more to drain any items that did not cross a flush boundary.\n *\n * @example\n * ```ts\n * await withDrain(\n * (flush) => processItems(items, { flush }),\n * () => writeRemainingFiles(),\n * )\n * ```\n */\nexport async function withDrain(work: (flush: () => Promise<void>) => Promise<void>, flush: () => Promise<void>): Promise<void> {\n await work(flush)\n await flush()\n}\n\n/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\n/** Returns `true` when `result` is a thenable `Promise`.\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve(1)) // true\n * isPromise(42) // false\n * ```\n */\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return result !== null && result !== undefined && typeof (result as Record<string, unknown>)['then'] === 'function'\n}\n\n/** Returns `true` when `result` is a fulfilled `Promise.allSettled` result.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseFulfilledResult).map((r) => r.value)\n * ```\n */\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n\n/**\n * Returns a wrapper that caches the result of the first invocation and replays\n * it for every subsequent call, ignoring later arguments.\n *\n * Works for sync and async factories — for async, the cached value is the\n * promise itself, so concurrent callers share one in-flight execution and\n * cannot race each other.\n *\n * @example\n * ```ts\n * const loadDocument = once(async (path: string) => parse(await readFile(path)))\n * const a = loadDocument('./a.yaml') // parses\n * const b = loadDocument('./b.yaml') // returns the cached promise from the first call\n * ```\n */\nexport function once<TArgs extends unknown[], TReturn>(factory: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn {\n let cache: { value: TReturn } | undefined\n return (...args: TArgs): TReturn => {\n if (!cache) cache = { value: factory(...args) }\n return cache.value\n }\n}\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Wraps `factory` with a keyed cache backed by the provided store.\n *\n * Pass a `WeakMap` for object keys (results are GC-eligible when the key is\n * collected) or a `Map` for primitive keys. For multi-argument functions,\n * nest two `memoize` calls — the outer keyed by the first argument, the\n * inner (created once per outer miss) keyed by the second.\n *\n * Because the cache is owned by the caller, it can be shared, inspected, or\n * cleared independently of the memoized function.\n *\n * @example Single WeakMap key\n * ```ts\n * const cache = new WeakMap<SchemaNode, Set<string>>()\n * const getRefs = memoize(cache, (node) => collectRefs(node))\n * ```\n *\n * @example Single Map key (primitive)\n * ```ts\n * const cache = new Map<string, Resolver>()\n * const getResolver = memoize(cache, (name) => buildResolver(name))\n * ```\n *\n * @example Two-level (object + primitive)\n * ```ts\n * const outer = new WeakMap<Params[], Map<string, Params[]>>()\n * const fn = memoize(outer, (params) => memoize(new Map(), (key) => transform(params, key)))\n * fn(params)('camelcase')\n * ```\n */\nexport function memoize<TKey, TValue>(store: Store<TKey, TValue>, factory: (key: TKey) => TValue): (key: TKey) => TValue {\n return (key: TKey): TValue => {\n if (store.has(key)) return store.get(key)!\n const value = factory(key)\n store.set(key, value)\n return value\n }\n}\n\n/**\n * Wraps a plain array in a reusable `AsyncIterable`.\n * Each `[Symbol.asyncIterator]()` call returns a fresh generator so the\n * iterable can be consumed multiple times (e.g. once per plugin pre-scan).\n *\n * @example\n * ```ts\n * const stream = arrayToAsyncIterable([1, 2, 3])\n * for await (const n of stream) console.log(n) // 1, 2, 3\n * ```\n */\nexport function arrayToAsyncIterable<T>(arr: readonly T[]): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]() {\n return (async function* () {\n yield* arr\n })()\n },\n }\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `undefined` when the path has none.\n */\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({\n prefix = '',\n replacer,\n }: {\n prefix?: string\n replacer?: (pathParam: string) => string\n } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { ast } from '@kubb/core'\n\n/**\n * Default parser options applied when no explicit options are provided.\n *\n * @example\n * ```ts\n * import { DEFAULT_PARSER_OPTIONS } from '@kubb/adapter-oas'\n *\n * const parser = createOasParser(oas)\n * const root = parser.parse({ ...DEFAULT_PARSER_OPTIONS, dateType: 'date' })\n * ```\n */\nexport const DEFAULT_PARSER_OPTIONS = {\n dateType: 'string',\n integerType: 'bigint',\n unknownType: 'any',\n emptySchemaType: 'any',\n enumSuffix: 'enum',\n} as const satisfies ast.ParserOptions\n\n/**\n * JSON-Pointer prefix for schemas declared under `components.schemas` in an OpenAPI document.\n *\n * Used when building or parsing `$ref` strings.\n *\n * @example\n * ```ts\n * `${SCHEMA_REF_PREFIX}Pet` // '#/components/schemas/Pet'\n * ```\n */\nexport const SCHEMA_REF_PREFIX = '#/components/schemas/' as const\n\n/**\n * OpenAPI version string written into the stub document created during multi-spec merges.\n */\nexport const MERGE_OPENAPI_VERSION = '3.0.0' as const\n\n/**\n * Fallback `info.title` placed in the stub document when merging multiple API files.\n */\nexport const MERGE_DEFAULT_TITLE = 'Merged API' as const\n\n/**\n * Fallback `info.version` placed in the stub document when merging multiple API files.\n */\nexport const MERGE_DEFAULT_VERSION = '1.0.0' as const\n\n/**\n * Set of JSON Schema keywords that prevent a schema fragment from being inlined during `allOf` flattening.\n *\n * A fragment that contains any of these keys carries structural meaning of its own and must stay as a separate\n * intersection member rather than being merged into the parent.\n *\n * @example\n * ```ts\n * import { structuralKeys } from '@kubb/adapter-oas'\n *\n * const isStructural = Object.keys(fragment).some((key) => structuralKeys.has(key))\n * // true when fragment has e.g. 'properties' or 'oneOf'\n * ```\n */\nexport const structuralKeys = new Set(['properties', 'items', 'additionalProperties', 'oneOf', 'anyOf', 'allOf', 'not'] as const)\n\n/**\n * Static map from OAS `format` strings to Kubb `SchemaType` values.\n *\n * Only formats whose AST type differs from the OAS `type` field appear here.\n * Formats that depend on runtime options (`int64`, `date-time`, `date`, `time`) are handled separately\n * in the parser. `ipv4` and `ipv6` map to their own dedicated schema types; `hostname` and\n * `idn-hostname` map to `'url'` as the closest generic string-format type.\n *\n * @example\n * ```ts\n * import { formatMap } from '@kubb/adapter-oas'\n *\n * formatMap['uuid'] // 'uuid'\n * formatMap['binary'] // 'blob'\n * formatMap['float'] // 'number'\n * ```\n */\nexport const formatMap = {\n uuid: 'uuid',\n email: 'email',\n 'idn-email': 'email',\n uri: 'url',\n 'uri-reference': 'url',\n url: 'url',\n ipv4: 'ipv4',\n ipv6: 'ipv6',\n hostname: 'url',\n 'idn-hostname': 'url',\n binary: 'blob',\n byte: 'blob',\n // Numeric formats override the OAS `type` because format is more specific.\n // See https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7\n int32: 'integer',\n float: 'number',\n double: 'number',\n} as const satisfies Record<string, ast.SchemaType>\n\n/**\n * Vendor extension keys that attach human-readable labels to enum values, checked in priority order.\n *\n * @example\n * ```ts\n * import { enumExtensionKeys } from '@kubb/adapter-oas'\n *\n * const key = enumExtensionKeys.find((k) => k in schema) // 'x-enumNames' | 'x-enum-varnames' | undefined\n * ```\n */\nexport const enumExtensionKeys = ['x-enumNames', 'x-enum-varnames'] as const\n\n/**\n * Maps `'any' | 'unknown' | 'void'` option strings to their `ScalarSchemaType` constant.\n * Replaces a plain object lookup with a `Map` for explicit key membership testing via `.has()`.\n */\nexport const typeOptionMap = new Map<'any' | 'unknown' | 'void', ast.ScalarSchemaType>([\n ['any', ast.schemaTypes.any],\n ['unknown', ast.schemaTypes.unknown],\n ['void', ast.schemaTypes.void],\n])\n","import { isPlainObject } from '@internals/utils'\nimport type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\nimport type { DiscriminatorObject, SchemaObject } from './types.ts'\n\n/**\n * Returns `true` when `doc` is a Swagger 2.0 document (no `openapi` key).\n *\n * @example\n * ```ts\n * if (isOpenApiV2Document(doc)) {\n * // doc is OpenAPIV2.Document\n * }\n * ```\n */\nexport function isOpenApiV2Document(doc: unknown): doc is OpenAPIV2.Document {\n return !!doc && isPlainObject(doc) && !('openapi' in doc)\n}\n\n/**\n * Returns `true` when a schema should be treated as nullable.\n *\n * Recognizes all nullable signals across OAS versions: `nullable: true` (OAS 3.0),\n * `x-nullable: true` (vendor extension), `type: 'null'`, and `type: ['null', ...]` (OAS 3.1).\n *\n * @example\n * ```ts\n * isNullable({ type: 'string', nullable: true }) // true\n * isNullable({ type: ['string', 'null'] }) // true\n * isNullable({ type: 'string' }) // false\n * ```\n */\nexport function isNullable(schema?: SchemaObject & { 'x-nullable'?: boolean }): boolean {\n const explicitNullable = schema?.nullable ?? schema?.['x-nullable']\n if (explicitNullable === true) return true\n\n const schemaType = schema?.type\n if (schemaType === 'null') return true\n if (Array.isArray(schemaType)) return schemaType.includes('null')\n\n return false\n}\n\n/**\n * Returns `true` when `obj` is an OpenAPI `$ref` pointer object.\n *\n * @example\n * ```ts\n * isReference({ $ref: '#/components/schemas/Pet' }) // true\n * isReference({ type: 'string' }) // false\n * ```\n */\nexport function isReference(obj?: unknown): obj is OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject {\n return !!obj && typeof obj === 'object' && '$ref' in obj\n}\n\n/**\n * Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object.\n *\n * @example\n * ```ts\n * isDiscriminator({ discriminator: { propertyName: 'type', mapping: {} } }) // true\n * isDiscriminator({ discriminator: 'type' }) // false (Swagger 2 string form)\n * ```\n */\nexport function isDiscriminator(obj?: unknown): obj is SchemaObject & { discriminator: DiscriminatorObject } {\n const record = obj as Record<string, unknown>\n return !!obj && !!record['discriminator'] && typeof record['discriminator'] !== 'string'\n}\n","import path from 'node:path'\nimport { mergeDeep, URLPath } from '@internals/utils'\nimport type { AdapterSource } from '@kubb/core'\nimport { bundle, loadConfig } from '@redocly/openapi-core'\nimport OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\nimport { MERGE_DEFAULT_TITLE, MERGE_DEFAULT_VERSION, MERGE_OPENAPI_VERSION } from './constants.ts'\nimport { isOpenApiV2Document } from './guards.ts'\nimport type { Document } from './types.ts'\n\nexport type ParseOptions = {\n canBundle?: boolean\n enablePaths?: boolean\n}\n\nexport type ValidateDocumentOptions = {\n throwOnError?: boolean\n}\n\n/**\n * Loads and dereferences an OpenAPI document, returning the raw `Document`.\n *\n * Accepts a file path string or an already-parsed document object. File paths are bundled via\n * Redocly to resolve external `$ref`s. Swagger 2.0 documents are automatically up-converted\n * to OpenAPI 3.0 via `swagger2openapi`.\n *\n * @example\n * ```ts\n * const document = await parseDocument('./openapi.yaml')\n * const document = await parse(rawDocumentObject, { canBundle: false })\n * ```\n */\nexport async function parseDocument(pathOrApi: string | Document, { canBundle = true, enablePaths = true }: ParseOptions = {}): Promise<Document> {\n if (typeof pathOrApi === 'string' && canBundle) {\n const config = await loadConfig()\n const bundleResults = await bundle({\n ref: pathOrApi,\n config,\n base: pathOrApi,\n })\n\n return parseDocument(bundleResults.bundle.parsed as string, {\n canBundle,\n enablePaths,\n })\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n return openapi as Document\n }\n\n return document\n}\n\n/**\n * Deep-merges multiple OpenAPI documents into a single `Document`.\n *\n * Each document is parsed independently then recursively merged via `mergeDeep` from `@internals/utils`.\n * Throws when the input array is empty.\n *\n * @example\n * ```ts\n * const document = await mergeDocuments(['./pets.yaml', './orders.yaml'])\n * ```\n */\nexport async function mergeDocuments(pathOrApi: Array<string | Document>): Promise<Document> {\n const documents = await Promise.all(pathOrApi.map((p) => parseDocument(p, { enablePaths: false, canBundle: false })))\n\n if (documents.length === 0) {\n throw new Error('No OAS documents provided for merging.')\n }\n\n const seed: Document = {\n openapi: MERGE_OPENAPI_VERSION,\n info: { title: MERGE_DEFAULT_TITLE, version: MERGE_DEFAULT_VERSION },\n paths: {},\n components: { schemas: {} },\n } as Document\n\n const merged = documents.reduce(\n (acc, current) => mergeDeep(acc as Record<string, unknown>, current as Record<string, unknown>),\n seed as Record<string, unknown>,\n )\n\n return parseDocument(merged as Document)\n}\n\n/**\n * Creates a `Document` from an `AdapterSource`.\n *\n * Handles all three source types:\n * - `{ type: 'path' }` — resolves and bundles a local file path or remote URL.\n * - `{ type: 'paths' }` — merges multiple file paths into a single document.\n * - `{ type: 'data' }` — parses an inline string (YAML/JSON) or raw object.\n *\n * @example\n * ```ts\n * const document = await parseFromConfig({ type: 'path', path: './openapi.yaml' })\n * const document = await parseFromConfig({ type: 'data', data: '{\"openapi\":\"3.0.0\",...}' })\n * ```\n */\nexport function parseFromConfig(source: AdapterSource): Promise<Document> {\n if (source.type === 'data') {\n if (typeof source.data === 'object') {\n return parseDocument(structuredClone(source.data) as Document)\n }\n\n return parseDocument(source.data as string, { canBundle: false })\n }\n\n if (source.type === 'paths') {\n return mergeDocuments(source.paths)\n }\n\n // type === 'path'\n if (new URLPath(source.path).isURL) {\n return parseDocument(source.path)\n }\n\n return parseDocument(path.resolve(path.dirname(source.path), source.path))\n}\n\n/**\n * Validates an OpenAPI document using `oas-normalize` with colorized error output.\n *\n * @example\n * ```ts\n * await validateDocument(document)\n * ```\n */\nexport async function validateDocument(document: Document, { throwOnError = false }: ValidateDocumentOptions = {}): Promise<void> {\n try {\n const oasNormalize = new OASNormalize(document, {\n enablePaths: true,\n colorizeErrors: true,\n })\n\n await oasNormalize.validate({\n parser: {\n validate: {\n errors: { colorize: true },\n },\n },\n })\n } catch (error) {\n if (throwOnError) {\n throw error\n }\n\n // Validation failures are non-fatal — mirror plugin-oas behavior\n }\n}\n","import { isReference } from './guards.ts'\nimport type { Document } from './types.ts'\n\nconst _refCache = new WeakMap<Document, Map<string, unknown>>()\n\n/**\n * Resolves a local JSON pointer reference from a document.\n *\n * Accepts `#/...` refs. Returns `null` for empty or non-local refs.\n * Throws when the pointer cannot be resolved.\n *\n * @example\n * ```ts\n * resolveRef<SchemaObject>(document, '#/components/schemas/Pet') // SchemaObject | null\n * ```\n */\nexport function resolveRef<T = unknown>(document: Document, $ref: string): T | null {\n const origRef = $ref\n $ref = $ref.trim()\n if ($ref === '') {\n return null\n }\n if (!$ref.startsWith('#')) return null\n $ref = globalThis.decodeURIComponent($ref.substring(1))\n\n let docCache = _refCache.get(document)\n if (!docCache) {\n docCache = new Map()\n _refCache.set(document, docCache)\n }\n\n if (docCache.has($ref)) {\n return docCache.get($ref) as T\n }\n\n const current = $ref\n .split('/')\n .filter(Boolean)\n .reduce((obj: unknown, key: string) => (obj as Record<string, unknown>)?.[key], document as unknown)\n\n if (!current) {\n throw new Error(`Could not find a definition for ${origRef}.`)\n }\n\n docCache.set($ref, current)\n return current as T\n}\n\n/**\n * Resolves a `$ref` object while preserving the original `$ref` field on the result.\n *\n * Useful for parser flows that need both dereferenced fields and pointer\n * identity (for naming/import purposes). Non-reference values are returned as-is.\n *\n * @example\n * ```ts\n * dereferenceWithRef(document, { $ref: '#/components/schemas/Pet' })\n * // { $ref: '#/components/schemas/Pet', type: 'object', properties: { ... } }\n * ```\n */\nexport function dereferenceWithRef<T = unknown>(document: Document, schema?: T): T {\n if (isReference(schema)) {\n return {\n ...schema,\n ...resolveRef(document, schema.$ref),\n $ref: schema.$ref,\n }\n }\n\n return schema as T\n}\n","import { pascalCase } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport type { ParameterObject, ServerObject } from 'oas/types'\nimport { isRef } from 'oas/types'\nimport { matchesMimeType } from 'oas/utils'\nimport { formatMap, SCHEMA_REF_PREFIX, structuralKeys } from './constants.ts'\nimport { isReference } from './guards.ts'\nimport { dereferenceWithRef, resolveRef } from './refs.ts'\nimport type { ContentType, Document, MediaTypeObject, Operation, ResponseObject, SchemaObject } from './types.ts'\n\n/**\n * Replaces `{variable}` placeholders in an OpenAPI server URL with provided values.\n * Resolution order: `overrides[key]` → `variable.default` → left unreplaced.\n * Throws if an override value is not in the variable's `enum` list.\n *\n * @example\n * ```ts\n * resolveServerUrl(\n * { url: 'https://{env}.api.example.com', variables: { env: { default: 'dev', enum: ['dev', 'prod'] } } },\n * { env: 'prod' },\n * )\n * // 'https://prod.api.example.com'\n * ```\n */\nexport function resolveServerUrl(server: ServerObject, overrides?: Record<string, string>): string {\n if (!server.variables) {\n return server.url\n }\n\n let url = server.url\n for (const [key, variable] of Object.entries(server.variables)) {\n const value = overrides?.[key] ?? (variable.default != null ? String(variable.default) : undefined)\n if (value === undefined) {\n continue\n }\n\n if (variable.enum?.length && !variable.enum.some((e) => String(e) === value)) {\n throw new Error(`Invalid server variable value '${value}' for '${key}' when resolving ${server.url}. Valid values are: ${variable.enum.join(', ')}.`)\n }\n\n url = url.replaceAll(`{${key}}`, value)\n }\n\n return url\n}\n\n/**\n * Returns the Kubb `SchemaType` for a given OAS `format` string, or `null` if not found.\n * Formats not in `formatMap` (e.g., `int64`, `date-time`) are handled separately by parser options.\n */\nexport function getSchemaType(format: string): ast.SchemaType | null {\n return formatMap[format as keyof typeof formatMap] ?? null\n}\n\n/**\n * Converts an OAS primitive type string to its `PrimitiveSchemaType` equivalent.\n * Numeric types (`number`, `integer`, `bigint`) pass through unchanged. `boolean` maps to `'boolean'`. Everything else becomes `'string'`.\n */\nexport function getPrimitiveType(type: string | undefined): ast.PrimitiveSchemaType {\n if (type === 'number' || type === 'integer' || type === 'bigint') return type\n if (type === 'boolean') return 'boolean'\n\n return 'string'\n}\n\n/**\n * Narrows a content-type string to the `MediaType` union Kubb recognizes, or returns `null`.\n */\nexport function getMediaType(contentType: string): ast.MediaType | null {\n return Object.values(ast.mediaTypes).includes(contentType as ast.MediaType) ? (contentType as ast.MediaType) : null\n}\n\nexport type OperationsOptions = {\n contentType?: ContentType\n}\n\n/**\n * Returns all parameters for an operation, merging path-level and operation-level entries.\n * Operation-level parameters override path-level ones with the same `in:name` key.\n * `$ref` parameters resolve via `dereferenceWithRef` for backward compatibility.\n *\n * @example\n * ```ts\n * getParameters(document, operation)\n * // [{ name: 'petId', in: 'path', required: true, schema: { type: 'integer' } }]\n * ```\n */\nexport function getParameters(document: Document, operation: Operation): Array<ParameterObject> {\n const resolveParams = (params: unknown[]): Array<ParameterObject> =>\n params.map((p) => dereferenceWithRef(document, p)).filter((p): p is ParameterObject => !!p && typeof p === 'object' && 'in' in p && 'name' in p)\n\n const operationParams = resolveParams(operation.schema?.parameters || [])\n const pathItem = document.paths?.[operation.path]\n const pathLevelParams = resolveParams(pathItem && !isReference(pathItem) && pathItem.parameters ? pathItem.parameters : [])\n\n const paramMap = new Map<string, ParameterObject>()\n for (const p of pathLevelParams) {\n if (p.name && p.in) {\n paramMap.set(`${p.in}:${p.name}`, p)\n }\n }\n for (const p of operationParams) {\n if (p.name && p.in) {\n paramMap.set(`${p.in}:${p.name}`, p)\n }\n }\n\n return Array.from(paramMap.values())\n}\n\nfunction getResponseBody(responseBody: boolean | ResponseObject, contentType?: string): MediaTypeObject | false | [string, MediaTypeObject, ...string[]] {\n if (!responseBody) return false\n if (isReference(responseBody)) return false\n\n const body = responseBody as ResponseObject\n if (!body.content) return false\n\n if (contentType) {\n if (!(contentType in body.content)) return false\n return body.content[contentType]!\n }\n\n let availableContentType: string | undefined\n const contentTypes = Object.keys(body.content)\n for (const mt of contentTypes) {\n if (matchesMimeType.json(mt)) {\n availableContentType = mt\n break\n }\n }\n\n if (!availableContentType) {\n availableContentType = contentTypes[0]\n }\n\n if (availableContentType) {\n return [availableContentType, body.content[availableContentType]!, ...(body.description ? [body.description] : [])]\n }\n\n return false\n}\n\n/**\n * Returns the response schema for a given operation and HTTP status code.\n *\n * Returns an empty object `{}` when no response body schema is available.\n *\n * @example\n * ```ts\n * getResponseSchema(document, operation, 200) // SchemaObject\n * getResponseSchema(document, operation, '4XX') // {}\n * ```\n */\nexport function getResponseSchema(document: Document, operation: Operation, statusCode: string | number, options: OperationsOptions = {}): SchemaObject {\n if (operation.schema.responses) {\n const responses = operation.schema.responses\n for (const key in responses) {\n const schema = responses[key]\n if (schema && isReference(schema)) {\n responses[key] = resolveRef<any>(document, schema.$ref)\n }\n }\n }\n\n const responseBody = getResponseBody(operation.getResponseByStatusCode(statusCode), options.contentType)\n\n if (responseBody === false) {\n return {}\n }\n\n const schema = Array.isArray(responseBody) ? responseBody[1].schema : responseBody.schema\n\n if (!schema) {\n return {}\n }\n\n return dereferenceWithRef(document, schema)\n}\n\n/**\n * Returns the request body schema for an operation, or `null` when absent.\n *\n * @example\n * ```ts\n * getRequestSchema(document, operation) // SchemaObject | null\n * ```\n */\nexport function getRequestSchema(document: Document, operation: Operation, options: OperationsOptions = {}): SchemaObject | null {\n if (operation.schema.requestBody) {\n operation.schema.requestBody = dereferenceWithRef(document, operation.schema.requestBody)\n }\n\n const requestBody = operation.getRequestBody(options.contentType)\n\n if (requestBody === false) {\n return null\n }\n\n const schema = Array.isArray(requestBody) ? requestBody[1].schema : requestBody.schema\n\n if (!schema) {\n return null\n }\n\n return dereferenceWithRef(document, schema)\n}\n\n/**\n * The three component sections Kubb reads schemas from.\n */\ntype SchemaSourceMode = 'schemas' | 'responses' | 'requestBodies'\n\n/**\n * A schema annotated with its component section source and original name. Used by `resolveNameCollisions` for cross-source collision resolution.\n */\nexport type SchemaWithMetadata = {\n schema: SchemaObject\n source: SchemaSourceMode\n originalName: string\n}\n\nexport type GetSchemasOptions = {\n contentType?: ContentType\n}\n\nexport type GetSchemasResult = {\n schemas: Record<string, SchemaObject>\n nameMapping: Map<string, string>\n}\n\n/**\n * Flattens a keyword-only `allOf` into its parent schema.\n *\n * Only flattens when every member is a plain fragment — no `$ref` and no structural keywords\n * (see `structuralKeys`). Outer schema values take precedence over fragment values.\n * Returns `null` for a `null` input, and the original schema unchanged when flattening is unsafe.\n *\n * @example\n * ```ts\n * flattenSchema({ allOf: [{ description: 'A pet' }], type: 'object', properties: {} })\n * // { type: 'object', properties: {}, description: 'A pet' }\n *\n * flattenSchema({ allOf: [{ $ref: '#/components/schemas/Pet' }] })\n * // returned unchanged — contains a $ref\n * ```\n */\n/**\n * Returns `true` when `fragment` carries any JSON Schema keyword that makes it\n * structurally significant on its own (see `structuralKeys`).\n *\n * A fragment with a structural keyword can't be safely merged into a parent schema.\n */\nfunction hasStructuralKeywords(fragment: SchemaObject): boolean {\n for (const key in fragment) {\n if (structuralKeys.has(key as 'properties')) return true\n }\n return false\n}\n\nexport function flattenSchema(schema: SchemaObject | null): SchemaObject | null {\n if (!schema?.allOf || schema.allOf.length === 0) return schema ?? null\n\n const allOfFragments = schema.allOf as SchemaObject[]\n if (allOfFragments.some((item) => isRef(item))) return schema\n if (allOfFragments.some(hasStructuralKeywords)) return schema\n\n const merged: SchemaObject = { ...schema }\n delete merged.allOf\n\n for (const fragment of allOfFragments) {\n for (const [key, value] of Object.entries(fragment)) {\n if (merged[key as keyof typeof merged] === undefined) {\n merged[key as keyof typeof merged] = value\n }\n }\n }\n\n return merged\n}\n\n/**\n * Extracts the inline schema from a media-type `content` map.\n *\n * Prefers `preferredContentType` when given; otherwise uses the first key in the map.\n * Returns `null` when `content` is absent, the schema is missing, or the schema is a `$ref`.\n *\n * @example\n * ```ts\n * extractSchemaFromContent(operation.content, 'application/json')\n * // SchemaObject | null\n * ```\n */\nexport function extractSchemaFromContent(content: Record<string, unknown> | undefined, preferredContentType?: ContentType): SchemaObject | null {\n if (!content) return null\n\n const firstContentType = Object.keys(content)[0] ?? 'application/json'\n const targetContentType = preferredContentType ?? firstContentType\n const contentSchema = content[targetContentType] as { schema?: SchemaObject } | undefined\n const schema = contentSchema?.schema\n\n if (schema && '$ref' in schema) return null\n return schema ?? null\n}\n\n/**\n * Walks a schema tree and collects the names of all `#/components/schemas/<name>` `$ref`s.\n */\nfunction* collectRefs(schema: unknown): Generator<string, void, undefined> {\n if (Array.isArray(schema)) {\n for (const item of schema) yield* collectRefs(item)\n return\n }\n\n if (schema && typeof schema === 'object') {\n for (const key in schema) {\n const value = (schema as Record<string, unknown>)[key]\n if (!(key === '$ref' && typeof value === 'string')) {\n yield* collectRefs(value)\n continue\n }\n if (value.startsWith(SCHEMA_REF_PREFIX)) {\n const name = value.slice(SCHEMA_REF_PREFIX.length)\n if (name) yield name\n }\n }\n }\n}\n\n/**\n * Returns a copy of `schemas` topologically sorted by `$ref` dependency.\n *\n * Referenced schemas appear before the schemas that depend on them, so code generators\n * can emit types in the correct order. Cycles are silently skipped.\n *\n * @example\n * ```ts\n * const sorted = sortSchemas({ Order: orderSchema, Pet: petSchema })\n * // Pet appears before Order when Order.$ref points at Pet\n * ```\n */\nexport function sortSchemas(schemas: Record<string, SchemaObject>): Record<string, SchemaObject> {\n const deps = new Map<string, string[]>()\n\n for (const [name, schema] of Object.entries(schemas)) {\n deps.set(name, [...new Set(collectRefs(schema))])\n }\n\n const sorted: string[] = []\n const visited = new Set<string>()\n\n function visit(name: string, stack: Set<string>) {\n if (visited.has(name) || stack.has(name)) return\n stack.add(name)\n for (const child of deps.get(name) ?? []) {\n if (deps.has(child)) visit(child, stack)\n }\n stack.delete(name)\n visited.add(name)\n sorted.push(name)\n }\n\n for (const name of Object.keys(schemas)) {\n visit(name, new Set())\n }\n\n const result: Record<string, SchemaObject> = {}\n for (const name of sorted) result[name] = schemas[name]!\n return result\n}\n\nconst semanticSuffixes: Record<SchemaSourceMode, string> = {\n schemas: 'Schema',\n responses: 'Response',\n requestBodies: 'Request',\n}\n\nfunction getSemanticSuffix(source: SchemaSourceMode): string {\n return semanticSuffixes[source]\n}\n\nfunction resolveSchemaRef(document: Document, schema: SchemaObject): SchemaObject {\n if (!isReference(schema)) return schema\n const resolved = resolveRef<SchemaObject>(document, schema.$ref)\n return resolved && !isReference(resolved) ? resolved : schema\n}\n\n/**\n * Collects component schemas from one or more sources and resolves name collisions.\n *\n * Sources default to `['schemas', 'requestBodies', 'responses']`. Returned schemas are\n * topologically sorted by `$ref` dependency so generators emit types in the correct order.\n *\n * When two or more schemas normalize to the same PascalCase name:\n * - Same source → numeric suffix (`2`, `3`, …).\n * - Different sources → semantic suffix (`Schema`, `Response`, `Request`).\n *\n * @example\n * ```ts\n * const { schemas, nameMapping } = getSchemas(document, { contentType: 'application/json' })\n * ```\n */\nexport function getSchemas(document: Document, { contentType }: GetSchemasOptions): GetSchemasResult {\n const components = document.components\n\n const candidates: SchemaWithMetadata[] = [\n ...Object.entries((components?.schemas as Record<string, SchemaObject>) ?? {}).map(([name, schema]) => ({\n schema: resolveSchemaRef(document, schema),\n source: 'schemas' as const,\n originalName: name,\n })),\n ...(['responses', 'requestBodies'] as const).flatMap((source) =>\n Object.entries(components?.[source] ?? {}).flatMap(([name, item]) => {\n const schema = extractSchemaFromContent((item as { content?: Record<string, unknown> }).content, contentType)\n return schema\n ? [\n {\n schema: resolveSchemaRef(document, schema),\n source,\n originalName: name,\n },\n ]\n : []\n }),\n ),\n ]\n\n const normalizedNames = new Map<string, SchemaWithMetadata[]>()\n for (const item of candidates) {\n const key = pascalCase(item.originalName)\n const bucket = normalizedNames.get(key) ?? []\n bucket.push(item)\n normalizedNames.set(key, bucket)\n }\n\n const schemas: Record<string, SchemaObject> = {}\n const nameMapping = new Map<string, string>()\n\n for (const [, items] of normalizedNames) {\n const isSingle = items.length === 1\n let hasMultipleSources = false\n if (!isSingle) {\n const firstSource = items[0]!.source\n for (let i = 1; i < items.length; i++) {\n if (items[i]!.source !== firstSource) {\n hasMultipleSources = true\n break\n }\n }\n }\n\n items.forEach((item, index) => {\n const suffix = isSingle ? '' : hasMultipleSources ? getSemanticSuffix(item.source) : index === 0 ? '' : String(index + 1)\n const uniqueName = item.originalName + suffix\n schemas[uniqueName] = item.schema\n nameMapping.set(`#/components/${item.source}/${item.originalName}`, uniqueName)\n })\n }\n\n return { schemas: sortSchemas(schemas), nameMapping }\n}\n\n/**\n * Resolves the AST type descriptor for a date/time format, honoring the `dateType` option.\n * Returns `null` when `dateType: false`, signalling the format should fall through to `string`.\n */\nexport function getDateType(\n options: ast.ParserOptions,\n format: 'date-time' | 'date' | 'time',\n): { type: 'datetime'; offset?: boolean; local?: boolean } | { type: 'date' | 'time'; representation: 'date' | 'string' } | null {\n if (!options.dateType) {\n return null\n }\n\n if (format === 'date-time') {\n if (options.dateType === 'date') {\n return { type: 'date', representation: 'date' }\n }\n if (options.dateType === 'stringOffset') {\n return { type: 'datetime', offset: true }\n }\n if (options.dateType === 'stringLocal') {\n return { type: 'datetime', local: true }\n }\n return { type: 'datetime', offset: false }\n }\n\n if (format === 'date') {\n return {\n type: 'date',\n representation: options.dateType === 'date' ? 'date' : 'string',\n }\n }\n\n // time\n return {\n type: 'time',\n representation: options.dateType === 'date' ? 'date' : 'string',\n }\n}\n\n/**\n * Collects the shared metadata fields passed to every `createSchema` call.\n */\nexport function buildSchemaNode(schema: SchemaObject, name: string | null | undefined, nullable: true | undefined, defaultValue: unknown) {\n return {\n name,\n nullable,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n readOnly: schema.readOnly,\n writeOnly: schema.writeOnly,\n default: defaultValue,\n example: schema.example,\n format: schema.format,\n } as const\n}\n\n/**\n * Returns all request body content type keys for an operation.\n *\n * The requestBody is dereferenced **in-place** when it is a `$ref` — the same mutation\n * that `getRequestSchema` already performs — so that the returned list accurately reflects\n * the available content types even for referenced bodies.\n *\n * @example\n * ```ts\n * getRequestBodyContentTypes(document, operation)\n * // ['application/json', 'multipart/form-data']\n * ```\n */\nexport function getRequestBodyContentTypes(document: Document, operation: Operation): string[] {\n if (operation.schema.requestBody) {\n operation.schema.requestBody = dereferenceWithRef(document, operation.schema.requestBody)\n }\n\n const body = operation.schema.requestBody as { content?: Record<string, unknown> } | undefined\n if (!body) return []\n\n // dereferenceWithRef keeps $ref but spreads all resolved fields (including `content`).\n // Do not bail out on isReference — the content is already present on the merged object.\n return body.content ? Object.keys(body.content) : []\n}\n","import { URLPath } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport BaseOas from 'oas'\nimport { DEFAULT_PARSER_OPTIONS, enumExtensionKeys, SCHEMA_REF_PREFIX, typeOptionMap } from './constants.ts'\nimport { isDiscriminator, isNullable, isReference } from './guards.ts'\nimport { resolveRef } from './refs.ts'\nimport {\n buildSchemaNode,\n flattenSchema,\n getDateType,\n getMediaType,\n getParameters,\n getPrimitiveType,\n getRequestBodyContentTypes,\n getRequestSchema,\n getResponseSchema,\n getSchemas,\n getSchemaType,\n} from './resolvers.ts'\nimport type { ContentType, Document, Operation, ReferenceObject, SchemaObject } from './types.ts'\n\n/**\n * Parser context holding the raw OpenAPI document and optional content-type override.\n *\n * Passed to schema and operation converters to access the full specification\n * and handle content negotiation when multiple media types are available.\n */\nexport type OasParserContext = {\n document: Document\n contentType?: ContentType\n}\n\n/**\n * The object returned by {@link createSchemaParser}.\n * Contains parser functions bound to a specific document.\n */\nexport type SchemaParser = {\n parseSchema: (entry: { schema: SchemaObject; name?: string | null }, options?: Partial<ast.ParserOptions>) => ast.SchemaNode\n parseOperation: (options: ast.ParserOptions, operation: Operation) => ast.OperationNode\n parseParameter: (options: ast.ParserOptions, param: Record<string, unknown>) => ast.ParameterNode\n}\n\n/**\n * Pre-computed per-schema context passed to every schema converter.\n *\n * Centralizes schema derivations (type resolution, defaults, options) to avoid repeated\n * computation across all conversion branches. The `type` field is normalized from OAS 3.1\n * multi-type arrays to a single string.\n */\ntype SchemaContext = {\n schema: SchemaObject\n name: string | null | undefined\n nullable: true | undefined\n defaultValue: unknown\n /**\n * Normalized single type string (first element when OAS 3.1 multi-type array).\n */\n type: string | undefined\n rawOptions: Partial<ast.ParserOptions> | undefined\n options: ast.ParserOptions\n}\n\n/**\n * Normalizes malformed `{ type: 'array', enum: [...] }` schemas by moving enum values into items.\n *\n * This pattern violates the OpenAPI spec but appears in real specs. The fix moves enum values\n * from the array to its items sub-schema, making them valid for downstream processing.\n *\n * @note This is a defensive measure for robustness with non-compliant specs.\n */\nfunction normalizeArrayEnum(schema: SchemaObject): SchemaObject {\n const isItemsObject = typeof schema.items === 'object' && !Array.isArray(schema.items)\n const normalizedItems: SchemaObject = {\n ...(isItemsObject ? (schema.items as SchemaObject) : {}),\n enum: schema.enum,\n }\n const { enum: _enum, ...schemaWithoutEnum } = schema\n\n return { ...schemaWithoutEnum, items: normalizedItems } as SchemaObject\n}\n\n/**\n * Factory function that creates schema and operation converters for a given OpenAPI context.\n *\n * Returns closures that share mutable state (`resolvingRefs` set for cycle detection).\n * Each converter branch (`convertRef`, `convertAllOf`, etc.) mutually recursively calls `parseSchema`,\n * made possible by hoisting of function declarations.\n *\n * @internal\n */\nexport function createSchemaParser(ctx: OasParserContext) {\n const document = ctx.document\n\n // Branch handlers — each converts one OAS schema pattern to a SchemaNode.\n\n /**\n * Tracks `$ref` paths that are currently being resolved to prevent infinite\n * recursion when schemas contain circular references (e.g. `Pet → parent → Pet`).\n */\n const resolvingRefs = new Set<string>()\n\n /**\n * Cache of already-resolved `$ref` schemas within this parser instance.\n *\n * Without this, the same referenced schema (e.g. `customer`) is fully re-expanded\n * every time it appears as a `$ref` in a different parent schema. In heavily\n * cross-referenced specs like Stripe (~1 400 schemas), this causes exponential\n * blowup — `customer` alone may be referenced from dozens of top-level schemas,\n * each triggering a fresh recursive expansion of its entire sub-tree.\n *\n * Memoizing by `$ref` path reduces the overall work from O(2^depth) to O(N)\n * where N is the number of unique schema names.\n */\n const resolvedRefCache = new Map<string, ast.SchemaNode | null>()\n\n /**\n * Converts a `$ref` schema into a `RefSchemaNode`.\n *\n * The resolved schema is stored in `node.schema`. Usage-site sibling fields\n * (description, readOnly, nullable, etc.) are stored directly on the ref node.\n * Use `syncSchemaRef(node)` in printers to get a merged view of both.\n * Circular refs are detected via `resolvingRefs` and leave `schema` as `undefined`.\n */\n function convertRef({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n let resolvedSchema: ast.SchemaNode | null = null\n const refPath = schema.$ref\n if (refPath && !resolvingRefs.has(refPath)) {\n if (!resolvedRefCache.has(refPath)) {\n try {\n const referenced = resolveRef<SchemaObject>(document, refPath)\n if (referenced) {\n resolvingRefs.add(refPath)\n resolvedSchema = parseSchema({ schema: referenced }, rawOptions)\n resolvingRefs.delete(refPath)\n }\n } catch {\n // Ref cannot be resolved in this document (e.g. unit tests with minimal documents).\n }\n resolvedRefCache.set(refPath, resolvedSchema)\n }\n resolvedSchema = resolvedRefCache.get(refPath) ?? null\n }\n\n return ast.createSchema({\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n type: 'ref',\n name: ast.extractRefName(schema.$ref!),\n ref: schema.$ref,\n schema: resolvedSchema,\n })\n }\n\n /**\n * Converts an `allOf` schema into a flattened node or an `IntersectionSchemaNode`.\n */\n function convertAllOf({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n if (\n schema.allOf!.length === 1 &&\n !schema.properties &&\n !(Array.isArray(schema.required) && schema.required.length) &&\n schema.additionalProperties === undefined\n ) {\n const [memberSchema] = schema.allOf as Array<SchemaObject | ReferenceObject>\n const memberNode = parseSchema({ schema: memberSchema! as SchemaObject, name: null }, rawOptions)\n const { kind: _kind, ...memberNodeProps } = memberNode\n const mergedNullable = nullable || memberNode.nullable || undefined\n const mergedDefault = schema.default === null && mergedNullable ? undefined : (schema.default ?? memberNode.default)\n\n return ast.createSchema({\n ...memberNodeProps,\n name,\n title: schema.title ?? memberNode.title,\n description: schema.description ?? memberNode.description,\n deprecated: schema.deprecated ?? memberNode.deprecated,\n nullable: mergedNullable,\n readOnly: schema.readOnly ?? memberNode.readOnly,\n writeOnly: schema.writeOnly ?? memberNode.writeOnly,\n default: mergedDefault,\n example: schema.example ?? memberNode.example,\n pattern: schema.pattern ?? ('pattern' in memberNode ? memberNode.pattern : undefined),\n format: schema.format ?? memberNode.format,\n } as ast.DistributiveOmit<ast.SchemaNode, 'kind'>)\n }\n\n const filteredDiscriminantValues: Array<{\n propertyName: string\n value: string\n }> = []\n const allOfMembers: Array<ast.SchemaNode> = (schema.allOf as Array<SchemaObject | ReferenceObject>)\n .filter((item) => {\n if (!isReference(item) || !name) return true\n const deref = resolveRef<SchemaObject>(document, item.$ref)\n if (!deref || !isDiscriminator(deref)) return true\n const parentUnion = deref.oneOf ?? deref.anyOf\n if (!parentUnion) return true\n const childRef = `${SCHEMA_REF_PREFIX}${name}`\n const inOneOf = parentUnion.some((oneOfItem) => isReference(oneOfItem) && oneOfItem.$ref === childRef)\n const inMapping = Object.values(deref.discriminator.mapping ?? {}).some((v) => v === childRef)\n if (inOneOf || inMapping) {\n const discriminatorValue = ast.findDiscriminator(deref.discriminator.mapping, childRef)\n if (discriminatorValue) {\n filteredDiscriminantValues.push({\n propertyName: deref.discriminator.propertyName,\n value: discriminatorValue,\n })\n }\n return false\n }\n return true\n })\n .map((s) => parseSchema({ schema: s as SchemaObject }, rawOptions))\n\n const syntheticStart = allOfMembers.length\n\n if (Array.isArray(schema.required) && schema.required.length) {\n const outerKeys = schema.properties ? new Set(Object.keys(schema.properties)) : new Set<string>()\n const missingRequired = schema.required.filter((key) => !outerKeys.has(key))\n\n if (missingRequired.length) {\n const resolvedMembers = (schema.allOf as Array<SchemaObject | ReferenceObject>).flatMap((item) => {\n if (!isReference(item)) return [item as SchemaObject]\n const deref = resolveRef<SchemaObject>(document, item.$ref)\n return deref && !isReference(deref) ? [deref] : []\n })\n\n for (const key of missingRequired) {\n for (const resolved of resolvedMembers) {\n if (resolved.properties?.[key]) {\n allOfMembers.push(\n parseSchema(\n {\n schema: {\n properties: { [key]: resolved.properties[key] },\n required: [key],\n } as SchemaObject,\n },\n rawOptions,\n ),\n )\n break\n }\n }\n }\n }\n }\n\n if (schema.properties) {\n const { allOf: _allOf, ...schemaWithoutAllOf } = schema\n allOfMembers.push(parseSchema({ schema: schemaWithoutAllOf }, rawOptions))\n }\n\n for (const { propertyName, value } of filteredDiscriminantValues) {\n allOfMembers.push(ast.createDiscriminantNode({ propertyName, value }))\n }\n\n return ast.createSchema({\n type: 'intersection',\n members: [...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(0, syntheticStart)), ...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(syntheticStart))],\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `oneOf` / `anyOf` schema into a `UnionSchemaNode`.\n */\n function convertUnion({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n function pickDiscriminatorPropertyNode(node: ast.SchemaNode, propertyName: string): ast.SchemaNode | null {\n const objectNode = ast.narrowSchema(node, 'object')\n const discriminatorProperty = objectNode?.properties?.find((property) => property.name === propertyName)\n\n if (!discriminatorProperty) {\n return null\n }\n\n return ast.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [discriminatorProperty],\n })\n }\n\n const unionMembers = [...(schema.oneOf ?? []), ...(schema.anyOf ?? [])]\n const strategy: 'one' | 'any' = schema.oneOf ? 'one' : 'any'\n const unionBase = {\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n discriminatorPropertyName: isDiscriminator(schema) ? schema.discriminator.propertyName : undefined,\n strategy,\n }\n const discriminator = isDiscriminator(schema) ? schema.discriminator : undefined\n const sharedPropertiesNode = schema.properties\n ? (() => {\n const { oneOf: _oneOf, anyOf: _anyOf, ...schemaWithoutUnion } = schema\n const memberBaseSchema: SchemaObject = discriminator\n ? (Object.fromEntries(Object.entries(schemaWithoutUnion).filter(([key]) => key !== 'discriminator')) as SchemaObject)\n : schemaWithoutUnion\n return parseSchema({ schema: memberBaseSchema, name }, rawOptions)\n })()\n : undefined\n\n if (sharedPropertiesNode || discriminator?.mapping) {\n const members = unionMembers.map((s) => {\n const ref = isReference(s) ? s.$ref : undefined\n const discriminatorValue = ast.findDiscriminator(discriminator?.mapping, ref)\n const memberNode = parseSchema({ schema: s as SchemaObject }, rawOptions)\n\n if (!discriminatorValue || !discriminator) {\n return memberNode\n }\n\n const narrowedDiscriminatorNode = sharedPropertiesNode\n ? pickDiscriminatorPropertyNode(\n ast.setDiscriminatorEnum({\n node: sharedPropertiesNode,\n propertyName: discriminator.propertyName,\n values: [discriminatorValue],\n }),\n discriminator.propertyName,\n )\n : undefined\n\n return ast.createSchema({\n type: 'intersection',\n members: [\n memberNode,\n narrowedDiscriminatorNode ??\n ast.createDiscriminantNode({\n propertyName: discriminator.propertyName,\n value: discriminatorValue,\n }),\n ],\n })\n })\n\n const unionNode = ast.createSchema({\n type: 'union',\n ...unionBase,\n members,\n })\n\n if (!sharedPropertiesNode) {\n return unionNode\n }\n\n return ast.createSchema({\n type: 'intersection',\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n members: [unionNode, sharedPropertiesNode],\n })\n }\n\n return ast.createSchema({\n type: 'union',\n ...unionBase,\n members: ast.simplifyUnion(unionMembers.map((s) => parseSchema({ schema: s as SchemaObject }, rawOptions))),\n })\n }\n\n /**\n * Converts an OAS 3.1 `const` schema into a null scalar or a single-value `EnumSchemaNode`.\n */\n function convertConst({ schema, name, nullable, defaultValue }: SchemaContext): ast.SchemaNode {\n const constValue = schema.const\n\n if (constValue === null) {\n return ast.createSchema({\n type: 'null',\n primitive: 'null',\n name,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n format: schema.format,\n })\n }\n\n const constPrimitive = getPrimitiveType(typeof constValue === 'number' ? 'number' : typeof constValue === 'boolean' ? 'boolean' : 'string')\n return ast.createSchema({\n type: 'enum',\n primitive: constPrimitive,\n enumValues: [constValue as string | number | boolean],\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a format-annotated schema into a special-type `SchemaNode`.\n * Returns `null` when the format should fall through to string handling (`dateType: false`).\n */\n function convertFormat({ schema, name, nullable, defaultValue, options }: SchemaContext): ast.SchemaNode | null {\n const base = buildSchemaNode(schema, name, nullable, defaultValue)\n\n if (schema.format === 'int64') {\n return ast.createSchema({\n type: options.integerType === 'bigint' ? 'bigint' : 'integer',\n primitive: 'integer',\n ...base,\n min: schema.minimum,\n max: schema.maximum,\n exclusiveMinimum: typeof schema.exclusiveMinimum === 'number' ? schema.exclusiveMinimum : undefined,\n exclusiveMaximum: typeof schema.exclusiveMaximum === 'number' ? schema.exclusiveMaximum : undefined,\n })\n }\n\n if (schema.format === 'date-time' || schema.format === 'date' || schema.format === 'time') {\n const dateType = getDateType(options, schema.format)\n if (!dateType) return null\n\n if (dateType.type === 'datetime') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'datetime',\n offset: dateType.offset,\n local: dateType.local,\n })\n }\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: dateType.type,\n representation: dateType.representation,\n })\n }\n\n const specialType = getSchemaType(schema.format!)\n if (!specialType) return null\n\n const specialPrimitive: ast.PrimitiveSchemaType = specialType === 'number' || specialType === 'integer' || specialType === 'bigint' ? specialType : 'string'\n\n if (specialType === 'number' || specialType === 'integer' || specialType === 'bigint') {\n return ast.createSchema({\n ...base,\n primitive: specialPrimitive,\n type: specialType,\n })\n }\n if (specialType === 'url') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'url',\n min: schema.minLength,\n max: schema.maxLength,\n })\n }\n if (specialType === 'ipv4') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'ipv4',\n })\n }\n if (specialType === 'ipv6') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'ipv6',\n })\n }\n if (specialType === 'uuid' || specialType === 'email') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: specialType,\n min: schema.minLength,\n max: schema.maxLength,\n })\n }\n\n return ast.createSchema({\n ...base,\n primitive: specialPrimitive,\n type: specialType as ast.ScalarSchemaType,\n })\n }\n\n /**\n * Converts an `enum` schema into an `EnumSchemaNode`.\n */\n function convertEnum({ schema, name, nullable, type, rawOptions }: SchemaContext): ast.SchemaNode {\n if (type === 'array') {\n return parseSchema({ schema: normalizeArrayEnum(schema), name }, rawOptions)\n }\n\n const nullInEnum = schema.enum!.includes(null)\n const filteredValues = (nullInEnum ? schema.enum!.filter((v) => v !== null) : schema.enum!) as Array<string | number | boolean>\n const enumNullable = nullable || nullInEnum || undefined\n const enumDefault = schema.default === null && enumNullable ? undefined : schema.default\n const enumPrimitive = getPrimitiveType(type)\n\n const enumBase = {\n type: 'enum' as const,\n primitive: enumPrimitive,\n name,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n nullable: enumNullable,\n readOnly: schema.readOnly,\n writeOnly: schema.writeOnly,\n default: enumDefault,\n example: schema.example,\n format: schema.format,\n }\n\n const extensionKey = enumExtensionKeys.find((key) => key in schema)\n if (extensionKey || enumPrimitive === 'number' || enumPrimitive === 'integer' || enumPrimitive === 'boolean') {\n const enumPrimitiveType = (enumPrimitive === 'number' || enumPrimitive === 'integer' ? 'number' : enumPrimitive === 'boolean' ? 'boolean' : 'string') as\n | 'number'\n | 'boolean'\n | 'string'\n const rawEnumNames = extensionKey ? ((schema as Record<string, unknown>)[extensionKey] as Array<string | number>) : undefined\n const uniqueValues = [...new Set(filteredValues)]\n const seenNames = new Set<string>()\n\n return ast.createSchema({\n ...enumBase,\n primitive: enumPrimitiveType,\n namedEnumValues: uniqueValues\n .map((value, index) => ({\n name: String(rawEnumNames?.[index] ?? value),\n value,\n primitive: enumPrimitiveType,\n }))\n .filter((entry) => {\n if (seenNames.has(entry.name)) return false\n seenNames.add(entry.name)\n return true\n }),\n })\n }\n\n return ast.createSchema({\n ...enumBase,\n enumValues: [...new Set(filteredValues)],\n })\n }\n\n /**\n * Converts an object-like schema into an `ObjectSchemaNode`.\n */\n function convertObject({ schema, name, nullable, defaultValue, rawOptions, options }: SchemaContext): ast.SchemaNode {\n const properties: Array<ast.PropertyNode> = schema.properties\n ? Object.entries(schema.properties).map(([propName, propSchema]) => {\n const required = Array.isArray(schema.required) ? schema.required.includes(propName) : !!schema.required\n const resolvedPropSchema = propSchema as SchemaObject\n const propNullable = isNullable(resolvedPropSchema)\n\n const resolvedChildName = ast.childName(name, propName)\n const propNode = parseSchema({ schema: resolvedPropSchema, name: resolvedChildName }, rawOptions)\n const schemaNode = (() => {\n const node = ast.setEnumName(propNode, name, propName, options.enumSuffix)\n const tupleNode = ast.narrowSchema(node, 'tuple')\n if (tupleNode?.items) {\n const namedItems = tupleNode.items.map((item) => ast.setEnumName(item, name, propName, options.enumSuffix))\n if (namedItems.some((item, i) => item !== tupleNode.items![i])) {\n return { ...tupleNode, items: namedItems }\n }\n }\n return node\n })()\n\n return ast.createProperty({\n name: propName,\n schema: {\n ...schemaNode,\n nullable: schemaNode.type === 'null' ? undefined : propNullable || undefined,\n },\n required,\n })\n })\n : []\n\n const additionalProperties = schema.additionalProperties\n const additionalPropertiesNode: ast.SchemaNode | boolean | undefined = (() => {\n if (additionalProperties === true) return true\n if (additionalProperties === false) return false\n if (additionalProperties && Object.keys(additionalProperties).length > 0) {\n return parseSchema({ schema: additionalProperties as SchemaObject }, rawOptions)\n }\n if (additionalProperties) return ast.createSchema({ type: typeOptionMap.get(options.unknownType)! })\n return undefined\n })()\n\n const rawPatternProperties = 'patternProperties' in schema ? schema.patternProperties : undefined\n\n const patternProperties = rawPatternProperties\n ? Object.fromEntries(\n Object.entries(rawPatternProperties).map(([pattern, patternSchema]) => [\n pattern,\n patternSchema === true || (typeof patternSchema === 'object' && Object.keys(patternSchema).length === 0)\n ? ast.createSchema({\n type: typeOptionMap.get(options.unknownType)!,\n })\n : parseSchema({ schema: patternSchema as SchemaObject }, rawOptions),\n ]),\n )\n : undefined\n\n const objectNode: ast.SchemaNode = ast.createSchema({\n type: 'object',\n primitive: 'object',\n properties,\n additionalProperties: additionalPropertiesNode,\n patternProperties,\n minProperties: schema.minProperties,\n maxProperties: schema.maxProperties,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n\n if (isDiscriminator(schema) && schema.discriminator.mapping) {\n const discPropName = schema.discriminator.propertyName\n const values = Object.keys(schema.discriminator.mapping)\n const enumName = name ? ast.enumPropName(name, discPropName, options.enumSuffix) : undefined\n return ast.setDiscriminatorEnum({\n node: objectNode,\n propertyName: discPropName,\n values,\n enumName,\n })\n }\n\n return objectNode\n }\n\n /**\n * Converts an OAS 3.1 `prefixItems` tuple into a `TupleSchemaNode`.\n */\n function convertTuple({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n const tupleItems = (schema.prefixItems ?? []).map((item) => parseSchema({ schema: item as SchemaObject }, rawOptions))\n const rest = schema.items ? parseSchema({ schema: schema.items as SchemaObject }, rawOptions) : ast.createSchema({ type: 'any' })\n\n return ast.createSchema({\n type: 'tuple',\n primitive: 'array',\n items: tupleItems,\n rest,\n min: schema.minItems,\n max: schema.maxItems,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'array'` schema into an `ArraySchemaNode`.\n */\n function convertArray({ schema, name, nullable, defaultValue, rawOptions, options }: SchemaContext): ast.SchemaNode {\n const rawItems = schema.items as SchemaObject | undefined\n const itemName = rawItems?.enum?.length && name ? ast.enumPropName(null, name, options.enumSuffix) : undefined\n const items = rawItems ? [parseSchema({ schema: rawItems, name: itemName }, rawOptions)] : []\n\n return ast.createSchema({\n type: 'array',\n primitive: 'array',\n items,\n min: schema.minItems,\n max: schema.maxItems,\n unique: schema.uniqueItems ?? undefined,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'string'` schema into a `StringSchemaNode`.\n */\n function convertString({ schema, name, nullable, defaultValue }: SchemaContext): ast.SchemaNode {\n return ast.createSchema({\n type: 'string',\n primitive: 'string',\n min: schema.minLength,\n max: schema.maxLength,\n pattern: schema.pattern,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'number'` or `type: 'integer'` schema.\n */\n function convertNumeric({ schema, name, nullable, defaultValue }: SchemaContext, type: 'number' | 'integer'): ast.SchemaNode {\n return ast.createSchema({\n type,\n primitive: type,\n min: schema.minimum,\n max: schema.maximum,\n exclusiveMinimum: typeof schema.exclusiveMinimum === 'number' ? schema.exclusiveMinimum : undefined,\n exclusiveMaximum: typeof schema.exclusiveMaximum === 'number' ? schema.exclusiveMaximum : undefined,\n multipleOf: schema.multipleOf,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'boolean'` schema.\n */\n function convertBoolean({ schema, name, nullable, defaultValue }: SchemaContext): ast.SchemaNode {\n return ast.createSchema({\n type: 'boolean',\n primitive: 'boolean',\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts an explicit `type: 'null'` schema.\n */\n function convertNull({ schema, name, nullable }: SchemaContext): ast.SchemaNode {\n return ast.createSchema({\n type: 'null',\n primitive: 'null',\n name,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n nullable,\n format: schema.format,\n })\n }\n\n /**\n * Central dispatcher that converts an OAS `SchemaObject` into a `SchemaNode`.\n *\n * Dispatch order (first match wins): `$ref` → `allOf` → `oneOf`/`anyOf` → `const` → `format`\n * → octet-stream blob → multi-type array → constraint-inferred type → `enum` → object/array/tuple/scalar\n * → empty-schema fallback (`emptySchemaType` option).\n */\n function parseSchema({ schema, name }: { schema: SchemaObject; name?: string | null }, rawOptions?: Partial<ast.ParserOptions>): ast.SchemaNode {\n const options: ast.ParserOptions = {\n ...DEFAULT_PARSER_OPTIONS,\n ...rawOptions,\n }\n const flattenedSchema = flattenSchema(schema)\n if (flattenedSchema && flattenedSchema !== schema) {\n return parseSchema({ schema: flattenedSchema, name }, rawOptions)\n }\n\n const nullable = isNullable(schema) || undefined\n const defaultValue = schema.default === null && nullable ? undefined : schema.default\n const type = Array.isArray(schema.type) ? schema.type[0] : schema.type\n\n const ctx: SchemaContext = {\n schema,\n name,\n nullable,\n defaultValue,\n type,\n rawOptions,\n options,\n }\n\n if (isReference(schema)) return convertRef(ctx)\n\n if (schema.allOf?.length) return convertAllOf(ctx)\n const unionMembers = [...(schema.oneOf ?? []), ...(schema.anyOf ?? [])]\n if (unionMembers.length) return convertUnion(ctx)\n\n if ('const' in schema && schema.const !== undefined) return convertConst(ctx)\n\n if (schema.format) {\n const formatResult = convertFormat(ctx)\n if (formatResult) return formatResult\n }\n\n if (schema.type === 'string' && schema.contentMediaType === 'application/octet-stream') {\n return ast.createSchema({\n type: 'blob',\n primitive: 'string',\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n if (Array.isArray(schema.type) && schema.type.length > 1) {\n const nonNullTypes = schema.type.filter((t) => t !== 'null') as string[]\n const arrayNullable = schema.type.includes('null') || nullable || undefined\n\n if (nonNullTypes.length > 1) {\n return ast.createSchema({\n type: 'union',\n members: nonNullTypes.map((t) => parseSchema({ schema: { ...schema, type: t } as SchemaObject, name }, rawOptions)),\n ...buildSchemaNode(schema, name, arrayNullable, defaultValue),\n })\n }\n }\n\n if (!type) {\n if (schema.minLength !== undefined || schema.maxLength !== undefined || schema.pattern !== undefined) {\n return convertString(ctx)\n }\n if (schema.minimum !== undefined || schema.maximum !== undefined) {\n return convertNumeric(ctx, 'number')\n }\n }\n\n if (schema.enum?.length) return convertEnum(ctx)\n if (type === 'object' || schema.properties || schema.additionalProperties || 'patternProperties' in schema) return convertObject(ctx)\n if ('prefixItems' in schema) return convertTuple(ctx)\n if (type === 'array' || 'items' in schema) return convertArray(ctx)\n if (type === 'string') return convertString(ctx)\n if (type === 'number') return convertNumeric(ctx, 'number')\n if (type === 'integer') return convertNumeric(ctx, 'integer')\n if (type === 'boolean') return convertBoolean(ctx)\n if (type === 'null') return convertNull(ctx)\n\n const emptyType = typeOptionMap.get(options.emptySchemaType)!\n return ast.createSchema({\n type: emptyType as ast.ScalarSchemaType,\n name,\n title: schema.title,\n description: schema.description,\n format: schema.format,\n })\n }\n\n /**\n * Converts a dereferenced OAS parameter object into a `ParameterNode`.\n */\n function parseParameter(options: ast.ParserOptions, param: Record<string, unknown>): ast.ParameterNode {\n const required = (param['required'] as boolean | undefined) ?? false\n\n const schema: ast.SchemaNode = param['schema']\n ? parseSchema({ schema: param['schema'] as SchemaObject }, options)\n : ast.createSchema({ type: typeOptionMap.get(options.unknownType)! })\n\n return ast.createParameter({\n name: param['name'] as string,\n in: param['in'] as ast.ParameterLocation,\n schema: {\n ...schema,\n description: (param['description'] as string | undefined) ?? schema.description,\n },\n required,\n })\n }\n\n /**\n * Reads the inline `requestBody` metadata (description / required) that OAS exposes\n * outside the schema itself. Returns an empty object when the request body is missing or a `$ref`.\n */\n function getRequestBodyMeta(operation: Operation): {\n description?: string\n required: boolean\n } {\n const body = operation.schema.requestBody as { description?: string; required?: boolean } | undefined\n if (!body) return { required: false }\n\n // After getRequestBodyContentTypes has run, body may still carry $ref but the\n // resolved fields (description, required, content) are already spread onto it.\n return {\n description: body.description,\n required: body.required === true,\n }\n }\n\n /**\n * Reads the inline response object (not a `$ref`) and returns its description plus its `content` map.\n */\n function getResponseMeta(responseObj: unknown): {\n description?: string\n content?: Record<string, unknown>\n } {\n if (typeof responseObj !== 'object' || responseObj === null || Array.isArray(responseObj)) return {}\n\n const inline = responseObj as {\n description?: string\n content?: Record<string, unknown>\n }\n return { description: inline.description, content: inline.content }\n }\n\n /**\n * Collects property names whose schema has a truthy boolean flag (`readOnly` or `writeOnly`).\n * `$ref` entries are skipped since their flags live on the dereferenced target.\n */\n function collectPropertyKeysByFlag(schema: SchemaObject | null, flag: 'readOnly' | 'writeOnly'): string[] | null {\n if (!schema?.properties) return null\n\n const keys: string[] = []\n for (const key in schema.properties) {\n const prop = schema.properties[key]\n if (prop && !isReference(prop) && (prop as Record<string, unknown>)[flag]) {\n keys.push(key)\n }\n }\n return keys.length ? keys : null\n }\n\n /**\n * Converts an OAS `Operation` into an `OperationNode`.\n */\n function parseOperation(options: ast.ParserOptions, operation: Operation): ast.OperationNode {\n const parameters: Array<ast.ParameterNode> = getParameters(document, operation).map((param) =>\n parseParameter(options, param as unknown as Record<string, unknown>),\n )\n\n // Determine which content types to include in requestBody.content.\n // When a global contentType is configured, restrict to that single type.\n // Otherwise include every content type declared in the spec.\n const allContentTypes = ctx.contentType ? [ctx.contentType] : getRequestBodyContentTypes(document, operation)\n\n const requestBodyMeta = getRequestBodyMeta(operation)\n\n const content = allContentTypes.flatMap((ct) => {\n const schema = getRequestSchema(document, operation, { contentType: ct })\n if (!schema) return []\n return [\n {\n contentType: ct,\n schema: ast.syncOptionality(parseSchema({ schema }, options), requestBodyMeta.required),\n keysToOmit: collectPropertyKeysByFlag(schema, 'readOnly'),\n },\n ]\n })\n\n const requestBody =\n content.length > 0 || requestBodyMeta.description\n ? {\n description: requestBodyMeta.description,\n required: requestBodyMeta.required || undefined,\n content: content.length > 0 ? content : undefined,\n }\n : undefined\n\n const responses: Array<ast.ResponseNode> = operation.getResponseStatusCodes().map((statusCode) => {\n const responseObj = operation.getResponseByStatusCode(statusCode)\n const responseSchema = getResponseSchema(document, operation, statusCode, { contentType: ctx.contentType })\n\n const schema =\n responseSchema && Object.keys(responseSchema).length > 0\n ? parseSchema({ schema: responseSchema }, options)\n : ast.createSchema({\n type: typeOptionMap.get(options.emptySchemaType)!,\n })\n\n const { description, content } = getResponseMeta(responseObj)\n const mediaType = content ? getMediaType(Object.keys(content)[0] ?? '') : getMediaType(operation.contentType ?? '')\n\n return ast.createResponse({\n statusCode: statusCode as ast.StatusCode,\n description,\n schema,\n mediaType,\n keysToOmit: collectPropertyKeysByFlag(responseSchema, 'writeOnly'),\n })\n })\n\n const urlPath = new URLPath(operation.path)\n\n return ast.createOperation({\n operationId: operation.getOperationId(),\n method: operation.method.toUpperCase() as ast.HttpMethod,\n path: urlPath.path,\n tags: operation.getTags().map((tag) => tag.name),\n summary: operation.getSummary() || undefined,\n description: operation.getDescription() || undefined,\n deprecated: operation.isDeprecated() || undefined,\n parameters,\n requestBody,\n responses,\n })\n }\n\n return { parseSchema, parseOperation, parseParameter }\n}\n\n/**\n * Parses a single OpenAPI `SchemaObject` into a `SchemaNode`.\n *\n * Use this for targeted schema parsing when you don't need the full spec.\n * For complete spec parsing, use `parseOas()` instead which handles operations and all schemas together.\n *\n * @note Circular schema references are tracked via internal state and resolve appropriately.\n *\n * @example\n * ```ts\n * const document = yaml.parse(fs.readFileSync('openapi.yaml', 'utf8'))\n * const ctx = { document }\n * const schema = parseSchema(ctx, { schema: { type: 'string', format: 'uuid' } })\n * ```\n */\nexport function parseSchema(\n ctx: OasParserContext,\n { schema, name }: { schema: SchemaObject; name?: string },\n options?: Partial<ast.ParserOptions>,\n): ast.SchemaNode {\n return createSchemaParser(ctx).parseSchema({ schema, name }, options)\n}\n\n/**\n * Parses an OpenAPI specification into Kubb's universal `InputNode` AST.\n *\n * This is the main entry point for `@kubb/adapter-oas`. It converts OpenAPI/Swagger specs into a spec-agnostic tree\n * that downstream plugins (`plugin-ts`, `plugin-zod`, etc.) consume for code generation. No code is generated here —\n * the tree is a pure data structure representing all schemas and operations.\n *\n * Returns the AST root and a `nameMapping` for resolving schema references.\n *\n * @example\n * ```ts\n * import { parseOas } from '@kubb/adapter-oas'\n *\n * const document = await parseFromConfig(config)\n * const { root, nameMapping } = parseOas(document, { dateType: 'date', contentType: 'application/json' })\n * ```\n */\nexport function parseOas(\n document: Document,\n options: Partial<ast.ParserOptions> & { contentType?: ContentType } = {},\n): { root: ast.InputNode; nameMapping: Map<string, string> } {\n const { contentType, ...parserOptions } = options\n const mergedOptions: ast.ParserOptions = {\n ...DEFAULT_PARSER_OPTIONS,\n ...parserOptions,\n }\n\n const { schemas: schemaObjects, nameMapping } = getSchemas(document, {\n contentType,\n })\n const { parseSchema: _parseSchema, parseOperation: _parseOperation } = createSchemaParser({ document, contentType })\n\n const schemas: Array<ast.SchemaNode> = Object.entries(schemaObjects).map(([name, schema]) => _parseSchema({ schema, name }, mergedOptions))\n\n const baseOas = new BaseOas(document)\n const paths = baseOas.getPaths()\n\n const operations: Array<ast.OperationNode> = Object.entries(paths).flatMap(([, methods]) =>\n Object.entries(methods)\n .map(([, operation]) => (operation ? _parseOperation(mergedOptions, operation) : null))\n .filter((op): op is ast.OperationNode => op !== null),\n )\n\n const root = ast.createInput({ schemas, operations })\n\n return { root, nameMapping }\n}\n","import { ast } from '@kubb/core'\nimport type { SchemaNodeByType } from '@kubb/ast'\n\nexport type DiscriminatorTarget = {\n propertyName: string\n enumValues: Array<string | number | boolean>\n}\n\n/**\n * Builds a map of child schema names → discriminator patch data by scanning the given\n * top-level AST schema nodes for union schemas that carry a `discriminatorPropertyName`.\n *\n * Extracted from `applyDiscriminatorInheritance` so the streaming path can call it on a\n * small pre-parsed subset of schemas (only the discriminator parents) rather than on all\n * schemas at once.\n */\nexport function buildDiscriminatorChildMap(schemas: ast.SchemaNode[]): Map<string, DiscriminatorTarget> {\n const childMap = new Map<string, DiscriminatorTarget>()\n\n for (const schema of schemas) {\n // Case 1: top-level schema is a union (oneOf/anyOf with discriminator)\n // Case 2: top-level schema is an intersection wrapping a union (oneOf/anyOf + shared properties)\n let unionNode = ast.narrowSchema(schema, 'union')\n\n if (!unionNode) {\n const intersectionMembers = ast.narrowSchema(schema, 'intersection')?.members\n if (intersectionMembers) {\n for (const m of intersectionMembers) {\n const u = ast.narrowSchema(m, 'union')\n if (u) {\n unionNode = u\n break\n }\n }\n }\n }\n\n if (!unionNode?.discriminatorPropertyName || !unionNode.members) continue\n\n const { discriminatorPropertyName, members } = unionNode\n\n for (const member of members) {\n // Members with a discriminant value are intersections: [RefSchemaNode, ObjectSchemaNode]\n const intersectionNode = ast.narrowSchema(member, 'intersection')\n if (!intersectionNode?.members) continue\n\n let refNode: SchemaNodeByType['ref'] | null = null\n let objNode: SchemaNodeByType['object'] | null = null\n\n for (const m of intersectionNode.members) {\n refNode ??= ast.narrowSchema(m, 'ref')\n objNode ??= ast.narrowSchema(m, 'object')\n }\n\n if (!refNode?.name || !objNode) continue\n\n const prop = objNode.properties.find((p) => p.name === discriminatorPropertyName)\n const enumNode = prop ? ast.narrowSchema(prop.schema, 'enum') : null\n if (!enumNode?.enumValues?.length) continue\n\n const enumValues = enumNode.enumValues.filter((v): v is string | number | boolean => v !== null)\n if (!enumValues.length) continue\n\n const existing = childMap.get(refNode.name)\n if (!existing) {\n childMap.set(refNode.name, { propertyName: discriminatorPropertyName, enumValues: [...enumValues] })\n continue\n }\n existing.enumValues.push(...enumValues)\n }\n }\n\n return childMap\n}\n\n/**\n * Patches a single top-level `SchemaNode` with its discriminator entry (adds or replaces\n * the discriminant property). Used by the streaming path to apply patches inline per yield\n * without buffering all schemas.\n */\nexport function patchDiscriminatorNode(node: ast.SchemaNode, entry: { propertyName: string; enumValues: Array<string | number | boolean> }): ast.SchemaNode {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode) return node\n\n const { propertyName, enumValues } = entry\n const enumSchema = ast.createSchema({ type: 'enum', enumValues })\n const newProp = ast.createProperty({ name: propertyName, required: true, schema: enumSchema })\n\n const existingIdx = objectNode.properties.findIndex((p) => p.name === propertyName)\n const newProperties = existingIdx >= 0 ? objectNode.properties.map((p, i) => (i === existingIdx ? newProp : p)) : [...objectNode.properties, newProp]\n\n return { ...objectNode, properties: newProperties }\n}\n\n/**\n * Injects discriminator enum values into child schemas so they know which value identifies them.\n *\n * Finds every union schema in `input.schemas` that has a `discriminatorPropertyName`, collects the\n * enum value each union member is mapped to, then adds (or replaces) that property on the matching\n * child object schema.\n *\n * Returns a new `InputNode` — the original is never mutated.\n *\n * @example\n * ```ts\n * const { root } = parseOas(document, options)\n * const next = applyDiscriminatorInheritance(root)\n * ```\n */\nexport function applyDiscriminatorInheritance(root: ast.InputNode): ast.InputNode {\n const childMap = buildDiscriminatorChildMap(root.schemas)\n\n if (childMap.size === 0) return root\n\n return ast.transform(root, {\n schema(node, { parent }) {\n if (parent?.kind !== 'Input' || !node.name) return\n\n const entry = childMap.get(node.name)\n if (!entry) return\n\n return patchDiscriminatorNode(node, entry)\n },\n })\n}\n","import { ast } from '@kubb/core'\nimport type BaseOas from 'oas'\nimport { buildDiscriminatorChildMap, patchDiscriminatorNode } from './discriminator.ts'\nimport type { SchemaParser } from './parser.ts'\nimport { resolveServerUrl } from './resolvers.ts'\nimport type { DiscriminatorTarget } from './discriminator.ts'\nimport type { AdapterOas, Document, SchemaObject } from './types.ts'\n\nexport type PreScanResult = {\n refAliasMap: Map<string, ast.SchemaNode>\n enumNames: string[]\n circularNames: string[]\n discriminatorChildMap: Map<string, DiscriminatorTarget> | null\n}\n\n/**\n * Reads the server URL from the document's `servers` array at `serverIndex`,\n * interpolating any `serverVariables` into the URL template.\n *\n * Returns `null` when `serverIndex` is omitted or out of range.\n *\n * @example Resolve the first server\n * `resolveBaseUrl({ document, serverIndex: 0 })`\n *\n * @example Override a path variable\n * `resolveBaseUrl({ document, serverIndex: 0, serverVariables: { version: 'v2' } })`\n */\nexport function resolveBaseUrl({\n document,\n serverIndex,\n serverVariables,\n}: {\n document: Document\n serverIndex?: number\n serverVariables?: Record<string, string>\n}): string | null {\n const server = serverIndex !== undefined ? document.servers?.at(serverIndex) : undefined\n return server?.url ? resolveServerUrl(server, serverVariables) : null\n}\n\n/**\n * Parses every schema once to build the lookup structures that streaming needs upfront.\n *\n * Three things happen in this single pass:\n * - `refAliasMap` records schemas that are pure `$ref` aliases so the streaming pass can inline them.\n * - `enumNames` collects the names of every enum schema so plugins skip re-scanning the stream.\n * - `circularNames` runs cycle detection, which requires all nodes in memory simultaneously.\n * The `allNodes` array is local and drops out of scope as soon as this function returns.\n *\n * After this call, only `refAliasMap` and `discriminatorChildMap` stay alive in the adapter closure.\n * Both are proportional to the number of aliases or discriminator parents, not total schema count.\n *\n * Each schema is parsed again during the streaming pass — this is intentional.\n * Holding the parsed nodes in memory here would defeat the streaming memory benefit.\n *\n * @example\n * ```ts\n * const { refAliasMap, enumNames, circularNames } = preScan({\n * schemas,\n * parseSchema,\n * parserOptions,\n * discriminator: 'strict',\n * })\n * ```\n */\nexport function preScan({\n schemas,\n parseSchema,\n parserOptions,\n discriminator,\n}: {\n schemas: Record<string, SchemaObject>\n parseSchema: (entry: { schema: SchemaObject; name: string }, options: ast.ParserOptions) => ast.SchemaNode\n parserOptions: ast.ParserOptions\n discriminator: AdapterOas['options']['discriminator']\n}): PreScanResult {\n const allNodes: ast.SchemaNode[] = []\n const refAliasMap = new Map<string, ast.SchemaNode>()\n const enumNames: string[] = []\n const discriminatorParentNodes: ast.SchemaNode[] = []\n\n for (const [name, schema] of Object.entries(schemas)) {\n const node = parseSchema({ schema, name }, parserOptions)\n allNodes.push(node)\n if (node.type === 'ref' && node.name && node.name !== name) {\n refAliasMap.set(name, node)\n }\n if (ast.narrowSchema(node, ast.schemaTypes.enum) && node.name) {\n enumNames.push(node.name)\n }\n if (discriminator === 'inherit' && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) {\n discriminatorParentNodes.push(node)\n }\n }\n\n const circularNames = [...ast.findCircularSchemas(allNodes)]\n const discriminatorChildMap = discriminatorParentNodes.length > 0 ? buildDiscriminatorChildMap(discriminatorParentNodes) : null\n\n return { refAliasMap, enumNames, circularNames, discriminatorChildMap }\n}\n\n/**\n * Creates a lazy `InputStreamNode` from already-resolved adapter state.\n *\n * The schema and operation iterables each start a fresh parse pass on every\n * `[Symbol.asyncIterator]()` call. This lets multiple plugins consume the same\n * stream object independently without sharing a cursor or holding all nodes in memory.\n *\n * Ref aliases in `refAliasMap` are inlined during iteration: an alias entry is replaced\n * with its target's parsed node (but keeps the alias name) so plugins never receive bare `ref` nodes.\n *\n * @example\n * ```ts\n * const streamNode = createInputStream({ schemas, parseSchema, parseOperation, baseOas, parserOptions, refAliasMap, discriminatorChildMap, meta })\n * for await (const schema of streamNode.schemas) {\n * // each call to for-await restarts from the first schema\n * }\n * ```\n */\nexport function createInputStream({\n schemas,\n parseSchema,\n parseOperation,\n baseOas,\n parserOptions,\n refAliasMap,\n discriminatorChildMap,\n meta,\n}: {\n schemas: Record<string, SchemaObject>\n parseSchema: SchemaParser['parseSchema']\n parseOperation: SchemaParser['parseOperation']\n baseOas: BaseOas\n parserOptions: ast.ParserOptions\n refAliasMap: Map<string, ast.SchemaNode>\n discriminatorChildMap: Map<string, DiscriminatorTarget> | null\n meta: ast.InputMeta\n}): ast.InputStreamNode {\n const schemasIterable: AsyncIterable<ast.SchemaNode> = {\n [Symbol.asyncIterator]() {\n return (async function* () {\n for (const [name, schema] of Object.entries(schemas)) {\n // Inline ref aliases: replace the alias entry with its target's parsed node\n // (keeping the alias name). Skip the first parse entirely for alias entries\n // since that result is never used.\n const alias = refAliasMap.get(name)\n if (alias?.name && schemas[alias.name]) {\n yield { ...parseSchema({ schema: schemas[alias.name]!, name: alias.name }, parserOptions), name }\n continue\n }\n\n const parsed = parseSchema({ schema, name }, parserOptions)\n const node = discriminatorChildMap?.get(name) ? patchDiscriminatorNode(parsed, discriminatorChildMap.get(name)!) : parsed\n yield node\n }\n })()\n },\n }\n\n const operationsIterable: AsyncIterable<ast.OperationNode> = {\n [Symbol.asyncIterator]() {\n return (async function* () {\n for (const methods of Object.values(baseOas.getPaths())) {\n for (const operation of Object.values(methods)) {\n if (!operation) continue\n const node = parseOperation(parserOptions, operation)\n if (node) yield node\n }\n }\n })()\n },\n }\n\n return ast.createStreamInput(schemasIterable, operationsIterable, meta)\n}\n","import { once } from '@internals/utils'\nimport { ast, createAdapter } from '@kubb/core'\nimport type { AdapterSource } from '@kubb/core'\nimport BaseOas from 'oas'\nimport { DEFAULT_PARSER_OPTIONS } from './constants.ts'\nimport { parseDocument, parseFromConfig, validateDocument } from './factory.ts'\nimport { createSchemaParser } from './parser.ts'\nimport { getSchemas } from './resolvers.ts'\nimport { createInputStream, preScan, resolveBaseUrl } from './stream.ts'\nimport type { AdapterOas, Document } from './types.ts'\n\n/**\n * Stable string identifier for the OAS adapter used in Kubb's adapter registry.\n */\nexport const adapterOasName = 'oas' satisfies AdapterOas['name']\n\n/**\n * Creates the default OpenAPI / Swagger adapter for Kubb.\n *\n * Parses the spec, optionally validates it, resolves the base URL, and converts\n * everything into an `InputNode` that downstream plugins consume.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { adapterOas } from '@kubb/adapter-oas'\n * import { pluginTs } from '@kubb/plugin-ts'\n *\n * export default defineConfig({\n * adapter: adapterOas({ dateType: 'date', serverIndex: 0 }),\n * input: { path: './openapi.yaml' },\n * plugins: [pluginTs()],\n * })\n * ```\n */\nexport const adapterOas = createAdapter<AdapterOas>((options) => {\n const {\n validate = true,\n contentType,\n serverIndex,\n serverVariables,\n discriminator = 'strict',\n dateType = DEFAULT_PARSER_OPTIONS.dateType,\n integerType = DEFAULT_PARSER_OPTIONS.integerType,\n unknownType = DEFAULT_PARSER_OPTIONS.unknownType,\n enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix,\n emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType,\n } = options\n\n const parserOptions: ast.ParserOptions = {\n ...DEFAULT_PARSER_OPTIONS,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n enumSuffix,\n }\n\n let nameMapping = new Map<string, string>()\n let parsedDocument: Document | null = null\n\n // `once` collapses concurrent callers (e.g. a build's `stream()` racing with `openInStudio()`'s `parse()`) onto one in-flight promise.\n const ensureDocument = once(async (source: AdapterSource): Promise<Document> => {\n const fresh = await parseFromConfig(source)\n if (validate) await validateDocument(fresh)\n parsedDocument = fresh\n return fresh\n })\n\n const ensureSchemas = once(async (document: Document) => {\n const result = getSchemas(document, { contentType })\n nameMapping = result.nameMapping\n return result.schemas\n })\n\n const ensureBaseOas = once((document: Document) => new BaseOas(document))\n\n const ensureSchemaParser = once((document: Document) => createSchemaParser({ document, contentType }))\n\n const ensurePreScan = once((schemas: Awaited<ReturnType<typeof ensureSchemas>>, parseSchema: ReturnType<typeof ensureSchemaParser>['parseSchema']) =>\n preScan({ schemas, parseSchema, parserOptions, discriminator }),\n )\n\n async function createStream(source: AdapterSource): Promise<ast.InputStreamNode> {\n const document = await ensureDocument(source)\n const schemas = await ensureSchemas(document)\n const { parseSchema, parseOperation } = ensureSchemaParser(document)\n const { refAliasMap, enumNames, circularNames, discriminatorChildMap } = ensurePreScan(schemas, parseSchema)\n\n return createInputStream({\n schemas,\n parseSchema,\n parseOperation,\n baseOas: ensureBaseOas(document),\n parserOptions,\n refAliasMap,\n discriminatorChildMap,\n meta: {\n title: document.info?.title,\n description: document.info?.description,\n version: document.info?.version,\n baseURL: resolveBaseUrl({ document, serverIndex, serverVariables }),\n circularNames,\n enumNames,\n },\n })\n }\n\n return {\n name: adapterOasName,\n get options() {\n return {\n validate,\n contentType,\n serverIndex,\n serverVariables,\n discriminator,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n enumSuffix,\n nameMapping,\n }\n },\n get document() {\n return parsedDocument\n },\n async validate(input, options) {\n const document = await parseDocument(input)\n await validateDocument(document, options)\n },\n getImports(node, resolve) {\n return ast.collectImports({\n node,\n nameMapping,\n resolve: (schemaName) => {\n const result = resolve(schemaName)\n if (!result) return null\n\n return ast.createImport({ name: [result.name], path: result.path })\n },\n })\n },\n async parse(source) {\n const streamNode = await createStream(source)\n\n const collect = async <T>(iter: AsyncIterable<T>): Promise<T[]> => {\n const out: T[] = []\n for await (const item of iter) out.push(item)\n return out\n }\n\n const [schemas, operations] = await Promise.all([collect(streamNode.schemas), collect(streamNode.operations)])\n\n return ast.createInput({ schemas, operations, meta: streamNode.meta })\n },\n stream: createStream,\n }\n})\n","// external packages\n\nimport type { AdapterFactoryOptions } from '@kubb/core'\nimport { ast } from '@kubb/core'\nimport type { Operation as OASOperation } from 'oas/operation'\nimport type {\n DiscriminatorObject as OASDiscriminatorObject,\n OASDocument,\n MediaTypeObject as OASMediaTypeObject,\n ResponseObject as OASResponseObject,\n SchemaObject as OASSchemaObject,\n} from 'oas/types'\nimport type { OpenAPIV3 } from 'openapi-types'\n\n/**\n * Re-exports of `openapi-types` for use by adapter consumers.\n */\nexport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\n\n/**\n * Content-type string for selecting request/response schemas from an OpenAPI spec.\n * Supports `'application/json'` or any other media type.\n *\n * @example\n * ```ts\n * const ct: ContentType = 'application/vnd.api+json'\n * ```\n */\nexport type ContentType = 'application/json' | (string & {})\n\n/**\n * Extended OpenAPI 3.0 schema object that includes OpenAPI 3.1 and JSON Schema fields.\n * The parser uses these additional fields to handle newer spec versions.\n *\n * @example\n * ```ts\n * const schema: SchemaObject = {\n * type: 'string',\n * const: 'dog',\n * contentMediaType: 'application/octet-stream',\n * }\n * ```\n */\nexport type SchemaObject = OASSchemaObject & {\n /**\n * OAS 3.0 vendor extension: marks a schema as nullable without using `type: ['null', ...]`.\n */\n 'x-nullable'?: boolean\n /**\n * OAS 3.1: constrains the schema to a single fixed value (equivalent to a one-item `enum`).\n */\n const?: string | number | boolean | null\n /**\n * OAS 3.1: media type of the schema content. `'application/octet-stream'` on a `string` schema maps to `blob`.\n */\n contentMediaType?: string\n $ref?: string\n /**\n * OAS 3.1: positional tuple items, replacing the multi-item `items` array from OAS 3.0.\n */\n prefixItems?: Array<SchemaObject | ReferenceObject>\n /**\n * JSON Schema: maps regex patterns to sub-schemas for validating additional properties.\n */\n patternProperties?: Record<string, SchemaObject | boolean>\n /**\n * Single-schema form of `items`. Narrowed from the base type to take precedence over the tuple overload.\n */\n items?: SchemaObject | ReferenceObject\n /**\n * Enum values for this schema (narrowed from `unknown[]`).\n */\n enum?: Array<string | number | boolean | null>\n}\n\n/**\n * Maps uppercase HTTP method names to lowercase for backwards compatibility.\n *\n * @example\n * ```ts\n * HttpMethods['GET'] // 'get'\n * HttpMethods['POST'] // 'post'\n * ```\n */\nexport const HttpMethods = Object.fromEntries(Object.entries(ast.httpMethods).map(([lower, upper]) => [upper, lower])) as Record<\n Uppercase<ast.HttpMethod>,\n Lowercase<ast.HttpMethod>\n>\n\n/**\n * HTTP method as a lowercase string (`'get' | 'post' | ...`).\n */\nexport type HttpMethod = Lowercase<ast.HttpMethod>\n\n/**\n * Normalized OpenAPI document after parsing.\n */\nexport type Document = OASDocument\n\n/**\n * API operation extracted from an OpenAPI document.\n */\nexport type Operation = OASOperation\n\n/**\n * Discriminator object for `oneOf`/`anyOf` schemas in OpenAPI.\n */\nexport type DiscriminatorObject = OASDiscriminatorObject\n\n/**\n * OpenAPI reference object pointing to a schema definition via `$ref`.\n */\nexport type ReferenceObject = OpenAPIV3.ReferenceObject\n\n/**\n * OpenAPI response object from a spec that contains schema, status code, and headers.\n */\nexport type ResponseObject = OASResponseObject\n\n/**\n * OpenAPI media type object that maps a content-type string to its schema.\n */\nexport type MediaTypeObject = OASMediaTypeObject\n\n/**\n * Configuration options for the OpenAPI adapter.\n * Controls spec validation, content-type selection, and server URL resolution.\n *\n * @example\n * ```ts\n * adapterOas({\n * validate: false,\n * dateType: 'date',\n * serverIndex: 0,\n * serverVariables: { env: 'prod' },\n * })\n * ```\n */\nexport type AdapterOasOptions = {\n /**\n * Validate the OpenAPI spec before parsing.\n * @default true\n */\n validate?: boolean\n /**\n * Preferred content-type used when extracting request/response schemas.\n * Defaults to the first valid JSON media type found in the spec.\n */\n contentType?: ContentType\n /**\n * Index into `oas.api.servers` for computing `baseURL`.\n * `0` → first server, `1` → second server. Omit to leave `baseURL` undefined.\n */\n serverIndex?: number\n /**\n * Override values for `{variable}` placeholders in the selected server URL.\n * Only used when `serverIndex` is set.\n *\n * @example\n * ```ts\n * // spec server: \"https://api.{env}.example.com\"\n * serverVariables: { env: 'prod' }\n * // → baseURL: \"https://api.prod.example.com\"\n * ```\n */\n serverVariables?: Record<string, string>\n /**\n * How the discriminator field is interpreted.\n * - `'strict'` — uses `oneOf` schemas as written in the spec.\n * - `'inherit'` — propagates discriminator values into child schemas from `discriminator.mapping`.\n * @default 'strict'\n */\n discriminator?: 'strict' | 'inherit'\n} & Partial<ast.ParserOptions>\n\n/**\n * Adapter options after defaults have been applied and schema name collisions resolved.\n */\nexport type AdapterOasResolvedOptions = {\n validate: boolean\n contentType: AdapterOasOptions['contentType']\n serverIndex: AdapterOasOptions['serverIndex']\n serverVariables: AdapterOasOptions['serverVariables']\n discriminator: NonNullable<AdapterOasOptions['discriminator']>\n dateType: NonNullable<AdapterOasOptions['dateType']>\n integerType: NonNullable<AdapterOasOptions['integerType']>\n unknownType: NonNullable<AdapterOasOptions['unknownType']>\n emptySchemaType: NonNullable<AdapterOasOptions['emptySchemaType']>\n enumSuffix: AdapterOasOptions['enumSuffix']\n /**\n * Map from original `$ref` paths to their collision-resolved schema names.\n * Populated after each `parse()` call.\n *\n * @example\n * ```ts\n * nameMapping.get('#/components/schemas/Order') // 'Order'\n * nameMapping.get('#/components/responses/Order') // 'OrderResponse'\n * ```\n */\n nameMapping: Map<string, string>\n}\n\n/**\n * `@kubb/core` adapter factory type for the OpenAPI adapter.\n */\nexport type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasResolvedOptions, Document>\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;CAS9D,OARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAEH,CAAC,MAAM,gBAAgB,CAAC,OAAO,QAE3C,CACT,KAAK,MAAM,MAAM;EAEhB,IADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,EACjD,OAAO;EACrB,IAAI,MAAM,KAAK,CAAC,QAAQ,OAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;EAC3E,OAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;;;;;;;;;;AAiBjC,SAAS,iBAAiB,MAAc,eAAkE;CACx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AAE;IACnB,WAAW,MAAM,QAAQ,MAAM,IAAI,KAAK,KAAK;IAC7C,OAAO;;GAGT,MAAM,CAAC,SAAS,cAAc,MAAM,QAAQ,IAAI,CAAC,QAAQ,WAAW,QAAQ,EAAE,QAAQ,WAAW,WAAW,CAAC,CAAC;GAE9G,OAAO,IAAI,YAAY;IAAE;IAAS;IAAY,MAAM,WAAW;IAAM,CAAC;;EAExE,QAAQ;EACT;EACD;;;;;;;;;;;;AC3EF,MAAa,cAAc,OAAO,YAAY,OAAO,QAAQ,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["#options","#transformParam","#eachParam"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/object.ts","../../../internals/utils/src/promise.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/constants.ts","../src/guards.ts","../src/factory.ts","../src/refs.ts","../src/resolvers.ts","../src/parser.ts","../src/discriminator.ts","../src/stream.ts","../src/adapter.ts","../src/types.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n *\n * Empty segments are filtered before joining. They arise when the text starts with\n * a dot followed immediately by a letter (e.g. `..Schema` splits into `['..', 'Schema']`\n * and `'..'` transforms to an empty string). Without this filter the join would produce\n * a leading `/`, which `path.resolve` would interpret as an absolute path, allowing\n * generated files to escape the configured output directory.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => transformPart(part, i === parts.length - 1))\n .filter(Boolean)\n .join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\n * Returns `true` when `value` is a plain (non-null, non-array) object.\n *\n * @example\n * ```ts\n * isPlainObject({}) // true\n * isPlainObject([]) // false\n * isPlainObject(null) // false\n * ```\n */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype\n}\n\n/**\n * Recursively merges `source` into `target`, combining nested plain objects.\n * Arrays and non-object values from `source` override the corresponding values in `target`.\n *\n * @example\n * ```ts\n * mergeDeep({ a: { x: 1 } }, { a: { y: 2 } })\n * // { a: { x: 1, y: 2 } }\n * ```\n */\nexport function mergeDeep(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target }\n for (const key of Object.keys(source)) {\n const sv = source[key]\n const tv = result[key]\n result[key] =\n sv !== null && typeof sv === 'object' && !Array.isArray(sv) && tv !== null && typeof tv === 'object' && !Array.isArray(tv)\n ? mergeDeep(tv as Record<string, unknown>, sv as Record<string, unknown>)\n : sv\n }\n return result\n}\n\n/**\n * Strips functions, symbols, and `undefined` values from plugin options for safe JSON transport.\n *\n * @example\n * ```ts\n * serializePluginOptions({ output: './src', onWrite: () => {} })\n * // { output: './src' } (function stripped)\n * ```\n */\nexport function serializePluginOptions<TOptions extends object>(options: TOptions): TOptions {\n if (options === null || options === undefined) return {} as TOptions\n if (typeof options !== 'object') return options\n if (Array.isArray(options)) return options.map(serializePluginOptions) as unknown as TOptions\n\n const serialized: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(options)) {\n if (typeof value === 'function' || typeof value === 'symbol' || value === undefined) continue\n serialized[key] = value !== null && typeof value === 'object' ? serializePluginOptions(value as object) : value\n }\n return serialized as TOptions\n}\n","function* chunks<T>(arr: readonly T[], size: number): Generator<T[]> {\n for (let i = 0; i < arr.length; i += size) {\n yield arr.slice(i, i + size)\n }\n}\n\nexport type ForBatchesOptions = {\n /**\n * Maximum batch size handed to `process`.\n * Parallel dispatch within a batch is the caller's responsibility\n * (typically via `Promise.all(batch.map(...))`).\n */\n concurrency: number\n /**\n * Called after every batch.\n *\n * Use a cheap, idempotent callback (e.g. one that short-circuits when there\n * is nothing new to do). The helper does not coalesce calls — if you need\n * throttling, do it inside `flush` itself.\n */\n flush?: () => Promise<void>\n}\n\n/**\n * Slices `source` into batches of `concurrency` items and awaits `process` for each batch.\n * Accepts both plain arrays (sync) and `AsyncIterable` (streaming).\n *\n * `process` controls whether items inside a batch run in parallel; this helper only\n * controls batch size and per-batch flushing.\n *\n * @example\n * ```ts\n * // parallel dispatch inside each batch\n * await forBatches(schemas, (batch) => Promise.all(batch.map(process)), { concurrency: 8 })\n *\n * // async iterable with a flush after every batch\n * await forBatches(stream.schemas, (batch) => dispatch(batch), { concurrency: 8, flush })\n * ```\n */\nexport async function forBatches<T>(\n source: readonly T[] | AsyncIterable<T>,\n process: (batch: T[]) => Promise<unknown>,\n options: ForBatchesOptions,\n): Promise<void> {\n const { concurrency, flush } = options\n\n if (Array.isArray(source)) {\n for (const batch of chunks(source, concurrency)) {\n await process(batch)\n if (flush) await flush()\n }\n return\n }\n\n const batch: T[] = []\n for await (const item of source) {\n batch.push(item)\n if (batch.length >= concurrency) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n }\n if (batch.length > 0) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n}\n\n/**\n * Runs `work`, passing `flush` as its periodic-flush callback, then calls\n * `flush` once more to drain any items that did not cross a flush boundary.\n *\n * @example\n * ```ts\n * await withDrain(\n * (flush) => processItems(items, { flush }),\n * () => writeRemainingFiles(),\n * )\n * ```\n */\nexport async function withDrain(work: (flush: () => Promise<void>) => Promise<void>, flush: () => Promise<void>): Promise<void> {\n await work(flush)\n await flush()\n}\n\n/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\n/** Returns `true` when `result` is a thenable `Promise`.\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve(1)) // true\n * isPromise(42) // false\n * ```\n */\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return result !== null && result !== undefined && typeof (result as Record<string, unknown>)['then'] === 'function'\n}\n\n/** Returns `true` when `result` is a fulfilled `Promise.allSettled` result.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseFulfilledResult).map((r) => r.value)\n * ```\n */\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n\n/**\n * Returns a wrapper that caches the result of the first invocation and replays\n * it for every subsequent call, ignoring later arguments.\n *\n * Works for sync and async factories — for async, the cached value is the\n * promise itself, so concurrent callers share one in-flight execution and\n * cannot race each other.\n *\n * @example\n * ```ts\n * const loadDocument = once(async (path: string) => parse(await readFile(path)))\n * const a = loadDocument('./a.yaml') // parses\n * const b = loadDocument('./b.yaml') // returns the cached promise from the first call\n * ```\n */\nexport function once<TArgs extends unknown[], TReturn>(factory: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn {\n let cache: { value: TReturn } | undefined\n return (...args: TArgs): TReturn => {\n if (!cache) cache = { value: factory(...args) }\n return cache.value\n }\n}\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Wraps `factory` with a keyed cache backed by the provided store.\n *\n * Pass a `WeakMap` for object keys (results are GC-eligible when the key is\n * collected) or a `Map` for primitive keys. For multi-argument functions,\n * nest two `memoize` calls — the outer keyed by the first argument, the\n * inner (created once per outer miss) keyed by the second.\n *\n * Because the cache is owned by the caller, it can be shared, inspected, or\n * cleared independently of the memoized function.\n *\n * @example Single WeakMap key\n * ```ts\n * const cache = new WeakMap<SchemaNode, Set<string>>()\n * const getRefs = memoize(cache, (node) => collectRefs(node))\n * ```\n *\n * @example Single Map key (primitive)\n * ```ts\n * const cache = new Map<string, Resolver>()\n * const getResolver = memoize(cache, (name) => buildResolver(name))\n * ```\n *\n * @example Two-level (object + primitive)\n * ```ts\n * const outer = new WeakMap<Params[], Map<string, Params[]>>()\n * const fn = memoize(outer, (params) => memoize(new Map(), (key) => transform(params, key)))\n * fn(params)('camelcase')\n * ```\n */\nexport function memoize<TKey, TValue>(store: Store<TKey, TValue>, factory: (key: TKey) => TValue): (key: TKey) => TValue {\n return (key: TKey): TValue => {\n if (store.has(key)) return store.get(key)!\n const value = factory(key)\n store.set(key, value)\n return value\n }\n}\n\n/**\n * Wraps a plain array in a reusable `AsyncIterable`.\n * Each `[Symbol.asyncIterator]()` call returns a fresh generator so the\n * iterable can be consumed multiple times (e.g. once per plugin pre-scan).\n *\n * @example\n * ```ts\n * const stream = arrayToAsyncIterable([1, 2, 3])\n * for await (const n of stream) console.log(n) // 1, 2, 3\n * ```\n */\nexport function arrayToAsyncIterable<T>(arr: readonly T[]): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]() {\n return (async function* () {\n yield* arr\n })()\n },\n }\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `undefined` when the path has none.\n */\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({\n prefix,\n replacer,\n }: {\n prefix?: string | null\n replacer?: (pathParam: string) => string\n } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { ast } from '@kubb/core'\n\n/**\n * Default parser options applied when no explicit options are provided.\n *\n * @example\n * ```ts\n * import { DEFAULT_PARSER_OPTIONS } from '@kubb/adapter-oas'\n *\n * const parser = createOasParser(oas)\n * const root = parser.parse({ ...DEFAULT_PARSER_OPTIONS, dateType: 'date' })\n * ```\n */\nexport const DEFAULT_PARSER_OPTIONS = {\n dateType: 'string',\n integerType: 'bigint',\n unknownType: 'any',\n emptySchemaType: 'any',\n enumSuffix: 'enum',\n} as const satisfies ast.ParserOptions\n\n/**\n * JSON-Pointer prefix for schemas declared under `components.schemas` in an OpenAPI document.\n *\n * Used when building or parsing `$ref` strings.\n *\n * @example\n * ```ts\n * `${SCHEMA_REF_PREFIX}Pet` // '#/components/schemas/Pet'\n * ```\n */\nexport const SCHEMA_REF_PREFIX = '#/components/schemas/' as const\n\n/**\n * OpenAPI version string written into the stub document created during multi-spec merges.\n */\nexport const MERGE_OPENAPI_VERSION = '3.0.0' as const\n\n/**\n * Fallback `info.title` placed in the stub document when merging multiple API files.\n */\nexport const MERGE_DEFAULT_TITLE = 'Merged API' as const\n\n/**\n * Fallback `info.version` placed in the stub document when merging multiple API files.\n */\nexport const MERGE_DEFAULT_VERSION = '1.0.0' as const\n\n/**\n * Set of JSON Schema keywords that prevent a schema fragment from being inlined during `allOf` flattening.\n *\n * A fragment that contains any of these keys carries structural meaning of its own and must stay as a separate\n * intersection member rather than being merged into the parent.\n *\n * @example\n * ```ts\n * import { structuralKeys } from '@kubb/adapter-oas'\n *\n * const isStructural = Object.keys(fragment).some((key) => structuralKeys.has(key))\n * // true when fragment has e.g. 'properties' or 'oneOf'\n * ```\n */\nexport const structuralKeys = new Set(['properties', 'items', 'additionalProperties', 'oneOf', 'anyOf', 'allOf', 'not'] as const)\n\n/**\n * Static map from OAS `format` strings to Kubb `SchemaType` values.\n *\n * Only formats whose AST type differs from the OAS `type` field appear here.\n * Formats that depend on runtime options (`int64`, `date-time`, `date`, `time`) are handled separately\n * in the parser. `ipv4` and `ipv6` map to their own dedicated schema types; `hostname` and\n * `idn-hostname` map to `'url'` as the closest generic string-format type.\n *\n * @example\n * ```ts\n * import { formatMap } from '@kubb/adapter-oas'\n *\n * formatMap['uuid'] // 'uuid'\n * formatMap['binary'] // 'blob'\n * formatMap['float'] // 'number'\n * ```\n */\nexport const formatMap = {\n uuid: 'uuid',\n email: 'email',\n 'idn-email': 'email',\n uri: 'url',\n 'uri-reference': 'url',\n url: 'url',\n ipv4: 'ipv4',\n ipv6: 'ipv6',\n hostname: 'url',\n 'idn-hostname': 'url',\n binary: 'blob',\n byte: 'blob',\n // Numeric formats override the OAS `type` because format is more specific.\n // See https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7\n int32: 'integer',\n float: 'number',\n double: 'number',\n} as const satisfies Record<string, ast.SchemaType>\n\n/**\n * Vendor extension keys that attach human-readable labels to enum values, checked in priority order.\n *\n * @example\n * ```ts\n * import { enumExtensionKeys } from '@kubb/adapter-oas'\n *\n * const key = enumExtensionKeys.find((k) => k in schema) // 'x-enumNames' | 'x-enum-varnames' | undefined\n * ```\n */\nexport const enumExtensionKeys = ['x-enumNames', 'x-enum-varnames'] as const\n\n/**\n * Maps `'any' | 'unknown' | 'void'` option strings to their `ScalarSchemaType` constant.\n * Replaces a plain object lookup with a `Map` for explicit key membership testing via `.has()`.\n */\nexport const typeOptionMap = new Map<'any' | 'unknown' | 'void', ast.ScalarSchemaType>([\n ['any', ast.schemaTypes.any],\n ['unknown', ast.schemaTypes.unknown],\n ['void', ast.schemaTypes.void],\n])\n","import { isPlainObject } from '@internals/utils'\nimport type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\nimport type { DiscriminatorObject, SchemaObject } from './types.ts'\n\n/**\n * Returns `true` when `doc` is a Swagger 2.0 document (no `openapi` key).\n *\n * @example\n * ```ts\n * if (isOpenApiV2Document(doc)) {\n * // doc is OpenAPIV2.Document\n * }\n * ```\n */\nexport function isOpenApiV2Document(doc: unknown): doc is OpenAPIV2.Document {\n return !!doc && isPlainObject(doc) && !('openapi' in doc)\n}\n\n/**\n * Returns `true` when a schema should be treated as nullable.\n *\n * Recognizes all nullable signals across OAS versions: `nullable: true` (OAS 3.0),\n * `x-nullable: true` (vendor extension), `type: 'null'`, and `type: ['null', ...]` (OAS 3.1).\n *\n * @example\n * ```ts\n * isNullable({ type: 'string', nullable: true }) // true\n * isNullable({ type: ['string', 'null'] }) // true\n * isNullable({ type: 'string' }) // false\n * ```\n */\nexport function isNullable(schema?: SchemaObject & { 'x-nullable'?: boolean }): boolean {\n const explicitNullable = schema?.nullable ?? schema?.['x-nullable']\n if (explicitNullable === true) return true\n\n const schemaType = schema?.type\n if (schemaType === 'null') return true\n if (Array.isArray(schemaType)) return schemaType.includes('null')\n\n return false\n}\n\n/**\n * Returns `true` when `obj` is an OpenAPI `$ref` pointer object.\n *\n * @example\n * ```ts\n * isReference({ $ref: '#/components/schemas/Pet' }) // true\n * isReference({ type: 'string' }) // false\n * ```\n */\nexport function isReference(obj?: unknown): obj is OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject {\n return !!obj && typeof obj === 'object' && '$ref' in obj\n}\n\n/**\n * Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object.\n *\n * @example\n * ```ts\n * isDiscriminator({ discriminator: { propertyName: 'type', mapping: {} } }) // true\n * isDiscriminator({ discriminator: 'type' }) // false (Swagger 2 string form)\n * ```\n */\nexport function isDiscriminator(obj?: unknown): obj is SchemaObject & { discriminator: DiscriminatorObject } {\n const record = obj as Record<string, unknown>\n return !!obj && !!record['discriminator'] && typeof record['discriminator'] !== 'string'\n}\n","import path from 'node:path'\nimport { mergeDeep, URLPath } from '@internals/utils'\nimport type { AdapterSource } from '@kubb/core'\nimport { bundle, loadConfig } from '@redocly/openapi-core'\nimport OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\nimport { MERGE_DEFAULT_TITLE, MERGE_DEFAULT_VERSION, MERGE_OPENAPI_VERSION } from './constants.ts'\nimport { isOpenApiV2Document } from './guards.ts'\nimport type { Document } from './types.ts'\n\nexport type ParseOptions = {\n canBundle?: boolean\n enablePaths?: boolean\n}\n\nexport type ValidateDocumentOptions = {\n throwOnError?: boolean\n}\n\n/**\n * Loads and dereferences an OpenAPI document, returning the raw `Document`.\n *\n * Accepts a file path string or an already-parsed document object. File paths are bundled via\n * Redocly to resolve external `$ref`s. Swagger 2.0 documents are automatically up-converted\n * to OpenAPI 3.0 via `swagger2openapi`.\n *\n * @example\n * ```ts\n * const document = await parseDocument('./openapi.yaml')\n * const document = await parse(rawDocumentObject, { canBundle: false })\n * ```\n */\nexport async function parseDocument(pathOrApi: string | Document, { canBundle = true, enablePaths = true }: ParseOptions = {}): Promise<Document> {\n if (typeof pathOrApi === 'string' && canBundle) {\n const config = await loadConfig()\n const bundleResults = await bundle({\n ref: pathOrApi,\n config,\n base: pathOrApi,\n })\n\n return parseDocument(bundleResults.bundle.parsed as string, {\n canBundle,\n enablePaths,\n })\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n return openapi as Document\n }\n\n return document\n}\n\n/**\n * Deep-merges multiple OpenAPI documents into a single `Document`.\n *\n * Each document is parsed independently then recursively merged via `mergeDeep` from `@internals/utils`.\n * Throws when the input array is empty.\n *\n * @example\n * ```ts\n * const document = await mergeDocuments(['./pets.yaml', './orders.yaml'])\n * ```\n */\nexport async function mergeDocuments(pathOrApi: Array<string | Document>): Promise<Document> {\n const documents = await Promise.all(pathOrApi.map((p) => parseDocument(p, { enablePaths: false, canBundle: false })))\n\n if (documents.length === 0) {\n throw new Error('No OAS documents provided for merging.')\n }\n\n const seed: Document = {\n openapi: MERGE_OPENAPI_VERSION,\n info: { title: MERGE_DEFAULT_TITLE, version: MERGE_DEFAULT_VERSION },\n paths: {},\n components: { schemas: {} },\n } as Document\n\n const merged = documents.reduce(\n (acc, current) => mergeDeep(acc as Record<string, unknown>, current as Record<string, unknown>),\n seed as Record<string, unknown>,\n )\n\n return parseDocument(merged as Document)\n}\n\n/**\n * Creates a `Document` from an `AdapterSource`.\n *\n * Handles all three source types:\n * - `{ type: 'path' }` — resolves and bundles a local file path or remote URL.\n * - `{ type: 'paths' }` — merges multiple file paths into a single document.\n * - `{ type: 'data' }` — parses an inline string (YAML/JSON) or raw object.\n *\n * @example\n * ```ts\n * const document = await parseFromConfig({ type: 'path', path: './openapi.yaml' })\n * const document = await parseFromConfig({ type: 'data', data: '{\"openapi\":\"3.0.0\",...}' })\n * ```\n */\nexport function parseFromConfig(source: AdapterSource): Promise<Document> {\n if (source.type === 'data') {\n if (typeof source.data === 'object') {\n return parseDocument(structuredClone(source.data) as Document)\n }\n\n return parseDocument(source.data as string, { canBundle: false })\n }\n\n if (source.type === 'paths') {\n return mergeDocuments(source.paths)\n }\n\n // type === 'path'\n if (new URLPath(source.path).isURL) {\n return parseDocument(source.path)\n }\n\n return parseDocument(path.resolve(path.dirname(source.path), source.path))\n}\n\n/**\n * Validates an OpenAPI document using `oas-normalize` with colorized error output.\n *\n * @example\n * ```ts\n * await validateDocument(document)\n * ```\n */\nexport async function validateDocument(document: Document, { throwOnError = false }: ValidateDocumentOptions = {}): Promise<void> {\n try {\n const oasNormalize = new OASNormalize(document, {\n enablePaths: true,\n colorizeErrors: true,\n })\n\n await oasNormalize.validate({\n parser: {\n validate: {\n errors: { colorize: true },\n },\n },\n })\n } catch (error) {\n if (throwOnError) {\n throw error\n }\n\n // Validation failures are non-fatal — mirror plugin-oas behavior\n }\n}\n","import { isReference } from './guards.ts'\nimport type { Document } from './types.ts'\n\nconst _refCache = new WeakMap<Document, Map<string, unknown>>()\n\n/**\n * Resolves a local JSON pointer reference from a document.\n *\n * Accepts `#/...` refs. Returns `null` for empty or non-local refs.\n * Throws when the pointer cannot be resolved.\n *\n * @example\n * ```ts\n * resolveRef<SchemaObject>(document, '#/components/schemas/Pet') // SchemaObject | null\n * ```\n */\nexport function resolveRef<T = unknown>(document: Document, $ref: string): T | null {\n const origRef = $ref\n $ref = $ref.trim()\n if ($ref === '') {\n return null\n }\n if (!$ref.startsWith('#')) return null\n $ref = globalThis.decodeURIComponent($ref.substring(1))\n\n let docCache = _refCache.get(document)\n if (!docCache) {\n docCache = new Map()\n _refCache.set(document, docCache)\n }\n\n if (docCache.has($ref)) {\n return docCache.get($ref) as T\n }\n\n const current = $ref\n .split('/')\n .filter(Boolean)\n .reduce((obj: unknown, key: string) => (obj as Record<string, unknown>)?.[key], document as unknown)\n\n if (!current) {\n throw new Error(`Could not find a definition for ${origRef}.`)\n }\n\n docCache.set($ref, current)\n return current as T\n}\n\n/**\n * Resolves a `$ref` object while preserving the original `$ref` field on the result.\n *\n * Useful for parser flows that need both dereferenced fields and pointer\n * identity (for naming/import purposes). Non-reference values are returned as-is.\n *\n * @example\n * ```ts\n * dereferenceWithRef(document, { $ref: '#/components/schemas/Pet' })\n * // { $ref: '#/components/schemas/Pet', type: 'object', properties: { ... } }\n * ```\n */\nexport function dereferenceWithRef<T = unknown>(document: Document, schema?: T): T {\n if (isReference(schema)) {\n return {\n ...schema,\n ...resolveRef(document, schema.$ref),\n $ref: schema.$ref,\n }\n }\n\n return schema as T\n}\n","import { pascalCase } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport type { ParameterObject, ServerObject } from 'oas/types'\nimport { isRef } from 'oas/types'\nimport { matchesMimeType } from 'oas/utils'\nimport { formatMap, SCHEMA_REF_PREFIX, structuralKeys } from './constants.ts'\nimport { isReference } from './guards.ts'\nimport { dereferenceWithRef, resolveRef } from './refs.ts'\nimport type { ContentType, Document, MediaTypeObject, Operation, ResponseObject, SchemaObject } from './types.ts'\n\n/**\n * Replaces `{variable}` placeholders in an OpenAPI server URL with provided values.\n * Resolution order: `overrides[key]` → `variable.default` → left unreplaced.\n * Throws if an override value is not in the variable's `enum` list.\n *\n * @example\n * ```ts\n * resolveServerUrl(\n * { url: 'https://{env}.api.example.com', variables: { env: { default: 'dev', enum: ['dev', 'prod'] } } },\n * { env: 'prod' },\n * )\n * // 'https://prod.api.example.com'\n * ```\n */\nexport function resolveServerUrl(server: ServerObject, overrides?: Record<string, string>): string {\n if (!server.variables) {\n return server.url\n }\n\n let url = server.url\n for (const [key, variable] of Object.entries(server.variables)) {\n const value = overrides?.[key] ?? (variable.default != null ? String(variable.default) : undefined)\n if (value === undefined) {\n continue\n }\n\n if (variable.enum?.length && !variable.enum.some((e) => String(e) === value)) {\n throw new Error(`Invalid server variable value '${value}' for '${key}' when resolving ${server.url}. Valid values are: ${variable.enum.join(', ')}.`)\n }\n\n url = url.replaceAll(`{${key}}`, value)\n }\n\n return url\n}\n\n/**\n * Returns the Kubb `SchemaType` for a given OAS `format` string, or `null` if not found.\n * Formats not in `formatMap` (e.g., `int64`, `date-time`) are handled separately by parser options.\n */\nexport function getSchemaType(format: string): ast.SchemaType | null {\n return formatMap[format as keyof typeof formatMap] ?? null\n}\n\n/**\n * Converts an OAS primitive type string to its `PrimitiveSchemaType` equivalent.\n * Numeric types (`number`, `integer`, `bigint`) pass through unchanged. `boolean` maps to `'boolean'`. Everything else becomes `'string'`.\n */\nexport function getPrimitiveType(type: string | undefined): ast.PrimitiveSchemaType {\n if (type === 'number' || type === 'integer' || type === 'bigint') return type\n if (type === 'boolean') return 'boolean'\n\n return 'string'\n}\n\n/**\n * Narrows a content-type string to the `MediaType` union Kubb recognizes, or returns `null`.\n */\nexport function getMediaType(contentType: string): ast.MediaType | null {\n return Object.values(ast.mediaTypes).includes(contentType as ast.MediaType) ? (contentType as ast.MediaType) : null\n}\n\nexport type OperationsOptions = {\n contentType?: ContentType\n}\n\n/**\n * Returns all parameters for an operation, merging path-level and operation-level entries.\n * Operation-level parameters override path-level ones with the same `in:name` key.\n * `$ref` parameters resolve via `dereferenceWithRef` for backward compatibility.\n *\n * @example\n * ```ts\n * getParameters(document, operation)\n * // [{ name: 'petId', in: 'path', required: true, schema: { type: 'integer' } }]\n * ```\n */\nexport function getParameters(document: Document, operation: Operation): Array<ParameterObject> {\n const resolveParams = (params: unknown[]): Array<ParameterObject> =>\n params.map((p) => dereferenceWithRef(document, p)).filter((p): p is ParameterObject => !!p && typeof p === 'object' && 'in' in p && 'name' in p)\n\n const operationParams = resolveParams(operation.schema?.parameters || [])\n const pathItem = document.paths?.[operation.path]\n const pathLevelParams = resolveParams(pathItem && !isReference(pathItem) && pathItem.parameters ? pathItem.parameters : [])\n\n const paramMap = new Map<string, ParameterObject>()\n for (const p of pathLevelParams) {\n if (p.name && p.in) {\n paramMap.set(`${p.in}:${p.name}`, p)\n }\n }\n for (const p of operationParams) {\n if (p.name && p.in) {\n paramMap.set(`${p.in}:${p.name}`, p)\n }\n }\n\n return Array.from(paramMap.values())\n}\n\nfunction getResponseBody(responseBody: boolean | ResponseObject, contentType?: string): MediaTypeObject | false | [string, MediaTypeObject, ...string[]] {\n if (!responseBody) return false\n if (isReference(responseBody)) return false\n\n const body = responseBody as ResponseObject\n if (!body.content) return false\n\n if (contentType) {\n if (!(contentType in body.content)) return false\n return body.content[contentType]!\n }\n\n let availableContentType: string | undefined\n const contentTypes = Object.keys(body.content)\n for (const mt of contentTypes) {\n if (matchesMimeType.json(mt)) {\n availableContentType = mt\n break\n }\n }\n\n if (!availableContentType) {\n availableContentType = contentTypes[0]\n }\n\n if (availableContentType) {\n return [availableContentType, body.content[availableContentType]!, ...(body.description ? [body.description] : [])]\n }\n\n return false\n}\n\n/**\n * Returns the response schema for a given operation and HTTP status code.\n *\n * Returns an empty object `{}` when no response body schema is available.\n *\n * @example\n * ```ts\n * getResponseSchema(document, operation, 200) // SchemaObject\n * getResponseSchema(document, operation, '4XX') // {}\n * ```\n */\nexport function getResponseSchema(document: Document, operation: Operation, statusCode: string | number, options: OperationsOptions = {}): SchemaObject {\n if (operation.schema.responses) {\n const responses = operation.schema.responses\n for (const key in responses) {\n const schema = responses[key]\n if (schema && isReference(schema)) {\n responses[key] = resolveRef<any>(document, schema.$ref)\n }\n }\n }\n\n const responseBody = getResponseBody(operation.getResponseByStatusCode(statusCode), options.contentType)\n\n if (responseBody === false) {\n return {}\n }\n\n const schema = Array.isArray(responseBody) ? responseBody[1].schema : responseBody.schema\n\n if (!schema) {\n return {}\n }\n\n return dereferenceWithRef(document, schema)\n}\n\n/**\n * Returns the request body schema for an operation, or `null` when absent.\n *\n * @example\n * ```ts\n * getRequestSchema(document, operation) // SchemaObject | null\n * ```\n */\nexport function getRequestSchema(document: Document, operation: Operation, options: OperationsOptions = {}): SchemaObject | null {\n if (operation.schema.requestBody) {\n operation.schema.requestBody = dereferenceWithRef(document, operation.schema.requestBody)\n }\n\n const requestBody = operation.getRequestBody(options.contentType)\n\n if (requestBody === false) {\n return null\n }\n\n const schema = Array.isArray(requestBody) ? requestBody[1].schema : requestBody.schema\n\n if (!schema) {\n return null\n }\n\n return dereferenceWithRef(document, schema)\n}\n\n/**\n * The three component sections Kubb reads schemas from.\n */\ntype SchemaSourceMode = 'schemas' | 'responses' | 'requestBodies'\n\n/**\n * A schema annotated with its component section source and original name. Used by `resolveNameCollisions` for cross-source collision resolution.\n */\nexport type SchemaWithMetadata = {\n schema: SchemaObject\n source: SchemaSourceMode\n originalName: string\n}\n\nexport type GetSchemasOptions = {\n contentType?: ContentType\n}\n\nexport type GetSchemasResult = {\n schemas: Record<string, SchemaObject>\n nameMapping: Map<string, string>\n}\n\n/**\n * Flattens a keyword-only `allOf` into its parent schema.\n *\n * Only flattens when every member is a plain fragment — no `$ref` and no structural keywords\n * (see `structuralKeys`). Outer schema values take precedence over fragment values.\n * Returns `null` for a `null` input, and the original schema unchanged when flattening is unsafe.\n *\n * @example\n * ```ts\n * flattenSchema({ allOf: [{ description: 'A pet' }], type: 'object', properties: {} })\n * // { type: 'object', properties: {}, description: 'A pet' }\n *\n * flattenSchema({ allOf: [{ $ref: '#/components/schemas/Pet' }] })\n * // returned unchanged — contains a $ref\n * ```\n */\n/**\n * Returns `true` when `fragment` carries any JSON Schema keyword that makes it\n * structurally significant on its own (see `structuralKeys`).\n *\n * A fragment with a structural keyword can't be safely merged into a parent schema.\n */\nfunction hasStructuralKeywords(fragment: SchemaObject): boolean {\n for (const key in fragment) {\n if (structuralKeys.has(key as 'properties')) return true\n }\n return false\n}\n\nexport function flattenSchema(schema: SchemaObject | null): SchemaObject | null {\n if (!schema?.allOf || schema.allOf.length === 0) return schema ?? null\n\n const allOfFragments = schema.allOf as SchemaObject[]\n if (allOfFragments.some((item) => isRef(item))) return schema\n if (allOfFragments.some(hasStructuralKeywords)) return schema\n\n const merged: SchemaObject = { ...schema }\n delete merged.allOf\n\n for (const fragment of allOfFragments) {\n for (const [key, value] of Object.entries(fragment)) {\n if (merged[key as keyof typeof merged] === undefined) {\n merged[key as keyof typeof merged] = value\n }\n }\n }\n\n return merged\n}\n\n/**\n * Extracts the inline schema from a media-type `content` map.\n *\n * Prefers `preferredContentType` when given; otherwise uses the first key in the map.\n * Returns `null` when `content` is absent, the schema is missing, or the schema is a `$ref`.\n *\n * @example\n * ```ts\n * extractSchemaFromContent(operation.content, 'application/json')\n * // SchemaObject | null\n * ```\n */\nexport function extractSchemaFromContent(content: Record<string, unknown> | undefined, preferredContentType?: ContentType): SchemaObject | null {\n if (!content) return null\n\n const firstContentType = Object.keys(content)[0] ?? 'application/json'\n const targetContentType = preferredContentType ?? firstContentType\n const contentSchema = content[targetContentType] as { schema?: SchemaObject } | undefined\n const schema = contentSchema?.schema\n\n if (schema && '$ref' in schema) return null\n return schema ?? null\n}\n\n/**\n * Walks a schema tree and collects the names of all `#/components/schemas/<name>` `$ref`s.\n */\nfunction* collectRefs(schema: unknown): Generator<string, void, undefined> {\n if (Array.isArray(schema)) {\n for (const item of schema) yield* collectRefs(item)\n return\n }\n\n if (schema && typeof schema === 'object') {\n for (const key in schema) {\n const value = (schema as Record<string, unknown>)[key]\n if (!(key === '$ref' && typeof value === 'string')) {\n yield* collectRefs(value)\n continue\n }\n if (value.startsWith(SCHEMA_REF_PREFIX)) {\n const name = value.slice(SCHEMA_REF_PREFIX.length)\n if (name) yield name\n }\n }\n }\n}\n\n/**\n * Returns a copy of `schemas` topologically sorted by `$ref` dependency.\n *\n * Referenced schemas appear before the schemas that depend on them, so code generators\n * can emit types in the correct order. Cycles are silently skipped.\n *\n * @example\n * ```ts\n * const sorted = sortSchemas({ Order: orderSchema, Pet: petSchema })\n * // Pet appears before Order when Order.$ref points at Pet\n * ```\n */\nexport function sortSchemas(schemas: Record<string, SchemaObject>): Record<string, SchemaObject> {\n const deps = new Map<string, string[]>()\n\n for (const [name, schema] of Object.entries(schemas)) {\n deps.set(name, [...new Set(collectRefs(schema))])\n }\n\n const sorted: string[] = []\n const visited = new Set<string>()\n\n function visit(name: string, stack: Set<string>) {\n if (visited.has(name) || stack.has(name)) return\n stack.add(name)\n for (const child of deps.get(name) ?? []) {\n if (deps.has(child)) visit(child, stack)\n }\n stack.delete(name)\n visited.add(name)\n sorted.push(name)\n }\n\n for (const name of Object.keys(schemas)) {\n visit(name, new Set())\n }\n\n const result: Record<string, SchemaObject> = {}\n for (const name of sorted) result[name] = schemas[name]!\n return result\n}\n\nconst semanticSuffixes: Record<SchemaSourceMode, string> = {\n schemas: 'Schema',\n responses: 'Response',\n requestBodies: 'Request',\n}\n\nfunction getSemanticSuffix(source: SchemaSourceMode): string {\n return semanticSuffixes[source]\n}\n\nfunction resolveSchemaRef(document: Document, schema: SchemaObject): SchemaObject {\n if (!isReference(schema)) return schema\n const resolved = resolveRef<SchemaObject>(document, schema.$ref)\n return resolved && !isReference(resolved) ? resolved : schema\n}\n\n/**\n * Collects component schemas from one or more sources and resolves name collisions.\n *\n * Sources default to `['schemas', 'requestBodies', 'responses']`. Returned schemas are\n * topologically sorted by `$ref` dependency so generators emit types in the correct order.\n *\n * When two or more schemas normalize to the same PascalCase name:\n * - Same source → numeric suffix (`2`, `3`, …).\n * - Different sources → semantic suffix (`Schema`, `Response`, `Request`).\n *\n * @example\n * ```ts\n * const { schemas, nameMapping } = getSchemas(document, { contentType: 'application/json' })\n * ```\n */\nexport function getSchemas(document: Document, { contentType }: GetSchemasOptions): GetSchemasResult {\n const components = document.components\n\n const candidates: SchemaWithMetadata[] = [\n ...Object.entries((components?.schemas as Record<string, SchemaObject>) ?? {}).map(([name, schema]) => ({\n schema: resolveSchemaRef(document, schema),\n source: 'schemas' as const,\n originalName: name,\n })),\n ...(['responses', 'requestBodies'] as const).flatMap((source) =>\n Object.entries(components?.[source] ?? {}).flatMap(([name, item]) => {\n const schema = extractSchemaFromContent((item as { content?: Record<string, unknown> }).content, contentType)\n return schema\n ? [\n {\n schema: resolveSchemaRef(document, schema),\n source,\n originalName: name,\n },\n ]\n : []\n }),\n ),\n ]\n\n const normalizedNames = new Map<string, SchemaWithMetadata[]>()\n for (const item of candidates) {\n const key = pascalCase(item.originalName)\n const bucket = normalizedNames.get(key) ?? []\n bucket.push(item)\n normalizedNames.set(key, bucket)\n }\n\n const schemas: Record<string, SchemaObject> = {}\n const nameMapping = new Map<string, string>()\n\n for (const [, items] of normalizedNames) {\n const isSingle = items.length === 1\n let hasMultipleSources = false\n if (!isSingle) {\n const firstSource = items[0]!.source\n for (let i = 1; i < items.length; i++) {\n if (items[i]!.source !== firstSource) {\n hasMultipleSources = true\n break\n }\n }\n }\n\n items.forEach((item, index) => {\n const suffix = isSingle ? '' : hasMultipleSources ? getSemanticSuffix(item.source) : index === 0 ? '' : String(index + 1)\n const uniqueName = item.originalName + suffix\n schemas[uniqueName] = item.schema\n nameMapping.set(`#/components/${item.source}/${item.originalName}`, uniqueName)\n })\n }\n\n return { schemas: sortSchemas(schemas), nameMapping }\n}\n\n/**\n * Resolves the AST type descriptor for a date/time format, honoring the `dateType` option.\n * Returns `null` when `dateType: false`, signalling the format should fall through to `string`.\n */\nexport function getDateType(\n options: ast.ParserOptions,\n format: 'date-time' | 'date' | 'time',\n): { type: 'datetime'; offset?: boolean; local?: boolean } | { type: 'date' | 'time'; representation: 'date' | 'string' } | null {\n if (!options.dateType) {\n return null\n }\n\n if (format === 'date-time') {\n if (options.dateType === 'date') {\n return { type: 'date', representation: 'date' }\n }\n if (options.dateType === 'stringOffset') {\n return { type: 'datetime', offset: true }\n }\n if (options.dateType === 'stringLocal') {\n return { type: 'datetime', local: true }\n }\n return { type: 'datetime', offset: false }\n }\n\n if (format === 'date') {\n return {\n type: 'date',\n representation: options.dateType === 'date' ? 'date' : 'string',\n }\n }\n\n // time\n return {\n type: 'time',\n representation: options.dateType === 'date' ? 'date' : 'string',\n }\n}\n\n/**\n * Collects the shared metadata fields passed to every `createSchema` call.\n */\nexport function buildSchemaNode(schema: SchemaObject, name: string | null | undefined, nullable: true | undefined, defaultValue: unknown) {\n return {\n name,\n nullable,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n readOnly: schema.readOnly,\n writeOnly: schema.writeOnly,\n default: defaultValue,\n example: schema.example,\n format: schema.format,\n } as const\n}\n\n/**\n * Returns all request body content type keys for an operation.\n *\n * The requestBody is dereferenced **in-place** when it is a `$ref` — the same mutation\n * that `getRequestSchema` already performs — so that the returned list accurately reflects\n * the available content types even for referenced bodies.\n *\n * @example\n * ```ts\n * getRequestBodyContentTypes(document, operation)\n * // ['application/json', 'multipart/form-data']\n * ```\n */\nexport function getRequestBodyContentTypes(document: Document, operation: Operation): string[] {\n if (operation.schema.requestBody) {\n operation.schema.requestBody = dereferenceWithRef(document, operation.schema.requestBody)\n }\n\n const body = operation.schema.requestBody as { content?: Record<string, unknown> } | undefined\n if (!body) return []\n\n // dereferenceWithRef keeps $ref but spreads all resolved fields (including `content`).\n // Do not bail out on isReference — the content is already present on the merged object.\n return body.content ? Object.keys(body.content) : []\n}\n","import { URLPath } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport BaseOas from 'oas'\nimport { DEFAULT_PARSER_OPTIONS, enumExtensionKeys, SCHEMA_REF_PREFIX, typeOptionMap } from './constants.ts'\nimport { isDiscriminator, isNullable, isReference } from './guards.ts'\nimport { resolveRef } from './refs.ts'\nimport {\n buildSchemaNode,\n flattenSchema,\n getDateType,\n getMediaType,\n getParameters,\n getPrimitiveType,\n getRequestBodyContentTypes,\n getRequestSchema,\n getResponseSchema,\n getSchemas,\n getSchemaType,\n} from './resolvers.ts'\nimport type { ContentType, Document, Operation, ReferenceObject, SchemaObject } from './types.ts'\n\n/**\n * Parser context holding the raw OpenAPI document and optional content-type override.\n *\n * Passed to schema and operation converters to access the full specification\n * and handle content negotiation when multiple media types are available.\n */\nexport type OasParserContext = {\n document: Document\n contentType?: ContentType\n}\n\n/**\n * The object returned by {@link createSchemaParser}.\n * Contains parser functions bound to a specific document.\n */\nexport type SchemaParser = {\n parseSchema: (entry: { schema: SchemaObject; name?: string | null }, options?: Partial<ast.ParserOptions>) => ast.SchemaNode\n parseOperation: (options: ast.ParserOptions, operation: Operation) => ast.OperationNode\n parseParameter: (options: ast.ParserOptions, param: Record<string, unknown>) => ast.ParameterNode\n}\n\n/**\n * Pre-computed per-schema context passed to every schema converter.\n *\n * Centralizes schema derivations (type resolution, defaults, options) to avoid repeated\n * computation across all conversion branches. The `type` field is normalized from OAS 3.1\n * multi-type arrays to a single string.\n */\ntype SchemaContext = {\n schema: SchemaObject\n name: string | null | undefined\n nullable: true | undefined\n defaultValue: unknown\n /**\n * Normalized single type string (first element when OAS 3.1 multi-type array).\n */\n type: string | undefined\n rawOptions: Partial<ast.ParserOptions> | undefined\n options: ast.ParserOptions\n}\n\n/**\n * Normalizes malformed `{ type: 'array', enum: [...] }` schemas by moving enum values into items.\n *\n * This pattern violates the OpenAPI spec but appears in real specs. The fix moves enum values\n * from the array to its items sub-schema, making them valid for downstream processing.\n *\n * @note This is a defensive measure for robustness with non-compliant specs.\n */\nfunction normalizeArrayEnum(schema: SchemaObject): SchemaObject {\n const isItemsObject = typeof schema.items === 'object' && !Array.isArray(schema.items)\n const normalizedItems: SchemaObject = {\n ...(isItemsObject ? (schema.items as SchemaObject) : {}),\n enum: schema.enum,\n }\n const { enum: _enum, ...schemaWithoutEnum } = schema\n\n return { ...schemaWithoutEnum, items: normalizedItems } as SchemaObject\n}\n\n/**\n * Factory function that creates schema and operation converters for a given OpenAPI context.\n *\n * Returns closures that share mutable state (`resolvingRefs` set for cycle detection).\n * Each converter branch (`convertRef`, `convertAllOf`, etc.) mutually recursively calls `parseSchema`,\n * made possible by hoisting of function declarations.\n *\n * @internal\n */\nexport function createSchemaParser(ctx: OasParserContext) {\n const document = ctx.document\n\n // Branch handlers — each converts one OAS schema pattern to a SchemaNode.\n\n /**\n * Tracks `$ref` paths that are currently being resolved to prevent infinite\n * recursion when schemas contain circular references (e.g. `Pet → parent → Pet`).\n */\n const resolvingRefs = new Set<string>()\n\n /**\n * Cache of already-resolved `$ref` schemas within this parser instance.\n *\n * Without this, the same referenced schema (e.g. `customer`) is fully re-expanded\n * every time it appears as a `$ref` in a different parent schema. In heavily\n * cross-referenced specs like Stripe (~1 400 schemas), this causes exponential\n * blowup — `customer` alone may be referenced from dozens of top-level schemas,\n * each triggering a fresh recursive expansion of its entire sub-tree.\n *\n * Memoizing by `$ref` path reduces the overall work from O(2^depth) to O(N)\n * where N is the number of unique schema names.\n */\n const resolvedRefCache = new Map<string, ast.SchemaNode | null>()\n\n /**\n * Converts a `$ref` schema into a `RefSchemaNode`.\n *\n * The resolved schema is stored in `node.schema`. Usage-site sibling fields\n * (description, readOnly, nullable, etc.) are stored directly on the ref node.\n * Use `syncSchemaRef(node)` in printers to get a merged view of both.\n * Circular refs are detected via `resolvingRefs` and leave `schema` as `undefined`.\n */\n function convertRef({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n let resolvedSchema: ast.SchemaNode | null = null\n const refPath = schema.$ref\n if (refPath && !resolvingRefs.has(refPath)) {\n if (!resolvedRefCache.has(refPath)) {\n try {\n const referenced = resolveRef<SchemaObject>(document, refPath)\n if (referenced) {\n resolvingRefs.add(refPath)\n resolvedSchema = parseSchema({ schema: referenced }, rawOptions)\n resolvingRefs.delete(refPath)\n }\n } catch {\n // Ref cannot be resolved in this document (e.g. unit tests with minimal documents).\n }\n resolvedRefCache.set(refPath, resolvedSchema)\n }\n resolvedSchema = resolvedRefCache.get(refPath) ?? null\n }\n\n return ast.createSchema({\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n type: 'ref',\n name: ast.extractRefName(schema.$ref!),\n ref: schema.$ref,\n schema: resolvedSchema,\n })\n }\n\n /**\n * Converts an `allOf` schema into a flattened node or an `IntersectionSchemaNode`.\n */\n function convertAllOf({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n if (\n schema.allOf!.length === 1 &&\n !schema.properties &&\n !(Array.isArray(schema.required) && schema.required.length) &&\n schema.additionalProperties === undefined\n ) {\n const [memberSchema] = schema.allOf as Array<SchemaObject | ReferenceObject>\n const memberNode = parseSchema({ schema: memberSchema! as SchemaObject, name: null }, rawOptions)\n const { kind: _kind, ...memberNodeProps } = memberNode\n const mergedNullable = nullable || memberNode.nullable || undefined\n const mergedDefault = schema.default === null && mergedNullable ? undefined : (schema.default ?? memberNode.default)\n\n return ast.createSchema({\n ...memberNodeProps,\n name,\n title: schema.title ?? memberNode.title,\n description: schema.description ?? memberNode.description,\n deprecated: schema.deprecated ?? memberNode.deprecated,\n nullable: mergedNullable,\n readOnly: schema.readOnly ?? memberNode.readOnly,\n writeOnly: schema.writeOnly ?? memberNode.writeOnly,\n default: mergedDefault,\n example: schema.example ?? memberNode.example,\n pattern: schema.pattern ?? ('pattern' in memberNode ? memberNode.pattern : undefined),\n format: schema.format ?? memberNode.format,\n } as ast.DistributiveOmit<ast.SchemaNode, 'kind'>)\n }\n\n const filteredDiscriminantValues: Array<{\n propertyName: string\n value: string\n }> = []\n const allOfMembers: Array<ast.SchemaNode> = (schema.allOf as Array<SchemaObject | ReferenceObject>)\n .filter((item) => {\n if (!isReference(item) || !name) return true\n const deref = resolveRef<SchemaObject>(document, item.$ref)\n if (!deref || !isDiscriminator(deref)) return true\n const parentUnion = deref.oneOf ?? deref.anyOf\n if (!parentUnion) return true\n const childRef = `${SCHEMA_REF_PREFIX}${name}`\n const inOneOf = parentUnion.some((oneOfItem) => isReference(oneOfItem) && oneOfItem.$ref === childRef)\n const inMapping = Object.values(deref.discriminator.mapping ?? {}).some((v) => v === childRef)\n if (inOneOf || inMapping) {\n const discriminatorValue = ast.findDiscriminator(deref.discriminator.mapping, childRef)\n if (discriminatorValue) {\n filteredDiscriminantValues.push({\n propertyName: deref.discriminator.propertyName,\n value: discriminatorValue,\n })\n }\n return false\n }\n return true\n })\n .map((s) => parseSchema({ schema: s as SchemaObject }, rawOptions))\n\n const syntheticStart = allOfMembers.length\n\n if (Array.isArray(schema.required) && schema.required.length) {\n const outerKeys = schema.properties ? new Set(Object.keys(schema.properties)) : new Set<string>()\n const missingRequired = schema.required.filter((key) => !outerKeys.has(key))\n\n if (missingRequired.length) {\n const resolvedMembers = (schema.allOf as Array<SchemaObject | ReferenceObject>).flatMap((item) => {\n if (!isReference(item)) return [item as SchemaObject]\n const deref = resolveRef<SchemaObject>(document, item.$ref)\n return deref && !isReference(deref) ? [deref] : []\n })\n\n for (const key of missingRequired) {\n for (const resolved of resolvedMembers) {\n if (resolved.properties?.[key]) {\n allOfMembers.push(\n parseSchema(\n {\n schema: {\n properties: { [key]: resolved.properties[key] },\n required: [key],\n } as SchemaObject,\n },\n rawOptions,\n ),\n )\n break\n }\n }\n }\n }\n }\n\n if (schema.properties) {\n const { allOf: _allOf, ...schemaWithoutAllOf } = schema\n allOfMembers.push(parseSchema({ schema: schemaWithoutAllOf }, rawOptions))\n }\n\n for (const { propertyName, value } of filteredDiscriminantValues) {\n allOfMembers.push(ast.createDiscriminantNode({ propertyName, value }))\n }\n\n return ast.createSchema({\n type: 'intersection',\n members: [...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(0, syntheticStart)), ...ast.mergeAdjacentObjectsLazy(allOfMembers.slice(syntheticStart))],\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `oneOf` / `anyOf` schema into a `UnionSchemaNode`.\n */\n function convertUnion({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n function pickDiscriminatorPropertyNode(node: ast.SchemaNode, propertyName: string): ast.SchemaNode | null {\n const objectNode = ast.narrowSchema(node, 'object')\n const discriminatorProperty = objectNode?.properties?.find((property) => property.name === propertyName)\n\n if (!discriminatorProperty) {\n return null\n }\n\n return ast.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [discriminatorProperty],\n })\n }\n\n const unionMembers = [...(schema.oneOf ?? []), ...(schema.anyOf ?? [])]\n const strategy: 'one' | 'any' = schema.oneOf ? 'one' : 'any'\n const unionBase = {\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n discriminatorPropertyName: isDiscriminator(schema) ? schema.discriminator.propertyName : undefined,\n strategy,\n }\n const discriminator = isDiscriminator(schema) ? schema.discriminator : undefined\n const sharedPropertiesNode = schema.properties\n ? (() => {\n const { oneOf: _oneOf, anyOf: _anyOf, ...schemaWithoutUnion } = schema\n const memberBaseSchema: SchemaObject = discriminator\n ? (Object.fromEntries(Object.entries(schemaWithoutUnion).filter(([key]) => key !== 'discriminator')) as SchemaObject)\n : schemaWithoutUnion\n return parseSchema({ schema: memberBaseSchema, name }, rawOptions)\n })()\n : undefined\n\n if (sharedPropertiesNode || discriminator?.mapping) {\n const members = unionMembers.map((s) => {\n const ref = isReference(s) ? s.$ref : undefined\n const discriminatorValue = ast.findDiscriminator(discriminator?.mapping, ref)\n const memberNode = parseSchema({ schema: s as SchemaObject }, rawOptions)\n\n if (!discriminatorValue || !discriminator) {\n return memberNode\n }\n\n const narrowedDiscriminatorNode = sharedPropertiesNode\n ? pickDiscriminatorPropertyNode(\n ast.setDiscriminatorEnum({\n node: sharedPropertiesNode,\n propertyName: discriminator.propertyName,\n values: [discriminatorValue],\n }),\n discriminator.propertyName,\n )\n : undefined\n\n return ast.createSchema({\n type: 'intersection',\n members: [\n memberNode,\n narrowedDiscriminatorNode ??\n ast.createDiscriminantNode({\n propertyName: discriminator.propertyName,\n value: discriminatorValue,\n }),\n ],\n })\n })\n\n const unionNode = ast.createSchema({\n type: 'union',\n ...unionBase,\n members,\n })\n\n if (!sharedPropertiesNode) {\n return unionNode\n }\n\n return ast.createSchema({\n type: 'intersection',\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n members: [unionNode, sharedPropertiesNode],\n })\n }\n\n return ast.createSchema({\n type: 'union',\n ...unionBase,\n members: ast.simplifyUnion(unionMembers.map((s) => parseSchema({ schema: s as SchemaObject }, rawOptions))),\n })\n }\n\n /**\n * Converts an OAS 3.1 `const` schema into a null scalar or a single-value `EnumSchemaNode`.\n */\n function convertConst({ schema, name, nullable, defaultValue }: SchemaContext): ast.SchemaNode {\n const constValue = schema.const\n\n if (constValue === null) {\n return ast.createSchema({\n type: 'null',\n primitive: 'null',\n name,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n format: schema.format,\n })\n }\n\n const constPrimitive = getPrimitiveType(typeof constValue === 'number' ? 'number' : typeof constValue === 'boolean' ? 'boolean' : 'string')\n return ast.createSchema({\n type: 'enum',\n primitive: constPrimitive,\n enumValues: [constValue as string | number | boolean],\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a format-annotated schema into a special-type `SchemaNode`.\n * Returns `null` when the format should fall through to string handling (`dateType: false`).\n */\n function convertFormat({ schema, name, nullable, defaultValue, options }: SchemaContext): ast.SchemaNode | null {\n const base = buildSchemaNode(schema, name, nullable, defaultValue)\n\n if (schema.format === 'int64') {\n return ast.createSchema({\n type: options.integerType === 'bigint' ? 'bigint' : 'integer',\n primitive: 'integer',\n ...base,\n min: schema.minimum,\n max: schema.maximum,\n exclusiveMinimum: typeof schema.exclusiveMinimum === 'number' ? schema.exclusiveMinimum : undefined,\n exclusiveMaximum: typeof schema.exclusiveMaximum === 'number' ? schema.exclusiveMaximum : undefined,\n })\n }\n\n if (schema.format === 'date-time' || schema.format === 'date' || schema.format === 'time') {\n const dateType = getDateType(options, schema.format)\n if (!dateType) return null\n\n if (dateType.type === 'datetime') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'datetime',\n offset: dateType.offset,\n local: dateType.local,\n })\n }\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: dateType.type,\n representation: dateType.representation,\n })\n }\n\n const specialType = getSchemaType(schema.format!)\n if (!specialType) return null\n\n const specialPrimitive: ast.PrimitiveSchemaType = specialType === 'number' || specialType === 'integer' || specialType === 'bigint' ? specialType : 'string'\n\n if (specialType === 'number' || specialType === 'integer' || specialType === 'bigint') {\n return ast.createSchema({\n ...base,\n primitive: specialPrimitive,\n type: specialType,\n })\n }\n if (specialType === 'url') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'url',\n min: schema.minLength,\n max: schema.maxLength,\n })\n }\n if (specialType === 'ipv4') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'ipv4',\n })\n }\n if (specialType === 'ipv6') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: 'ipv6',\n })\n }\n if (specialType === 'uuid' || specialType === 'email') {\n return ast.createSchema({\n ...base,\n primitive: 'string' as const,\n type: specialType,\n min: schema.minLength,\n max: schema.maxLength,\n })\n }\n\n return ast.createSchema({\n ...base,\n primitive: specialPrimitive,\n type: specialType as ast.ScalarSchemaType,\n })\n }\n\n /**\n * Converts an `enum` schema into an `EnumSchemaNode`.\n */\n function convertEnum({ schema, name, nullable, type, rawOptions }: SchemaContext): ast.SchemaNode {\n if (type === 'array') {\n return parseSchema({ schema: normalizeArrayEnum(schema), name }, rawOptions)\n }\n\n const nullInEnum = schema.enum!.includes(null)\n const filteredValues = (nullInEnum ? schema.enum!.filter((v) => v !== null) : schema.enum!) as Array<string | number | boolean>\n const enumNullable = nullable || nullInEnum || undefined\n const enumDefault = schema.default === null && enumNullable ? undefined : schema.default\n const enumPrimitive = getPrimitiveType(type)\n\n const enumBase = {\n type: 'enum' as const,\n primitive: enumPrimitive,\n name,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n nullable: enumNullable,\n readOnly: schema.readOnly,\n writeOnly: schema.writeOnly,\n default: enumDefault,\n example: schema.example,\n format: schema.format,\n }\n\n const extensionKey = enumExtensionKeys.find((key) => key in schema)\n if (extensionKey || enumPrimitive === 'number' || enumPrimitive === 'integer' || enumPrimitive === 'boolean') {\n const enumPrimitiveType = (enumPrimitive === 'number' || enumPrimitive === 'integer' ? 'number' : enumPrimitive === 'boolean' ? 'boolean' : 'string') as\n | 'number'\n | 'boolean'\n | 'string'\n const rawEnumNames = extensionKey ? ((schema as Record<string, unknown>)[extensionKey] as Array<string | number>) : undefined\n const uniqueValues = [...new Set(filteredValues)]\n const seenNames = new Set<string>()\n\n return ast.createSchema({\n ...enumBase,\n primitive: enumPrimitiveType,\n namedEnumValues: uniqueValues\n .map((value, index) => ({\n name: String(rawEnumNames?.[index] ?? value),\n value,\n primitive: enumPrimitiveType,\n }))\n .filter((entry) => {\n if (seenNames.has(entry.name)) return false\n seenNames.add(entry.name)\n return true\n }),\n })\n }\n\n return ast.createSchema({\n ...enumBase,\n enumValues: [...new Set(filteredValues)],\n })\n }\n\n /**\n * Converts an object-like schema into an `ObjectSchemaNode`.\n */\n function convertObject({ schema, name, nullable, defaultValue, rawOptions, options }: SchemaContext): ast.SchemaNode {\n const properties: Array<ast.PropertyNode> = schema.properties\n ? Object.entries(schema.properties).map(([propName, propSchema]) => {\n const required = Array.isArray(schema.required) ? schema.required.includes(propName) : !!schema.required\n const resolvedPropSchema = propSchema as SchemaObject\n const propNullable = isNullable(resolvedPropSchema)\n\n const resolvedChildName = ast.childName(name, propName)\n const propNode = parseSchema({ schema: resolvedPropSchema, name: resolvedChildName }, rawOptions)\n const schemaNode = (() => {\n const node = ast.setEnumName(propNode, name, propName, options.enumSuffix)\n const tupleNode = ast.narrowSchema(node, 'tuple')\n if (tupleNode?.items) {\n const namedItems = tupleNode.items.map((item) => ast.setEnumName(item, name, propName, options.enumSuffix))\n if (namedItems.some((item, i) => item !== tupleNode.items![i])) {\n return { ...tupleNode, items: namedItems }\n }\n }\n return node\n })()\n\n return ast.createProperty({\n name: propName,\n schema: {\n ...schemaNode,\n nullable: schemaNode.type === 'null' ? undefined : propNullable || undefined,\n },\n required,\n })\n })\n : []\n\n const additionalProperties = schema.additionalProperties\n const additionalPropertiesNode: ast.SchemaNode | boolean | undefined = (() => {\n if (additionalProperties === true) return true\n if (additionalProperties === false) return false\n if (additionalProperties && Object.keys(additionalProperties).length > 0) {\n return parseSchema({ schema: additionalProperties as SchemaObject }, rawOptions)\n }\n if (additionalProperties) return ast.createSchema({ type: typeOptionMap.get(options.unknownType)! })\n return undefined\n })()\n\n const rawPatternProperties = 'patternProperties' in schema ? schema.patternProperties : undefined\n\n const patternProperties = rawPatternProperties\n ? Object.fromEntries(\n Object.entries(rawPatternProperties).map(([pattern, patternSchema]) => [\n pattern,\n patternSchema === true || (typeof patternSchema === 'object' && Object.keys(patternSchema).length === 0)\n ? ast.createSchema({\n type: typeOptionMap.get(options.unknownType)!,\n })\n : parseSchema({ schema: patternSchema as SchemaObject }, rawOptions),\n ]),\n )\n : undefined\n\n const objectNode: ast.SchemaNode = ast.createSchema({\n type: 'object',\n primitive: 'object',\n properties,\n additionalProperties: additionalPropertiesNode,\n patternProperties,\n minProperties: schema.minProperties,\n maxProperties: schema.maxProperties,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n\n if (isDiscriminator(schema) && schema.discriminator.mapping) {\n const discPropName = schema.discriminator.propertyName\n const values = Object.keys(schema.discriminator.mapping)\n const enumName = name ? ast.enumPropName(name, discPropName, options.enumSuffix) : undefined\n return ast.setDiscriminatorEnum({\n node: objectNode,\n propertyName: discPropName,\n values,\n enumName,\n })\n }\n\n return objectNode\n }\n\n /**\n * Converts an OAS 3.1 `prefixItems` tuple into a `TupleSchemaNode`.\n */\n function convertTuple({ schema, name, nullable, defaultValue, rawOptions }: SchemaContext): ast.SchemaNode {\n const tupleItems = (schema.prefixItems ?? []).map((item) => parseSchema({ schema: item as SchemaObject }, rawOptions))\n const rest = schema.items ? parseSchema({ schema: schema.items as SchemaObject }, rawOptions) : ast.createSchema({ type: 'any' })\n\n return ast.createSchema({\n type: 'tuple',\n primitive: 'array',\n items: tupleItems,\n rest,\n min: schema.minItems,\n max: schema.maxItems,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'array'` schema into an `ArraySchemaNode`.\n */\n function convertArray({ schema, name, nullable, defaultValue, rawOptions, options }: SchemaContext): ast.SchemaNode {\n const rawItems = schema.items as SchemaObject | undefined\n const itemName = rawItems?.enum?.length && name ? ast.enumPropName(null, name, options.enumSuffix) : undefined\n const items = rawItems ? [parseSchema({ schema: rawItems, name: itemName }, rawOptions)] : []\n\n return ast.createSchema({\n type: 'array',\n primitive: 'array',\n items,\n min: schema.minItems,\n max: schema.maxItems,\n unique: schema.uniqueItems ?? undefined,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'string'` schema into a `StringSchemaNode`.\n */\n function convertString({ schema, name, nullable, defaultValue }: SchemaContext): ast.SchemaNode {\n return ast.createSchema({\n type: 'string',\n primitive: 'string',\n min: schema.minLength,\n max: schema.maxLength,\n pattern: schema.pattern,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'number'` or `type: 'integer'` schema.\n */\n function convertNumeric({ schema, name, nullable, defaultValue }: SchemaContext, type: 'number' | 'integer'): ast.SchemaNode {\n return ast.createSchema({\n type,\n primitive: type,\n min: schema.minimum,\n max: schema.maximum,\n exclusiveMinimum: typeof schema.exclusiveMinimum === 'number' ? schema.exclusiveMinimum : undefined,\n exclusiveMaximum: typeof schema.exclusiveMaximum === 'number' ? schema.exclusiveMaximum : undefined,\n multipleOf: schema.multipleOf,\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts a `type: 'boolean'` schema.\n */\n function convertBoolean({ schema, name, nullable, defaultValue }: SchemaContext): ast.SchemaNode {\n return ast.createSchema({\n type: 'boolean',\n primitive: 'boolean',\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n /**\n * Converts an explicit `type: 'null'` schema.\n */\n function convertNull({ schema, name, nullable }: SchemaContext): ast.SchemaNode {\n return ast.createSchema({\n type: 'null',\n primitive: 'null',\n name,\n title: schema.title,\n description: schema.description,\n deprecated: schema.deprecated,\n nullable,\n format: schema.format,\n })\n }\n\n /**\n * Central dispatcher that converts an OAS `SchemaObject` into a `SchemaNode`.\n *\n * Dispatch order (first match wins): `$ref` → `allOf` → `oneOf`/`anyOf` → `const` → `format`\n * → octet-stream blob → multi-type array → constraint-inferred type → `enum` → object/array/tuple/scalar\n * → empty-schema fallback (`emptySchemaType` option).\n */\n function parseSchema({ schema, name }: { schema: SchemaObject; name?: string | null }, rawOptions?: Partial<ast.ParserOptions>): ast.SchemaNode {\n const options: ast.ParserOptions = {\n ...DEFAULT_PARSER_OPTIONS,\n ...rawOptions,\n }\n const flattenedSchema = flattenSchema(schema)\n if (flattenedSchema && flattenedSchema !== schema) {\n return parseSchema({ schema: flattenedSchema, name }, rawOptions)\n }\n\n const nullable = isNullable(schema) || undefined\n const defaultValue = schema.default === null && nullable ? undefined : schema.default\n const type = Array.isArray(schema.type) ? schema.type[0] : schema.type\n\n const ctx: SchemaContext = {\n schema,\n name,\n nullable,\n defaultValue,\n type,\n rawOptions,\n options,\n }\n\n if (isReference(schema)) return convertRef(ctx)\n\n if (schema.allOf?.length) return convertAllOf(ctx)\n const unionMembers = [...(schema.oneOf ?? []), ...(schema.anyOf ?? [])]\n if (unionMembers.length) return convertUnion(ctx)\n\n if ('const' in schema && schema.const !== undefined) return convertConst(ctx)\n\n if (schema.format) {\n const formatResult = convertFormat(ctx)\n if (formatResult) return formatResult\n }\n\n if (schema.type === 'string' && schema.contentMediaType === 'application/octet-stream') {\n return ast.createSchema({\n type: 'blob',\n primitive: 'string',\n ...buildSchemaNode(schema, name, nullable, defaultValue),\n })\n }\n\n if (Array.isArray(schema.type) && schema.type.length > 1) {\n const nonNullTypes = schema.type.filter((t) => t !== 'null') as string[]\n const arrayNullable = schema.type.includes('null') || nullable || undefined\n\n if (nonNullTypes.length > 1) {\n return ast.createSchema({\n type: 'union',\n members: nonNullTypes.map((t) => parseSchema({ schema: { ...schema, type: t } as SchemaObject, name }, rawOptions)),\n ...buildSchemaNode(schema, name, arrayNullable, defaultValue),\n })\n }\n }\n\n if (!type) {\n if (schema.minLength !== undefined || schema.maxLength !== undefined || schema.pattern !== undefined) {\n return convertString(ctx)\n }\n if (schema.minimum !== undefined || schema.maximum !== undefined) {\n return convertNumeric(ctx, 'number')\n }\n }\n\n if (schema.enum?.length) return convertEnum(ctx)\n if (type === 'object' || schema.properties || schema.additionalProperties || 'patternProperties' in schema) return convertObject(ctx)\n if ('prefixItems' in schema) return convertTuple(ctx)\n if (type === 'array' || 'items' in schema) return convertArray(ctx)\n if (type === 'string') return convertString(ctx)\n if (type === 'number') return convertNumeric(ctx, 'number')\n if (type === 'integer') return convertNumeric(ctx, 'integer')\n if (type === 'boolean') return convertBoolean(ctx)\n if (type === 'null') return convertNull(ctx)\n\n const emptyType = typeOptionMap.get(options.emptySchemaType)!\n return ast.createSchema({\n type: emptyType as ast.ScalarSchemaType,\n name,\n title: schema.title,\n description: schema.description,\n format: schema.format,\n })\n }\n\n /**\n * Converts a dereferenced OAS parameter object into a `ParameterNode`.\n */\n function parseParameter(options: ast.ParserOptions, param: Record<string, unknown>): ast.ParameterNode {\n const required = (param['required'] as boolean | undefined) ?? false\n\n const schema: ast.SchemaNode = param['schema']\n ? parseSchema({ schema: param['schema'] as SchemaObject }, options)\n : ast.createSchema({ type: typeOptionMap.get(options.unknownType)! })\n\n return ast.createParameter({\n name: param['name'] as string,\n in: param['in'] as ast.ParameterLocation,\n schema: {\n ...schema,\n description: (param['description'] as string | undefined) ?? schema.description,\n },\n required,\n })\n }\n\n /**\n * Reads the inline `requestBody` metadata (description / required) that OAS exposes\n * outside the schema itself. Returns an empty object when the request body is missing or a `$ref`.\n */\n function getRequestBodyMeta(operation: Operation): {\n description?: string\n required: boolean\n } {\n const body = operation.schema.requestBody as { description?: string; required?: boolean } | undefined\n if (!body) return { required: false }\n\n // After getRequestBodyContentTypes has run, body may still carry $ref but the\n // resolved fields (description, required, content) are already spread onto it.\n return {\n description: body.description,\n required: body.required === true,\n }\n }\n\n /**\n * Reads the inline response object (not a `$ref`) and returns its description plus its `content` map.\n */\n function getResponseMeta(responseObj: unknown): {\n description?: string\n content?: Record<string, unknown>\n } {\n if (typeof responseObj !== 'object' || responseObj === null || Array.isArray(responseObj)) return {}\n\n const inline = responseObj as {\n description?: string\n content?: Record<string, unknown>\n }\n return { description: inline.description, content: inline.content }\n }\n\n /**\n * Collects property names whose schema has a truthy boolean flag (`readOnly` or `writeOnly`).\n * `$ref` entries are skipped since their flags live on the dereferenced target.\n */\n function collectPropertyKeysByFlag(schema: SchemaObject | null, flag: 'readOnly' | 'writeOnly'): string[] | null {\n if (!schema?.properties) return null\n\n const keys: string[] = []\n for (const key in schema.properties) {\n const prop = schema.properties[key]\n if (prop && !isReference(prop) && (prop as Record<string, unknown>)[flag]) {\n keys.push(key)\n }\n }\n return keys.length ? keys : null\n }\n\n /**\n * Converts an OAS `Operation` into an `OperationNode`.\n */\n function parseOperation(options: ast.ParserOptions, operation: Operation): ast.OperationNode {\n const parameters: Array<ast.ParameterNode> = getParameters(document, operation).map((param) =>\n parseParameter(options, param as unknown as Record<string, unknown>),\n )\n\n // Determine which content types to include in requestBody.content.\n // When a global contentType is configured, restrict to that single type.\n // Otherwise include every content type declared in the spec.\n const allContentTypes = ctx.contentType ? [ctx.contentType] : getRequestBodyContentTypes(document, operation)\n\n const requestBodyMeta = getRequestBodyMeta(operation)\n\n const content = allContentTypes.flatMap((ct) => {\n const schema = getRequestSchema(document, operation, { contentType: ct })\n if (!schema) return []\n return [\n {\n contentType: ct,\n schema: ast.syncOptionality(parseSchema({ schema }, options), requestBodyMeta.required),\n keysToOmit: collectPropertyKeysByFlag(schema, 'readOnly'),\n },\n ]\n })\n\n const requestBody =\n content.length > 0 || requestBodyMeta.description\n ? {\n description: requestBodyMeta.description,\n required: requestBodyMeta.required || undefined,\n content: content.length > 0 ? content : undefined,\n }\n : undefined\n\n const responses: Array<ast.ResponseNode> = operation.getResponseStatusCodes().map((statusCode) => {\n const responseObj = operation.getResponseByStatusCode(statusCode)\n const responseSchema = getResponseSchema(document, operation, statusCode, { contentType: ctx.contentType })\n\n const schema =\n responseSchema && Object.keys(responseSchema).length > 0\n ? parseSchema({ schema: responseSchema }, options)\n : ast.createSchema({\n type: typeOptionMap.get(options.emptySchemaType)!,\n })\n\n const { description, content } = getResponseMeta(responseObj)\n const mediaType = content ? getMediaType(Object.keys(content)[0] ?? '') : getMediaType(operation.contentType ?? '')\n\n return ast.createResponse({\n statusCode: statusCode as ast.StatusCode,\n description,\n schema,\n mediaType,\n keysToOmit: collectPropertyKeysByFlag(responseSchema, 'writeOnly'),\n })\n })\n\n const urlPath = new URLPath(operation.path)\n\n return ast.createOperation({\n operationId: operation.getOperationId(),\n method: operation.method.toUpperCase() as ast.HttpMethod,\n path: urlPath.path,\n tags: operation.getTags().map((tag) => tag.name),\n summary: operation.getSummary() || undefined,\n description: operation.getDescription() || undefined,\n deprecated: operation.isDeprecated() || undefined,\n parameters,\n requestBody,\n responses,\n })\n }\n\n return { parseSchema, parseOperation, parseParameter }\n}\n\n/**\n * Parses a single OpenAPI `SchemaObject` into a `SchemaNode`.\n *\n * Use this for targeted schema parsing when you don't need the full spec.\n * For complete spec parsing, use `parseOas()` instead which handles operations and all schemas together.\n *\n * @note Circular schema references are tracked via internal state and resolve appropriately.\n *\n * @example\n * ```ts\n * const document = yaml.parse(fs.readFileSync('openapi.yaml', 'utf8'))\n * const ctx = { document }\n * const schema = parseSchema(ctx, { schema: { type: 'string', format: 'uuid' } })\n * ```\n */\nexport function parseSchema(\n ctx: OasParserContext,\n { schema, name }: { schema: SchemaObject; name?: string },\n options?: Partial<ast.ParserOptions>,\n): ast.SchemaNode {\n return createSchemaParser(ctx).parseSchema({ schema, name }, options)\n}\n\n/**\n * Parses an OpenAPI specification into Kubb's universal `InputNode` AST.\n *\n * This is the main entry point for `@kubb/adapter-oas`. It converts OpenAPI/Swagger specs into a spec-agnostic tree\n * that downstream plugins (`plugin-ts`, `plugin-zod`, etc.) consume for code generation. No code is generated here —\n * the tree is a pure data structure representing all schemas and operations.\n *\n * Returns the AST root and a `nameMapping` for resolving schema references.\n *\n * @example\n * ```ts\n * import { parseOas } from '@kubb/adapter-oas'\n *\n * const document = await parseFromConfig(config)\n * const { root, nameMapping } = parseOas(document, { dateType: 'date', contentType: 'application/json' })\n * ```\n */\nexport function parseOas(\n document: Document,\n options: Partial<ast.ParserOptions> & { contentType?: ContentType } = {},\n): { root: ast.InputNode; nameMapping: Map<string, string> } {\n const { contentType, ...parserOptions } = options\n const mergedOptions: ast.ParserOptions = {\n ...DEFAULT_PARSER_OPTIONS,\n ...parserOptions,\n }\n\n const { schemas: schemaObjects, nameMapping } = getSchemas(document, {\n contentType,\n })\n const { parseSchema: _parseSchema, parseOperation: _parseOperation } = createSchemaParser({ document, contentType })\n\n const schemas: Array<ast.SchemaNode> = Object.entries(schemaObjects).map(([name, schema]) => _parseSchema({ schema, name }, mergedOptions))\n\n const baseOas = new BaseOas(document)\n const paths = baseOas.getPaths()\n\n const operations: Array<ast.OperationNode> = Object.entries(paths).flatMap(([, methods]) =>\n Object.entries(methods)\n .map(([, operation]) => (operation ? _parseOperation(mergedOptions, operation) : null))\n .filter((op): op is ast.OperationNode => op !== null),\n )\n\n const root = ast.createInput({ schemas, operations })\n\n return { root, nameMapping }\n}\n","import { ast } from '@kubb/core'\nimport type { SchemaNodeByType } from '@kubb/ast'\n\nexport type DiscriminatorTarget = {\n propertyName: string\n enumValues: Array<string | number | boolean>\n}\n\n/**\n * Builds a map of child schema names → discriminator patch data by scanning the given\n * top-level AST schema nodes for union schemas that carry a `discriminatorPropertyName`.\n *\n * Extracted from `applyDiscriminatorInheritance` so the streaming path can call it on a\n * small pre-parsed subset of schemas (only the discriminator parents) rather than on all\n * schemas at once.\n */\nexport function buildDiscriminatorChildMap(schemas: ast.SchemaNode[]): Map<string, DiscriminatorTarget> {\n const childMap = new Map<string, DiscriminatorTarget>()\n\n for (const schema of schemas) {\n // Case 1: top-level schema is a union (oneOf/anyOf with discriminator)\n // Case 2: top-level schema is an intersection wrapping a union (oneOf/anyOf + shared properties)\n let unionNode = ast.narrowSchema(schema, 'union')\n\n if (!unionNode) {\n const intersectionMembers = ast.narrowSchema(schema, 'intersection')?.members\n if (intersectionMembers) {\n for (const m of intersectionMembers) {\n const u = ast.narrowSchema(m, 'union')\n if (u) {\n unionNode = u\n break\n }\n }\n }\n }\n\n if (!unionNode?.discriminatorPropertyName || !unionNode.members) continue\n\n const { discriminatorPropertyName, members } = unionNode\n\n for (const member of members) {\n // Members with a discriminant value are intersections: [RefSchemaNode, ObjectSchemaNode]\n const intersectionNode = ast.narrowSchema(member, 'intersection')\n if (!intersectionNode?.members) continue\n\n let refNode: SchemaNodeByType['ref'] | null = null\n let objNode: SchemaNodeByType['object'] | null = null\n\n for (const m of intersectionNode.members) {\n refNode ??= ast.narrowSchema(m, 'ref')\n objNode ??= ast.narrowSchema(m, 'object')\n }\n\n if (!refNode?.name || !objNode) continue\n\n const prop = objNode.properties.find((p) => p.name === discriminatorPropertyName)\n const enumNode = prop ? ast.narrowSchema(prop.schema, 'enum') : null\n if (!enumNode?.enumValues?.length) continue\n\n const enumValues = enumNode.enumValues.filter((v): v is string | number | boolean => v !== null)\n if (!enumValues.length) continue\n\n const existing = childMap.get(refNode.name)\n if (!existing) {\n childMap.set(refNode.name, { propertyName: discriminatorPropertyName, enumValues: [...enumValues] })\n continue\n }\n existing.enumValues.push(...enumValues)\n }\n }\n\n return childMap\n}\n\n/**\n * Patches a single top-level `SchemaNode` with its discriminator entry (adds or replaces\n * the discriminant property). Used by the streaming path to apply patches inline per yield\n * without buffering all schemas.\n */\nexport function patchDiscriminatorNode(node: ast.SchemaNode, entry: { propertyName: string; enumValues: Array<string | number | boolean> }): ast.SchemaNode {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode) return node\n\n const { propertyName, enumValues } = entry\n const enumSchema = ast.createSchema({ type: 'enum', enumValues })\n const newProp = ast.createProperty({ name: propertyName, required: true, schema: enumSchema })\n\n const existingIdx = objectNode.properties.findIndex((p) => p.name === propertyName)\n const newProperties = existingIdx >= 0 ? objectNode.properties.map((p, i) => (i === existingIdx ? newProp : p)) : [...objectNode.properties, newProp]\n\n return { ...objectNode, properties: newProperties }\n}\n\n/**\n * Injects discriminator enum values into child schemas so they know which value identifies them.\n *\n * Finds every union schema in `input.schemas` that has a `discriminatorPropertyName`, collects the\n * enum value each union member is mapped to, then adds (or replaces) that property on the matching\n * child object schema.\n *\n * Returns a new `InputNode` — the original is never mutated.\n *\n * @example\n * ```ts\n * const { root } = parseOas(document, options)\n * const next = applyDiscriminatorInheritance(root)\n * ```\n */\nexport function applyDiscriminatorInheritance(root: ast.InputNode): ast.InputNode {\n const childMap = buildDiscriminatorChildMap(root.schemas)\n\n if (childMap.size === 0) return root\n\n return ast.transform(root, {\n schema(node, { parent }) {\n if (parent?.kind !== 'Input' || !node.name) return\n\n const entry = childMap.get(node.name)\n if (!entry) return\n\n return patchDiscriminatorNode(node, entry)\n },\n })\n}\n","import { ast } from '@kubb/core'\nimport type BaseOas from 'oas'\nimport { buildDiscriminatorChildMap, patchDiscriminatorNode } from './discriminator.ts'\nimport type { SchemaParser } from './parser.ts'\nimport { resolveServerUrl } from './resolvers.ts'\nimport type { DiscriminatorTarget } from './discriminator.ts'\nimport type { AdapterOas, Document, SchemaObject } from './types.ts'\n\nexport type PreScanResult = {\n refAliasMap: Map<string, ast.SchemaNode>\n enumNames: string[]\n circularNames: string[]\n discriminatorChildMap: Map<string, DiscriminatorTarget> | null\n}\n\n/**\n * Reads the server URL from the document's `servers` array at `serverIndex`,\n * interpolating any `serverVariables` into the URL template.\n *\n * Returns `null` when `serverIndex` is omitted or out of range.\n *\n * @example Resolve the first server\n * `resolveBaseUrl({ document, serverIndex: 0 })`\n *\n * @example Override a path variable\n * `resolveBaseUrl({ document, serverIndex: 0, serverVariables: { version: 'v2' } })`\n */\nexport function resolveBaseUrl({\n document,\n serverIndex,\n serverVariables,\n}: {\n document: Document\n serverIndex?: number\n serverVariables?: Record<string, string>\n}): string | null {\n const server = serverIndex !== undefined ? document.servers?.at(serverIndex) : undefined\n return server?.url ? resolveServerUrl(server, serverVariables) : null\n}\n\n/**\n * Parses every schema once to build the lookup structures that streaming needs upfront.\n *\n * Three things happen in this single pass:\n * - `refAliasMap` records schemas that are pure `$ref` aliases so the streaming pass can inline them.\n * - `enumNames` collects the names of every enum schema so plugins skip re-scanning the stream.\n * - `circularNames` runs cycle detection, which requires all nodes in memory simultaneously.\n * The `allNodes` array is local and drops out of scope as soon as this function returns.\n *\n * After this call, only `refAliasMap` and `discriminatorChildMap` stay alive in the adapter closure.\n * Both are proportional to the number of aliases or discriminator parents, not total schema count.\n *\n * Each schema is parsed again during the streaming pass — this is intentional.\n * Holding the parsed nodes in memory here would defeat the streaming memory benefit.\n *\n * @example\n * ```ts\n * const { refAliasMap, enumNames, circularNames } = preScan({\n * schemas,\n * parseSchema,\n * parserOptions,\n * discriminator: 'strict',\n * })\n * ```\n */\nexport function preScan({\n schemas,\n parseSchema,\n parserOptions,\n discriminator,\n}: {\n schemas: Record<string, SchemaObject>\n parseSchema: (entry: { schema: SchemaObject; name: string }, options: ast.ParserOptions) => ast.SchemaNode\n parserOptions: ast.ParserOptions\n discriminator: AdapterOas['options']['discriminator']\n}): PreScanResult {\n const allNodes: ast.SchemaNode[] = []\n const refAliasMap = new Map<string, ast.SchemaNode>()\n const enumNames: string[] = []\n const discriminatorParentNodes: ast.SchemaNode[] = []\n\n for (const [name, schema] of Object.entries(schemas)) {\n const node = parseSchema({ schema, name }, parserOptions)\n allNodes.push(node)\n if (node.type === 'ref' && node.name && node.name !== name) {\n refAliasMap.set(name, node)\n }\n if (ast.narrowSchema(node, ast.schemaTypes.enum) && node.name) {\n enumNames.push(node.name)\n }\n if (discriminator === 'inherit' && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) {\n discriminatorParentNodes.push(node)\n }\n }\n\n const circularNames = [...ast.findCircularSchemas(allNodes)]\n const discriminatorChildMap = discriminatorParentNodes.length > 0 ? buildDiscriminatorChildMap(discriminatorParentNodes) : null\n\n return { refAliasMap, enumNames, circularNames, discriminatorChildMap }\n}\n\n/**\n * Creates a lazy `InputStreamNode` from already-resolved adapter state.\n *\n * The schema and operation iterables each start a fresh parse pass on every\n * `[Symbol.asyncIterator]()` call. This lets multiple plugins consume the same\n * stream object independently without sharing a cursor or holding all nodes in memory.\n *\n * Ref aliases in `refAliasMap` are inlined during iteration: an alias entry is replaced\n * with its target's parsed node (but keeps the alias name) so plugins never receive bare `ref` nodes.\n *\n * @example\n * ```ts\n * const streamNode = createInputStream({ schemas, parseSchema, parseOperation, baseOas, parserOptions, refAliasMap, discriminatorChildMap, meta })\n * for await (const schema of streamNode.schemas) {\n * // each call to for-await restarts from the first schema\n * }\n * ```\n */\nexport function createInputStream({\n schemas,\n parseSchema,\n parseOperation,\n baseOas,\n parserOptions,\n refAliasMap,\n discriminatorChildMap,\n meta,\n}: {\n schemas: Record<string, SchemaObject>\n parseSchema: SchemaParser['parseSchema']\n parseOperation: SchemaParser['parseOperation']\n baseOas: BaseOas\n parserOptions: ast.ParserOptions\n refAliasMap: Map<string, ast.SchemaNode>\n discriminatorChildMap: Map<string, DiscriminatorTarget> | null\n meta: ast.InputMeta\n}): ast.InputStreamNode {\n const schemasIterable: AsyncIterable<ast.SchemaNode> = {\n [Symbol.asyncIterator]() {\n return (async function* () {\n for (const [name, schema] of Object.entries(schemas)) {\n // Inline ref aliases: replace the alias entry with its target's parsed node\n // (keeping the alias name). Skip the first parse entirely for alias entries\n // since that result is never used.\n const alias = refAliasMap.get(name)\n if (alias?.name && schemas[alias.name]) {\n yield { ...parseSchema({ schema: schemas[alias.name]!, name: alias.name }, parserOptions), name }\n continue\n }\n\n const parsed = parseSchema({ schema, name }, parserOptions)\n const node = discriminatorChildMap?.get(name) ? patchDiscriminatorNode(parsed, discriminatorChildMap.get(name)!) : parsed\n yield node\n }\n })()\n },\n }\n\n const operationsIterable: AsyncIterable<ast.OperationNode> = {\n [Symbol.asyncIterator]() {\n return (async function* () {\n for (const methods of Object.values(baseOas.getPaths())) {\n for (const operation of Object.values(methods)) {\n if (!operation) continue\n const node = parseOperation(parserOptions, operation)\n if (node) yield node\n }\n }\n })()\n },\n }\n\n return ast.createStreamInput(schemasIterable, operationsIterable, meta)\n}\n","import { once } from '@internals/utils'\nimport { ast, createAdapter } from '@kubb/core'\nimport type { AdapterSource } from '@kubb/core'\nimport BaseOas from 'oas'\nimport { DEFAULT_PARSER_OPTIONS } from './constants.ts'\nimport { parseDocument, parseFromConfig, validateDocument } from './factory.ts'\nimport { createSchemaParser } from './parser.ts'\nimport { getSchemas } from './resolvers.ts'\nimport { createInputStream, preScan, resolveBaseUrl } from './stream.ts'\nimport type { AdapterOas, Document } from './types.ts'\n\n/**\n * Canonical adapter name for `@kubb/adapter-oas`. Used for driver lookups.\n */\nexport const adapterOasName = 'oas' satisfies AdapterOas['name']\n\n/**\n * Default Kubb adapter for OpenAPI 2.0, 3.0, and 3.1 specifications. Reads the\n * file at `input.path`, validates it, resolves the base URL, and converts every\n * schema and operation into the universal AST that every downstream plugin\n * consumes.\n *\n * Configure once on `defineConfig`. The adapter's choices (date representation,\n * integer width, server URL) apply to every plugin in the build.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { adapterOas } from '@kubb/adapter-oas'\n * import { pluginTs } from '@kubb/plugin-ts'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * adapter: adapterOas({\n * serverIndex: 0,\n * discriminator: 'inherit',\n * dateType: 'date',\n * }),\n * plugins: [pluginTs()],\n * })\n * ```\n */\nexport const adapterOas = createAdapter<AdapterOas>((options) => {\n const {\n validate = true,\n contentType,\n serverIndex,\n serverVariables,\n discriminator = 'strict',\n dateType = DEFAULT_PARSER_OPTIONS.dateType,\n integerType = DEFAULT_PARSER_OPTIONS.integerType,\n unknownType = DEFAULT_PARSER_OPTIONS.unknownType,\n enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix,\n emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType,\n } = options\n\n const parserOptions: ast.ParserOptions = {\n ...DEFAULT_PARSER_OPTIONS,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n enumSuffix,\n }\n\n let nameMapping = new Map<string, string>()\n let parsedDocument: Document | null = null\n\n // `once` collapses concurrent callers (e.g. a build's `stream()` racing with `openInStudio()`'s `parse()`) onto one in-flight promise.\n const ensureDocument = once(async (source: AdapterSource): Promise<Document> => {\n const fresh = await parseFromConfig(source)\n if (validate) await validateDocument(fresh)\n parsedDocument = fresh\n return fresh\n })\n\n const ensureSchemas = once(async (document: Document) => {\n const result = getSchemas(document, { contentType })\n nameMapping = result.nameMapping\n return result.schemas\n })\n\n const ensureBaseOas = once((document: Document) => new BaseOas(document))\n\n const ensureSchemaParser = once((document: Document) => createSchemaParser({ document, contentType }))\n\n const ensurePreScan = once((schemas: Awaited<ReturnType<typeof ensureSchemas>>, parseSchema: ReturnType<typeof ensureSchemaParser>['parseSchema']) =>\n preScan({ schemas, parseSchema, parserOptions, discriminator }),\n )\n\n async function createStream(source: AdapterSource): Promise<ast.InputStreamNode> {\n const document = await ensureDocument(source)\n const schemas = await ensureSchemas(document)\n const { parseSchema, parseOperation } = ensureSchemaParser(document)\n const { refAliasMap, enumNames, circularNames, discriminatorChildMap } = ensurePreScan(schemas, parseSchema)\n\n return createInputStream({\n schemas,\n parseSchema,\n parseOperation,\n baseOas: ensureBaseOas(document),\n parserOptions,\n refAliasMap,\n discriminatorChildMap,\n meta: {\n title: document.info?.title,\n description: document.info?.description,\n version: document.info?.version,\n baseURL: resolveBaseUrl({ document, serverIndex, serverVariables }),\n circularNames,\n enumNames,\n },\n })\n }\n\n return {\n name: adapterOasName,\n get options() {\n return {\n validate,\n contentType,\n serverIndex,\n serverVariables,\n discriminator,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n enumSuffix,\n nameMapping,\n }\n },\n get document() {\n return parsedDocument\n },\n async validate(input, options) {\n const document = await parseDocument(input)\n await validateDocument(document, options)\n },\n getImports(node, resolve) {\n return ast.collectImports({\n node,\n nameMapping,\n resolve: (schemaName) => {\n const result = resolve(schemaName)\n if (!result) return null\n\n return ast.createImport({ name: [result.name], path: result.path })\n },\n })\n },\n async parse(source) {\n const streamNode = await createStream(source)\n\n const collect = async <T>(iter: AsyncIterable<T>): Promise<T[]> => {\n const out: T[] = []\n for await (const item of iter) out.push(item)\n return out\n }\n\n const [schemas, operations] = await Promise.all([collect(streamNode.schemas), collect(streamNode.operations)])\n\n return ast.createInput({ schemas, operations, meta: streamNode.meta })\n },\n stream: createStream,\n }\n})\n","// external packages\n\nimport type { AdapterFactoryOptions } from '@kubb/core'\nimport { ast } from '@kubb/core'\nimport type { Operation as OASOperation } from 'oas/operation'\nimport type {\n DiscriminatorObject as OASDiscriminatorObject,\n OASDocument,\n MediaTypeObject as OASMediaTypeObject,\n ResponseObject as OASResponseObject,\n SchemaObject as OASSchemaObject,\n} from 'oas/types'\nimport type { OpenAPIV3 } from 'openapi-types'\n\n/**\n * Re-exports of `openapi-types` for use by adapter consumers.\n */\nexport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'\n\n/**\n * Content-type string for selecting request/response schemas from an OpenAPI spec.\n * Supports `'application/json'` or any other media type.\n *\n * @example\n * ```ts\n * const ct: ContentType = 'application/vnd.api+json'\n * ```\n */\nexport type ContentType = 'application/json' | (string & {})\n\n/**\n * Extended OpenAPI 3.0 schema object that includes OpenAPI 3.1 and JSON Schema fields.\n * The parser uses these additional fields to handle newer spec versions.\n *\n * @example\n * ```ts\n * const schema: SchemaObject = {\n * type: 'string',\n * const: 'dog',\n * contentMediaType: 'application/octet-stream',\n * }\n * ```\n */\nexport type SchemaObject = OASSchemaObject & {\n /**\n * OAS 3.0 vendor extension: marks a schema as nullable without using `type: ['null', ...]`.\n */\n 'x-nullable'?: boolean\n /**\n * OAS 3.1: constrains the schema to a single fixed value (equivalent to a one-item `enum`).\n */\n const?: string | number | boolean | null\n /**\n * OAS 3.1: media type of the schema content. `'application/octet-stream'` on a `string` schema maps to `blob`.\n */\n contentMediaType?: string\n $ref?: string\n /**\n * OAS 3.1: positional tuple items, replacing the multi-item `items` array from OAS 3.0.\n */\n prefixItems?: Array<SchemaObject | ReferenceObject>\n /**\n * JSON Schema: maps regex patterns to sub-schemas for validating additional properties.\n */\n patternProperties?: Record<string, SchemaObject | boolean>\n /**\n * Single-schema form of `items`. Narrowed from the base type to take precedence over the tuple overload.\n */\n items?: SchemaObject | ReferenceObject\n /**\n * Enum values for this schema (narrowed from `unknown[]`).\n */\n enum?: Array<string | number | boolean | null>\n}\n\n/**\n * Maps uppercase HTTP method names to lowercase for backwards compatibility.\n *\n * @example\n * ```ts\n * HttpMethods['GET'] // 'get'\n * HttpMethods['POST'] // 'post'\n * ```\n */\nexport const HttpMethods = Object.fromEntries(Object.entries(ast.httpMethods).map(([lower, upper]) => [upper, lower])) as Record<\n Uppercase<ast.HttpMethod>,\n Lowercase<ast.HttpMethod>\n>\n\n/**\n * HTTP method as a lowercase string (`'get' | 'post' | ...`).\n */\nexport type HttpMethod = Lowercase<ast.HttpMethod>\n\n/**\n * Normalized OpenAPI document after parsing.\n */\nexport type Document = OASDocument\n\n/**\n * API operation extracted from an OpenAPI document.\n */\nexport type Operation = OASOperation\n\n/**\n * Discriminator object for `oneOf`/`anyOf` schemas in OpenAPI.\n */\nexport type DiscriminatorObject = OASDiscriminatorObject\n\n/**\n * OpenAPI reference object pointing to a schema definition via `$ref`.\n */\nexport type ReferenceObject = OpenAPIV3.ReferenceObject\n\n/**\n * OpenAPI response object from a spec that contains schema, status code, and headers.\n */\nexport type ResponseObject = OASResponseObject\n\n/**\n * OpenAPI media type object that maps a content-type string to its schema.\n */\nexport type MediaTypeObject = OASMediaTypeObject\n\n/**\n * Configuration options for the OpenAPI adapter. Controls spec validation,\n * content-type selection, server URL resolution, and how types are derived\n * from the spec.\n *\n * @example\n * ```ts\n * adapterOas({\n * validate: false,\n * dateType: 'date',\n * serverIndex: 0,\n * serverVariables: { env: 'prod' },\n * })\n * ```\n */\nexport type AdapterOasOptions = {\n /**\n * Validate the OpenAPI spec with `@readme/openapi-parser` before parsing.\n * Set to `false` only when you have a known-invalid spec you still want to\n * generate from.\n *\n * @default true\n */\n validate?: boolean\n /**\n * Preferred media type when an operation defines several. Defaults to the\n * first JSON-compatible media type found in the spec.\n */\n contentType?: ContentType\n /**\n * Index into the `servers` array from your OpenAPI spec. Used to compute the\n * base URL for plugins that need it. Most projects pick `0` for the primary\n * server. Omit to leave `baseURL` undefined.\n */\n serverIndex?: number\n /**\n * Override values for `{variable}` placeholders in the selected server URL.\n * Only used when `serverIndex` is set. Variables you do not provide use\n * their `default` value from the spec.\n *\n * @example\n * ```ts\n * // spec server: \"https://api.{env}.example.com\"\n * serverVariables: { env: 'prod' }\n * // → baseURL: \"https://api.prod.example.com\"\n * ```\n */\n serverVariables?: Record<string, string>\n /**\n * How the `discriminator` field on `oneOf`/`anyOf` schemas is interpreted.\n * - `'strict'` — child schemas stay exactly as written; the discriminator\n * narrows types at the call site but child shapes are not modified.\n * - `'inherit'` — Kubb propagates the discriminator property as a literal\n * value into each child schema, so each branch's discriminator field is\n * precisely typed.\n *\n * @default 'strict'\n */\n discriminator?: 'strict' | 'inherit'\n} & Partial<ast.ParserOptions>\n\n/**\n * Adapter options after defaults have been applied and schema name collisions resolved.\n */\nexport type AdapterOasResolvedOptions = {\n validate: boolean\n contentType: AdapterOasOptions['contentType']\n serverIndex: AdapterOasOptions['serverIndex']\n serverVariables: AdapterOasOptions['serverVariables']\n discriminator: NonNullable<AdapterOasOptions['discriminator']>\n dateType: NonNullable<AdapterOasOptions['dateType']>\n integerType: NonNullable<AdapterOasOptions['integerType']>\n unknownType: NonNullable<AdapterOasOptions['unknownType']>\n emptySchemaType: NonNullable<AdapterOasOptions['emptySchemaType']>\n enumSuffix: AdapterOasOptions['enumSuffix']\n /**\n * Map from original `$ref` paths to their collision-resolved schema names.\n * Populated after each `parse()` call.\n *\n * @example\n * ```ts\n * nameMapping.get('#/components/schemas/Order') // 'Order'\n * nameMapping.get('#/components/responses/Order') // 'OrderResponse'\n * ```\n */\n nameMapping: Map<string, string>\n}\n\n/**\n * `@kubb/core` adapter factory type for the OpenAPI adapter.\n */\nexport type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasResolvedOptions, Document>\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;CAS9D,OARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,Q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