@cerios/openapi-to-zod 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/internal.ts","../src/errors.ts","../src/batch-executor.ts","../src/utils/lru-cache.ts","../src/utils/name-utils.ts","../src/utils/pattern-utils.ts","../src/utils/string-utils.ts","../src/validators/array-validator.ts","../src/validators/composition-validator.ts","../src/validators/number-validator.ts","../src/generators/jsdoc-generator.ts","../src/validators/conditional-validator.ts","../src/validators/object-validator.ts","../src/validators/string-validator.ts","../src/generators/property-generator.ts","../src/utils/config-schemas.ts","../src/utils/config-validation.ts","../src/utils/content-type-utils.ts","../src/utils/operation-filters.ts","../src/utils/ref-resolver.ts","../src/utils/typescript-loader.ts"],"sourcesContent":["/**\n * Internal utilities shared between @cerios packages\n *\n * ⚠️ WARNING: NOT FOR PUBLIC USE\n *\n * This module exposes internal implementation details that are shared\n * between @cerios/openapi-to-zod and @cerios/openapi-to-zod-playwright.\n *\n * These APIs are NOT considered part of the public API surface and may\n * change without notice in minor or patch versions. Use at your own risk.\n *\n * @internal\n * @packageDocumentation\n */\n\n// Batch execution utilities\nexport { executeBatch, type Generator, getBatchExitCode } from \"./batch-executor\";\n\n// Property generator for schema generation\nexport { PropertyGenerator, type PropertyGeneratorContext } from \"./generators/property-generator\";\n\n// Configuration schemas and validation\nexport type { BaseOperationFilters, RequestResponseOptions } from \"./utils/config-schemas\";\nexport { OperationFiltersSchema, RequestResponseOptionsSchema } from \"./utils/config-schemas\";\nexport { formatConfigValidationError } from \"./utils/config-validation\";\n// Content type utilities\nexport {\n\ttype ContentTypeParseResult,\n\ttype FallbackContentTypeParsing,\n\tgetResponseParseMethod,\n} from \"./utils/content-type-utils\";\n// Caching utilities\nexport { LRUCache } from \"./utils/lru-cache\";\n// String and naming utilities\nexport { toCamelCase, toPascalCase } from \"./utils/name-utils\";\n\n// Operation filtering utilities\nexport {\n\tcreateFilterStatistics,\n\ttype FilterStatistics,\n\tformatFilterStatistics,\n\tshouldIncludeOperation,\n\tvalidateFilters,\n} from \"./utils/operation-filters\";\n// Pattern matching utilities\nexport { stripPathPrefix, stripPrefix } from \"./utils/pattern-utils\";\n\n// Ref resolution utilities\nexport {\n\tmergeParameters,\n\tresolveParameterRef,\n\tresolveRef,\n\tresolveRequestBodyRef,\n\tresolveResponseRef,\n} from \"./utils/ref-resolver\";\n\nexport { escapeJSDoc } from \"./utils/string-utils\";\n// TypeScript loading utilities\nexport { createTypeScriptLoader } from \"./utils/typescript-loader\";\n// String validator utilities\nexport { buildDateTimeValidation } from \"./validators/string-validator\";\n","/**\n * Custom error classes for better error handling and debugging\n */\n\n/**\n * Base error class for all generator errors\n */\nexport class GeneratorError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly code: string,\n\t\tpublic readonly context?: Record<string, unknown>\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"GeneratorError\";\n\t\tError.captureStackTrace?.(this, this.constructor);\n\t}\n}\n\n/**\n * Error thrown when OpenAPI spec validation fails\n */\nexport class SpecValidationError extends GeneratorError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, \"SPEC_VALIDATION_ERROR\", context);\n\t\tthis.name = \"SpecValidationError\";\n\t}\n}\n\n/**\n * Error thrown when file operations fail\n */\nexport class FileOperationError extends GeneratorError {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly filePath: string,\n\t\tcontext?: Record<string, unknown>\n\t) {\n\t\tsuper(message, \"FILE_OPERATION_ERROR\", { ...context, filePath });\n\t\tthis.name = \"FileOperationError\";\n\t}\n}\n\n/**\n * Error thrown when config file is invalid\n */\nexport class ConfigValidationError extends GeneratorError {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly configPath?: string,\n\t\tcontext?: Record<string, unknown>\n\t) {\n\t\tsuper(message, \"CONFIG_VALIDATION_ERROR\", { ...context, configPath });\n\t\tthis.name = \"ConfigValidationError\";\n\t}\n}\n\n/**\n * Error thrown when schema generation fails\n */\nexport class SchemaGenerationError extends GeneratorError {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly schemaName: string,\n\t\tcontext?: Record<string, unknown>\n\t) {\n\t\tsuper(message, \"SCHEMA_GENERATION_ERROR\", { ...context, schemaName });\n\t\tthis.name = \"SchemaGenerationError\";\n\t}\n}\n\n/**\n * Error thrown when circular reference is detected in schema\n */\nexport class CircularReferenceError extends SchemaGenerationError {\n\tconstructor(\n\t\tschemaName: string,\n\t\tpublic readonly referencePath: string[]\n\t) {\n\t\tconst pathStr = referencePath.join(\" -> \");\n\t\tsuper(`Circular reference detected in schema: ${pathStr}`, schemaName, { referencePath, circularPath: pathStr });\n\t\tthis.name = \"CircularReferenceError\";\n\t}\n}\n\n/**\n * Error thrown when CLI options are invalid\n */\nexport class CliOptionsError extends GeneratorError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, \"CLI_OPTIONS_ERROR\", context);\n\t\tthis.name = \"CliOptionsError\";\n\t}\n}\n\n/**\n * Error thrown when configuration is invalid or missing required values\n */\nexport class ConfigurationError extends GeneratorError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, \"CONFIGURATION_ERROR\", context);\n\t\tthis.name = \"ConfigurationError\";\n\t}\n}\n","import { ConfigurationError } from \"./errors\";\nimport type { ExecutionMode } from \"./types\";\n\n/**\n * @shared Generator interface for batch execution\n * @since 1.0.0\n * Interface that both OpenApiGenerator and OpenApiPlaywrightGenerator must implement\n */\nexport interface Generator {\n\tgenerate(): void;\n}\n\n/**\n * Result of processing a single spec\n */\ninterface SpecResult<T> {\n\tspec: T;\n\tsuccess: boolean;\n\terror?: string;\n}\n\n/**\n * Summary of batch execution results\n */\ninterface BatchExecutionSummary<T> {\n\ttotal: number;\n\tsuccessful: number;\n\tfailed: number;\n\tresults: SpecResult<T>[];\n}\n\n/**\n * Process a single spec and return result with error handling\n */\nasync function processSpec<T>(\n\tspec: T,\n\tindex: number,\n\ttotal: number,\n\tcreateGenerator: (spec: T) => Generator\n): Promise<SpecResult<T>> {\n\t// Live progress to stdout\n\tconst specInput = (spec as any).input || \"spec\";\n\tconst specOutput = (spec as any).output || \"output\";\n\tconsole.log(`Processing [${index + 1}/${total}] ${specInput}...`);\n\n\ttry {\n\t\tconst generator = createGenerator(spec);\n\t\tgenerator.generate();\n\n\t\treturn {\n\t\t\tspec,\n\t\t\tsuccess: true,\n\t\t};\n\t} catch (error) {\n\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\tconsole.error(`✗ Failed to generate ${specOutput}: ${errorMessage}`);\n\n\t\treturn {\n\t\t\tspec,\n\t\t\tsuccess: false,\n\t\t\terror: errorMessage,\n\t\t};\n\t}\n}\n\n/**\n * Execute specs in parallel using Promise.allSettled with configurable batch size\n * Processes specifications in batches to control memory usage and concurrency\n * Continues processing all specs even if some fail\n */\nasync function executeParallel<T>(\n\tspecs: T[],\n\tcreateGenerator: (spec: T) => Generator,\n\tbatchSize: number\n): Promise<SpecResult<T>[]> {\n\tconsole.log(`\\nExecuting ${specs.length} specification(s) in parallel (batch size: ${batchSize})...\\n`);\n\n\tconst results: SpecResult<T>[] = [];\n\n\t// Process in batches to control memory usage\n\tfor (let i = 0; i < specs.length; i += batchSize) {\n\t\tconst batch = specs.slice(i, Math.min(i + batchSize, specs.length));\n\t\tconst batchPromises = batch.map((spec, batchIndex) =>\n\t\t\tprocessSpec(spec, i + batchIndex, specs.length, createGenerator)\n\t\t);\n\n\t\tconst batchResults = await Promise.allSettled(batchPromises);\n\n\t\t// Convert settled results to SpecResult\n\t\tfor (let j = 0; j < batchResults.length; j++) {\n\t\t\tconst result = batchResults[j];\n\t\t\tif (result.status === \"fulfilled\") {\n\t\t\t\tresults.push(result.value);\n\t\t\t} else {\n\t\t\t\t// Handle unexpected promise rejection\n\t\t\t\tresults.push({\n\t\t\t\t\tspec: batch[j],\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: result.reason instanceof Error ? result.reason.message : String(result.reason),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn results;\n}\n\n/**\n * Execute specs sequentially one at a time\n * Continues processing all specs even if some fail\n */\nasync function executeSequential<T>(specs: T[], createGenerator: (spec: T) => Generator): Promise<SpecResult<T>[]> {\n\tconsole.log(`\\nExecuting ${specs.length} spec(s) sequentially...\\n`);\n\n\tconst results: SpecResult<T>[] = [];\n\n\tfor (let i = 0; i < specs.length; i++) {\n\t\tconst result = await processSpec(specs[i], i, specs.length, createGenerator);\n\t\tresults.push(result);\n\t}\n\n\treturn results;\n}\n\n/**\n * Print final summary of batch execution\n */\nfunction printSummary<T>(summary: BatchExecutionSummary<T>): void {\n\tconsole.log(`\\n${\"=\".repeat(50)}`);\n\tconsole.log(\"Batch Execution Summary\");\n\tconsole.log(\"=\".repeat(50));\n\tconsole.log(`Total specs: ${summary.total}`);\n\tconsole.log(`Successful: ${summary.successful}`);\n\tconsole.log(`Failed: ${summary.failed}`);\n\n\tif (summary.failed > 0) {\n\t\tconsole.log(\"\\nFailed specs:\");\n\t\tfor (const result of summary.results) {\n\t\t\tif (!result.success) {\n\t\t\t\tconst specInput = (result.spec as any).input || \"spec\";\n\t\t\t\tconsole.error(` ✗ ${specInput}`);\n\t\t\t\tconsole.error(` Error: ${result.error}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconsole.log(`${\"=\".repeat(50)}\\n`);\n}\n\n/**\n * @shared Execute batch processing of multiple specs with custom generator\n * @since 1.0.0\n * Utility used by core and playwright packages\n *\n * @param specs - Array of spec configurations to process\n * @param executionMode - Execution mode: \"parallel\" (default) or \"sequential\"\n * @param createGenerator - Factory function to create generator from spec\n * @param batchSize - Number of specifications to process concurrently in parallel mode\n * @returns BatchExecutionSummary with results\n * @throws Never throws - collects all errors and reports them\n */\nexport async function executeBatch<T>(\n\tspecs: T[],\n\texecutionMode: ExecutionMode = \"parallel\",\n\tcreateGenerator: (spec: T) => Generator,\n\tbatchSize: number\n): Promise<BatchExecutionSummary<T>> {\n\tif (specs.length === 0) {\n\t\tthrow new ConfigurationError(\"No specs provided for batch execution\", { specsCount: 0, executionMode });\n\t}\n\n\tlet results: SpecResult<T>[] = [];\n\n\ttry {\n\t\t// Execute based on mode\n\t\tresults =\n\t\t\texecutionMode === \"parallel\"\n\t\t\t\t? await executeParallel(specs, createGenerator, batchSize)\n\t\t\t\t: await executeSequential(specs, createGenerator);\n\n\t\t// Calculate summary\n\t\tconst summary: BatchExecutionSummary<T> = {\n\t\t\ttotal: results.length,\n\t\t\tsuccessful: results.filter(r => r.success).length,\n\t\t\tfailed: results.filter(r => !r.success).length,\n\t\t\tresults,\n\t\t};\n\n\t\t// Print summary\n\t\tprintSummary(summary);\n\n\t\treturn summary;\n\t} finally {\n\t\t// Memory leak prevention: Clear large result objects and hint GC for large batches\n\t\tif (results.length > batchSize) {\n\t\t\t// Clear spec references to allow GC\n\t\t\tfor (const result of results) {\n\t\t\t\t// Keep only essential info, clear large objects\n\t\t\t\tif (result.spec) {\n\t\t\t\t\t(result.spec as any) = null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Hint to V8 garbage collector for large batches (if available)\n\t\t\tif (global.gc) {\n\t\t\t\tglobal.gc();\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Determine exit code based on batch execution results\n * Returns 1 if any spec failed, 0 if all succeeded\n */\nexport function getBatchExitCode<T>(summary: BatchExecutionSummary<T>): number {\n\treturn summary.failed > 0 ? 1 : 0;\n}\n","/**\n * @shared Simple LRU Cache implementation for performance optimization\n * @since 1.0.0\n * Utility used by core and playwright packages\n * Prevents memory leaks from unbounded cache growth\n */\nexport class LRUCache<K, V> {\n\tprivate cache = new Map<K, V>();\n\tprivate maxSize: number;\n\n\tconstructor(maxSize: number) {\n\t\tthis.maxSize = maxSize;\n\t}\n\n\tget capacity(): number {\n\t\treturn this.maxSize;\n\t}\n\n\tget(key: K): V | undefined {\n\t\tif (!this.cache.has(key)) return undefined;\n\t\t// Move to end (most recently used)\n\t\tconst value = this.cache.get(key);\n\t\tif (value === undefined) return undefined;\n\t\tthis.cache.delete(key);\n\t\tthis.cache.set(key, value);\n\t\treturn value;\n\t}\n\n\tset(key: K, value: V): void {\n\t\tif (this.cache.has(key)) {\n\t\t\tthis.cache.delete(key);\n\t\t} else if (this.cache.size >= this.maxSize) {\n\t\t\t// Remove least recently used (first item)\n\t\t\tconst firstKey = this.cache.keys().next().value;\n\t\t\tif (firstKey !== undefined) {\n\t\t\t\tthis.cache.delete(firstKey);\n\t\t\t}\n\t\t}\n\t\tthis.cache.set(key, value);\n\t}\n\n\thas(key: K): boolean {\n\t\treturn this.cache.has(key);\n\t}\n\n\tclear(): void {\n\t\tthis.cache.clear();\n\t}\n\n\tsize(): number {\n\t\treturn this.cache.size;\n\t}\n}\n","/**\n * Name conversion utilities\n */\n\nexport interface NamingOptions {\n\tprefix?: string;\n\tsuffix?: string;\n}\n\n/**\n * Sanitize a string by replacing invalid identifier characters with underscores\n * Preserves dots, hyphens, underscores, and spaces as word separators\n * Example: \"User@Domain\" -> \"User_Domain\"\n * Example: \"User-Data@2024\" -> \"User-Data_2024\"\n */\nfunction sanitizeIdentifier(str: string): string {\n\t// Replace all non-identifier chars (except dots, hyphens, underscores, spaces) with underscores\n\t// Valid identifier chars: letters, digits, underscore\n\t// Preserve: dots, hyphens, underscores, spaces as word separators\n\treturn str.replace(/[^a-zA-Z0-9._\\-\\s]+/g, \"_\");\n}\n\n/**\n * Convert schema name to camelCase with optional prefix/suffix\n * Handles dotted names like \"Company.Models.User\" -> \"companyModelsUser\"\n */\nexport function toCamelCase(str: string, options?: NamingOptions): string {\n\t// Sanitize invalid characters first\n\tconst sanitized = sanitizeIdentifier(str);\n\n\t// Split by dots, hyphens, underscores, and spaces to get words\n\tconst words = sanitized.split(/[.\\-_\\s]+/).filter(word => word.length > 0);\n\n\t// Convert to camelCase: first word lowercase, rest PascalCase\n\tlet name: string;\n\tif (words.length === 0) {\n\t\tname = str.charAt(0).toLowerCase() + str.slice(1);\n\t} else if (words.length === 1) {\n\t\tname = words[0].charAt(0).toLowerCase() + words[0].slice(1);\n\t} else {\n\t\tname =\n\t\t\twords[0].charAt(0).toLowerCase() +\n\t\t\twords[0].slice(1) +\n\t\t\twords\n\t\t\t\t.slice(1)\n\t\t\t\t.map(word => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t\t\t.join(\"\");\n\t}\n\n\t// Add prefix (only lowercase first char for camelCase, preserve rest)\n\tif (options?.prefix) {\n\t\tconst prefix = options.prefix.charAt(0).toLowerCase() + options.prefix.slice(1);\n\t\tname = prefix + name.charAt(0).toUpperCase() + name.slice(1);\n\t}\n\n\t// Add suffix (capitalize first char for proper camelCase, preserve rest)\n\tif (options?.suffix) {\n\t\tconst suffix = options.suffix.charAt(0).toUpperCase() + options.suffix.slice(1);\n\t\tname = name + suffix;\n\t}\n\n\treturn name;\n}\n\n/**\n * @shared Convert enum value to PascalCase and sanitize for TypeScript enum keys\n * @since 1.0.0\n * Utility used by core and playwright packages\n * Handles dotted names like \"Company.Models.User\" -> \"CompanyModelsUser\"\n */\nexport function toPascalCase(str: string | number): string {\n\tconst stringValue = String(str);\n\n\t// Check if it's already a valid PascalCase or camelCase identifier\n\t// (only contains letters, digits, and no special characters)\n\tconst isAlreadyValidCase = /^[a-zA-Z][a-zA-Z0-9]*$/.test(stringValue);\n\n\tif (isAlreadyValidCase) {\n\t\t// Just ensure it starts with uppercase\n\t\treturn stringValue.charAt(0).toUpperCase() + stringValue.slice(1);\n\t}\n\n\t// Sanitize invalid characters first\n\tconst sanitized = sanitizeIdentifier(stringValue);\n\n\t// Split by dots, hyphens, underscores, and spaces to get words\n\tconst words = sanitized.split(/[.\\-_\\s]+/).filter(word => word.length > 0);\n\n\t// Convert all words to PascalCase\n\tlet result: string;\n\tif (words.length === 0) {\n\t\tresult = \"Value\";\n\t} else {\n\t\tresult = words.map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(\"\");\n\t}\n\n\t// Enum keys can't start with a number - prefix with 'N'\n\tif (/^\\d/.test(result)) {\n\t\tresult = `N${result}`;\n\t}\n\n\t// If result is empty or only underscores, use a default\n\tif (!result || /^_+$/.test(result)) {\n\t\treturn \"Value\";\n\t}\n\n\treturn result;\n}\n\n/**\n * Resolve $ref to schema name\n */\nexport function resolveRef(ref: string): string {\n\tconst parts = ref.split(\"/\");\n\treturn parts[parts.length - 1];\n}\n","import { minimatch } from \"minimatch\";\n\n/**\n * Pattern matching utilities for prefix stripping\n *\n * Shared utility used by core and playwright packages\n *\n * Supports both literal string matching and glob patterns for stripping\n * prefixes from strings (paths, schema names, etc.)\n */\n\n/**\n * Validates if a glob pattern is syntactically valid\n * @param pattern - The glob pattern to validate\n * @returns true if valid, false otherwise\n */\nfunction isValidGlobPattern(pattern: string): boolean {\n\ttry {\n\t\t// Try to create a minimatch instance to validate the pattern\n\t\tnew minimatch.Minimatch(pattern);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Checks if a pattern contains glob special characters\n * @param pattern - The pattern to check\n * @returns true if pattern contains glob wildcards\n */\nfunction isGlobPattern(pattern: string): boolean {\n\treturn /[*?[\\]{}!]/.test(pattern);\n}\n\n/**\n * @shared Strips a prefix from a string using either literal string matching or glob patterns\n * @since 1.1.0\n * Shared utility used by core and playwright packages\n *\n * @param input - The full string to strip from\n * @param pattern - The glob pattern to strip\n * @param ensureLeadingChar - Optional character to ensure at start (e.g., \"/\" for paths)\n * @returns The string with prefix removed, or original string if no match\n *\n * @example\n * // Literal string matching\n * stripPrefix(\"/api/v1/users\", \"/api/v1\") // => \"/users\"\n * stripPrefix(\"Company.Models.User\", \"Company.Models.\") // => \"User\"\n *\n * @example\n * // Glob pattern matching\n * stripPrefix(\"/api/v1.0/users\", \"/api/v*\") // => matches and strips\n * stripPrefix(\"Company.Models.User\", \"*.Models.\") // => \"User\"\n * stripPrefix(\"api_v2_UserSchema\", \"api_v[0-9]_\") // => \"UserSchema\"\n */\nexport function stripPrefix(input: string, pattern: string | undefined, ensureLeadingChar?: string): string {\n\tif (!pattern) {\n\t\treturn input;\n\t}\n\n\t// Validate glob pattern if it contains special characters\n\tif (isGlobPattern(pattern) && !isValidGlobPattern(pattern)) {\n\t\tconsole.warn(`⚠️ Invalid glob pattern \"${pattern}\": Pattern is malformed`);\n\t\treturn input;\n\t}\n\n\t// Check if pattern contains glob wildcards\n\tif (isGlobPattern(pattern)) {\n\t\t// Use glob matching to find the prefix\n\t\t// We need to find what part of the input matches the pattern as a prefix\n\t\t// Try matching progressively longer prefixes to find the longest match\n\t\tlet longestMatch = -1;\n\n\t\tfor (let i = 1; i <= input.length; i++) {\n\t\t\tconst testPrefix = input.substring(0, i);\n\t\t\tif (minimatch(testPrefix, pattern)) {\n\t\t\t\t// Found a match - keep looking for a longer match\n\t\t\t\tlongestMatch = i;\n\t\t\t}\n\t\t}\n\n\t\tif (longestMatch > 0) {\n\t\t\t// Strip the longest matching prefix\n\t\t\tconst stripped = input.substring(longestMatch);\n\n\t\t\t// Ensure result starts with specified character if provided\n\t\t\tif (ensureLeadingChar) {\n\t\t\t\tif (stripped === \"\") {\n\t\t\t\t\treturn ensureLeadingChar;\n\t\t\t\t}\n\t\t\t\tif (!stripped.startsWith(ensureLeadingChar)) {\n\t\t\t\t\treturn `${ensureLeadingChar}${stripped}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn stripped === \"\" && !ensureLeadingChar ? input : stripped;\n\t\t}\n\n\t\t// No match found\n\t\treturn input;\n\t}\n\n\t// Literal string matching\n\tif (input.startsWith(pattern)) {\n\t\tconst stripped = input.substring(pattern.length);\n\n\t\t// Ensure result starts with specified character if provided\n\t\tif (ensureLeadingChar) {\n\t\t\tif (stripped === \"\") {\n\t\t\t\treturn ensureLeadingChar;\n\t\t\t}\n\t\t\tif (!stripped.startsWith(ensureLeadingChar)) {\n\t\t\t\treturn `${ensureLeadingChar}${stripped}`;\n\t\t\t}\n\t\t}\n\n\t\treturn stripped;\n\t}\n\n\t// No match - return original input\n\treturn input;\n}\n\n/**\n * @shared Strips a prefix from a path (ensures leading slash)\n * @since 1.1.0\n * Shared utility used by playwright package for path manipulation\n *\n * @param path - The full path to strip from\n * @param pattern - The glob pattern to strip\n * @returns The path with prefix removed, or original path if no match\n *\n * @example\n * stripPathPrefix(\"/api/v1/users\", \"/api/v1\") // => \"/users\"\n * stripPathPrefix(\"/api/v2/posts\", \"/api/v*\") // => \"/posts\"\n * stripPathPrefix(\"/api/v1.0/items\", \"/api/v[0-9].*\") // => \"/items\"\n */\nexport function stripPathPrefix(path: string, pattern: string | undefined): string {\n\tif (!pattern) {\n\t\treturn path;\n\t}\n\n\t// For literal string matching with paths, normalize the pattern\n\tif (!isGlobPattern(pattern)) {\n\t\tlet normalizedPattern = pattern.trim();\n\t\tif (!normalizedPattern.startsWith(\"/\")) {\n\t\t\tnormalizedPattern = `/${normalizedPattern}`;\n\t\t}\n\t\tif (normalizedPattern.endsWith(\"/\") && normalizedPattern !== \"/\") {\n\t\t\tnormalizedPattern = normalizedPattern.slice(0, -1);\n\t\t}\n\n\t\treturn stripPrefix(path, normalizedPattern, \"/\");\n\t}\n\n\t// For glob patterns, use as-is\n\treturn stripPrefix(path, pattern, \"/\");\n}\n","/**\n * String utility functions for escaping and formatting\n */\n\nimport type { OpenAPISchema } from \"../types\";\n\n/**\n * Escape string for description in .describe()\n */\nexport function escapeDescription(str: string): string {\n\treturn str.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"').replace(/\\n/g, \"\\\\n\");\n}\n\n/**\n * Escape regex pattern for use in code\n * Only escapes forward slashes which would terminate the regex literal\n * Handles patterns that may already have escaped forward slashes from JSON\n */\nexport function escapePattern(str: string): string {\n\t// Use negative lookbehind to only escape forward slashes that are NOT already preceded by a backslash\n\treturn str.replace(/(?<!\\\\)\\//g, \"\\\\/\");\n}\n\n/**\n * @shared Escape JSDoc comment content to prevent injection\n * @since 1.0.0\n * Utility used by core and playwright packages\n */\nexport function escapeJSDoc(str: string): string {\n\treturn str.replace(/\\*\\//g, \"*\\\\/\");\n}\n\n/**\n * Wrap validation with .nullable() if needed\n */\nexport function wrapNullable(validation: string, isNullable: boolean): string {\n\treturn isNullable ? `${validation}.nullable()` : validation;\n}\n\n/**\n * Check if schema is nullable (supports both OpenAPI 3.0 and 3.1 syntax)\n * @param schema - The OpenAPI schema to check\n * @param defaultNullable - Default nullable behavior when not explicitly specified (default: false)\n */\nexport function isNullable(schema: OpenAPISchema, defaultNullable = false): boolean {\n\t// OpenAPI 3.0 style: nullable explicitly set\n\tif (schema.nullable === true) {\n\t\treturn true;\n\t}\n\tif (schema.nullable === false) {\n\t\treturn false;\n\t}\n\t// OpenAPI 3.1 style: type can be an array including \"null\"\n\tif (Array.isArray(schema.type)) {\n\t\treturn schema.type.includes(\"null\");\n\t}\n\t// No explicit nullable annotation - use default\n\treturn defaultNullable;\n}\n\n/**\n * Get the primary type from schema (handles OpenAPI 3.1 type arrays)\n */\nexport function getPrimaryType(schema: OpenAPISchema): string | undefined {\n\tif (Array.isArray(schema.type)) {\n\t\t// OpenAPI 3.1: type can be an array like [\"string\", \"null\"]\n\t\t// Return the first non-null type\n\t\tconst nonNullType = schema.type.find(t => t !== \"null\");\n\t\treturn nonNullType;\n\t}\n\treturn schema.type;\n}\n\n/**\n * Check if schema has multiple non-null types\n */\nexport function hasMultipleTypes(schema: OpenAPISchema): boolean {\n\tif (Array.isArray(schema.type)) {\n\t\tconst nonNullTypes = schema.type.filter(t => t !== \"null\");\n\t\treturn nonNullTypes.length > 1;\n\t}\n\treturn false;\n}\n\n/**\n * Add description to a schema validation string\n */\nexport function addDescription(validation: string, description: string | undefined, useDescribe: boolean): string {\n\tif (!description || !useDescribe) return validation;\n\n\tconst escapedDesc = escapeDescription(description);\n\treturn `${validation}.describe(\"${escapedDesc}\")`;\n}\n","import type { OpenAPISchema } from \"../types\";\nimport { addDescription } from \"../utils/string-utils\";\n\nexport interface ArrayValidatorContext {\n\tgeneratePropertySchema: (schema: OpenAPISchema, currentSchema?: string) => string;\n\tuseDescribe: boolean;\n\tcurrentSchema?: string;\n}\n\n/**\n * Generate array or tuple validation\n */\nexport function generateArrayValidation(schema: OpenAPISchema, context: ArrayValidatorContext): string {\n\tlet validation: string;\n\n\t// Handle prefixItems (tuple validation - OpenAPI 3.1)\n\tif (schema.prefixItems && schema.prefixItems.length > 0) {\n\t\tconst tupleItems = schema.prefixItems.map(item => context.generatePropertySchema(item, context.currentSchema));\n\t\tvalidation = `z.tuple([${tupleItems.join(\", \")}])`;\n\n\t\t// Add rest items if specified (items after the fixed prefix)\n\t\t// items takes precedence over unevaluatedItems\n\t\tif (schema.items) {\n\t\t\tconst restSchema = context.generatePropertySchema(schema.items, context.currentSchema);\n\t\t\tvalidation += `.rest(${restSchema})`;\n\t\t} else if (schema.unevaluatedItems && typeof schema.unevaluatedItems === \"object\") {\n\t\t\t// Use unevaluatedItems as rest schema if items not specified\n\t\t\tconst restSchema = context.generatePropertySchema(schema.unevaluatedItems, context.currentSchema);\n\t\t\tvalidation += `.rest(${restSchema})`;\n\t\t}\n\t\t// If unevaluatedItems is false (or undefined), tuple has fixed length by default\n\t} else if (schema.items) {\n\t\tconst itemSchema = context.generatePropertySchema(schema.items, context.currentSchema);\n\t\tvalidation = `z.array(${itemSchema})`;\n\n\t\t// Add array constraints\n\t\tif (schema.minItems !== undefined) {\n\t\t\tvalidation += `.min(${schema.minItems})`;\n\t\t}\n\t\tif (schema.maxItems !== undefined) {\n\t\t\tvalidation += `.max(${schema.maxItems})`;\n\t\t}\n\n\t\t// Add uniqueItems constraint\n\t\tif (schema.uniqueItems === true) {\n\t\t\tvalidation += `.refine((items) => new Set(items).size === items.length, { message: \"Array items must be unique\" })`;\n\t\t}\n\t} else {\n\t\tvalidation = \"z.array(z.unknown())\";\n\t}\n\n\t// Handle contains with min/max constraints\n\tif (schema.contains) {\n\t\tconst containsSchema = context.generatePropertySchema(schema.contains, context.currentSchema);\n\t\tconst minCount = schema.minContains ?? 1;\n\t\tconst maxCount = schema.maxContains;\n\n\t\tif (maxCount !== undefined) {\n\t\t\t// Both min and max\n\t\t\tvalidation += `.refine((arr) => { const matches = arr.filter(item => ${containsSchema}.safeParse(item).success); return matches.length >= ${minCount} && matches.length <= ${maxCount}; }, { message: \"Array must contain between ${minCount} and ${maxCount} items matching the schema\" })`;\n\t\t} else {\n\t\t\t// Just min\n\t\t\tvalidation += `.refine((arr) => arr.filter(item => ${containsSchema}.safeParse(item).success).length >= ${minCount}, { message: \"Array must contain at least ${minCount} item(s) matching the schema\" })`;\n\t\t}\n\t}\n\n\t// Handle unevaluatedItems (OpenAPI 3.1) - only applies to prefixItems scenarios\n\t// Note: unevaluatedItems with prefixItems should use .rest() which was already handled above\n\t// This section handles the false case which needs to restrict the length\n\tif (schema.unevaluatedItems === false && schema.prefixItems && schema.prefixItems.length > 0 && !schema.items) {\n\t\t// No items beyond prefixItems allowed - add length restriction\n\t\tconst prefixCount = schema.prefixItems.length;\n\t\tvalidation += `.refine((arr) => arr.length <= ${prefixCount}, { message: \"No unevaluated items allowed beyond prefix items\" })`;\n\t}\n\n\t// Add description if useDescribe is enabled\n\treturn addDescription(validation, schema.description, context.useDescribe);\n}\n","import type { OpenAPISchema } from \"../types\";\nimport { wrapNullable } from \"../utils/string-utils\";\n\nexport interface CompositionValidatorContext {\n\tgeneratePropertySchema: (\n\t\tschema: OpenAPISchema,\n\t\tcurrentSchema?: string,\n\t\tisTopLevel?: boolean,\n\t\tsuppressDefaultNullable?: boolean\n\t) => string;\n\t/**\n\t * Generate inline object shape for use with .extend()\n\t * Returns just the shape object literal: { prop1: z.string(), prop2: z.number() }\n\t * This avoids the .nullable().shape bug when inline objects have nullable: true\n\t */\n\tgenerateInlineObjectShape?: (schema: OpenAPISchema, currentSchema?: string) => string;\n\tresolveDiscriminatorMapping?: (mapping: Record<string, string>, schemas: OpenAPISchema[]) => OpenAPISchema[];\n\tresolveSchemaRef?: (ref: string) => OpenAPISchema | undefined;\n}\n\nexport interface UnionOptions {\n\tpassthrough?: boolean;\n\tdiscriminatorMapping?: Record<string, string>;\n}\n\n/**\n * Check if discriminator property is required in all schemas\n */\nfunction isDiscriminatorRequired(\n\tschemas: OpenAPISchema[],\n\tdiscriminator: string,\n\tcontext: CompositionValidatorContext\n): { valid: boolean; invalidSchemas: string[] } {\n\tconst invalidSchemas: string[] = [];\n\n\tfor (const schema of schemas) {\n\t\tconst resolved = resolveSchema(schema, context);\n\t\tconst required = resolved.required || [];\n\n\t\tif (!required.includes(discriminator)) {\n\t\t\tconst schemaName = schema.$ref ? schema.$ref.split(\"/\").pop() || \"inline\" : \"inline\";\n\t\t\tinvalidSchemas.push(schemaName);\n\t\t}\n\t}\n\n\treturn {\n\t\tvalid: invalidSchemas.length === 0,\n\t\tinvalidSchemas,\n\t};\n}\n\n/**\n * Generate union validation\n */\nexport function generateUnion(\n\tschemas: OpenAPISchema[],\n\tdiscriminator: string | undefined,\n\tisNullable: boolean,\n\tcontext: CompositionValidatorContext,\n\toptions?: UnionOptions,\n\tcurrentSchema?: string\n): string {\n\t// Handle empty oneOf/anyOf - malformed spec, warn and return z.never()\n\tif (schemas.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[openapi-to-zod] Warning: Empty oneOf/anyOf array encountered. This is likely a malformed OpenAPI spec. Generating z.never() as fallback.\"\n\t\t);\n\t\treturn wrapNullable(\n\t\t\t'z.never().describe(\"Empty oneOf/anyOf in OpenAPI spec - no valid schema defined\")',\n\t\t\tisNullable\n\t\t);\n\t}\n\n\t// Simplify single-item oneOf/anyOf - no union needed\n\tif (schemas.length === 1) {\n\t\t// Suppress defaultNullable - this is a schema definition, not a property value\n\t\tlet singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false, true);\n\t\tif (options?.passthrough && !singleSchema.includes(\".catchall(\")) {\n\t\t\tsingleSchema = `${singleSchema}.catchall(z.unknown())`;\n\t\t}\n\t\treturn wrapNullable(singleSchema, isNullable);\n\t}\n\n\tif (discriminator) {\n\t\t// Apply discriminator mapping if provided\n\t\tlet resolvedSchemas = schemas;\n\t\tif (options?.discriminatorMapping && context.resolveDiscriminatorMapping) {\n\t\t\tresolvedSchemas = context.resolveDiscriminatorMapping(options.discriminatorMapping, schemas);\n\t\t}\n\n\t\t// Check if discriminator is required in all schemas\n\t\tconst discriminatorCheck = isDiscriminatorRequired(resolvedSchemas, discriminator, context);\n\n\t\tif (!discriminatorCheck.valid) {\n\t\t\t// Discriminator is not required in all schemas - fallback to z.union()\n\t\t\tconsole.warn(\n\t\t\t\t`[openapi-to-zod] Warning: Discriminator \"${discriminator}\" is not required in schemas: ${discriminatorCheck.invalidSchemas.join(\", \")}. ` +\n\t\t\t\t\t\"Falling back to z.union() instead of z.discriminatedUnion().\"\n\t\t\t);\n\n\t\t\t// Suppress defaultNullable on each variant - they are schema definitions, not property values\n\t\t\tlet schemaStrings = resolvedSchemas.map(s => context.generatePropertySchema(s, currentSchema, false, true));\n\t\t\tif (options?.passthrough) {\n\t\t\t\tschemaStrings = schemaStrings.map(s => (s.includes(\".catchall(\") ? s : `${s}.catchall(z.unknown())`));\n\t\t\t}\n\n\t\t\tconst fallbackDescription = `Discriminator \"${discriminator}\" is optional in some schemas (${discriminatorCheck.invalidSchemas.join(\", \")}), using z.union() instead of z.discriminatedUnion()`;\n\t\t\tconst union = `z.union([${schemaStrings.join(\", \")}]).describe(\"${fallbackDescription}\")`;\n\t\t\treturn wrapNullable(union, isNullable);\n\t\t}\n\n\t\t// Use discriminated union for better type inference\n\t\t// Suppress defaultNullable on each variant - they are schema definitions, not property values\n\t\tlet schemaStrings = resolvedSchemas.map(s => context.generatePropertySchema(s, currentSchema, false, true));\n\t\tif (options?.passthrough) {\n\t\t\tschemaStrings = schemaStrings.map(s => (s.includes(\".catchall(\") ? s : `${s}.catchall(z.unknown())`));\n\t\t}\n\t\tconst union = `z.discriminatedUnion(\"${discriminator}\", [${schemaStrings.join(\", \")}])`;\n\t\treturn wrapNullable(union, isNullable);\n\t}\n\n\t// Suppress defaultNullable on each variant - they are schema definitions, not property values\n\tlet schemaStrings = schemas.map(s => context.generatePropertySchema(s, currentSchema, false, true));\n\tif (options?.passthrough) {\n\t\tschemaStrings = schemaStrings.map(s => (s.includes(\".catchall(\") ? s : `${s}.catchall(z.unknown())`));\n\t}\n\tconst union = `z.union([${schemaStrings.join(\", \")}])`;\n\treturn wrapNullable(union, isNullable);\n}\n\n/**\n * Helper to resolve schema (follows $ref if needed)\n */\nfunction resolveSchema(schema: OpenAPISchema, context: CompositionValidatorContext): OpenAPISchema {\n\tif (schema.$ref && context.resolveSchemaRef) {\n\t\tconst resolved = context.resolveSchemaRef(schema.$ref);\n\t\tif (resolved) {\n\t\t\treturn resolved;\n\t\t}\n\t}\n\treturn schema;\n}\n\n/**\n * Collect properties from a schema (including nested allOf)\n */\nfunction collectProperties(\n\tschema: OpenAPISchema,\n\tcontext: CompositionValidatorContext\n): Map<string, { schema: OpenAPISchema; source: string }> {\n\tconst resolved = resolveSchema(schema, context);\n\tconst props = new Map<string, { schema: OpenAPISchema; source: string }>();\n\n\t// Get source name for error messages\n\tconst sourceName = schema.$ref ? schema.$ref.split(\"/\").pop() || \"unknown\" : \"inline\";\n\n\t// Collect direct properties\n\tif (resolved.properties) {\n\t\tfor (const [key, value] of Object.entries(resolved.properties)) {\n\t\t\tprops.set(key, { schema: value, source: sourceName });\n\t\t}\n\t}\n\n\t// Recursively collect from nested allOf\n\tif (resolved.allOf) {\n\t\tfor (const subSchema of resolved.allOf) {\n\t\t\tconst subProps = collectProperties(subSchema, context);\n\t\t\tfor (const [key, value] of subProps) {\n\t\t\t\tif (!props.has(key)) {\n\t\t\t\t\tprops.set(key, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn props;\n}\n\n/**\n * Check if two schemas are semantically equivalent\n */\nfunction schemasMatch(a: OpenAPISchema, b: OpenAPISchema): boolean {\n\t// Simple deep comparison for common cases\n\treturn JSON.stringify(a) === JSON.stringify(b);\n}\n\n/**\n * Detect conflicting properties across allOf schemas\n */\nfunction detectConflictingProperties(schemas: OpenAPISchema[], context: CompositionValidatorContext): string[] {\n\tconst conflicts: string[] = [];\n\tconst propertyMap = new Map<string, { schema: OpenAPISchema; source: string }>();\n\n\tfor (const schema of schemas) {\n\t\tconst schemaProps = collectProperties(schema, context);\n\n\t\tfor (const [propName, propInfo] of schemaProps) {\n\t\t\tconst existing = propertyMap.get(propName);\n\t\t\tif (existing) {\n\t\t\t\t// Check if the definitions match\n\t\t\t\tif (!schemasMatch(existing.schema, propInfo.schema)) {\n\t\t\t\t\tconflicts.push(\n\t\t\t\t\t\t`Property \"${propName}\" has conflicting definitions in ${existing.source} and ${propInfo.source}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpropertyMap.set(propName, propInfo);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn conflicts;\n}\n\n/**\n * Generate allOf validation\n *\n * Key fix: For inline objects in allOf, we generate the shape directly as an object literal\n * (e.g., { prop: z.string() }) instead of using z.object({...}).shape.\n * This avoids the invalid .nullable().shape pattern that occurs when inline objects\n * have nullable: true set.\n *\n * According to Zod docs (https://zod.dev/api?id=extend):\n * - .extend() accepts an object of shape definitions OR another schema's .shape\n * - For $refs: use baseSchema.extend(otherSchema.shape)\n * - For inline objects: use baseSchema.extend({ prop: z.string() })\n * - .nullable() must be applied AFTER all .extend() calls\n * - defaultNullable should NOT apply to schemas in allOf - they are schema shapes, not property values\n */\nexport function generateAllOf(\n\tschemas: OpenAPISchema[],\n\tisNullable: boolean,\n\tcontext: CompositionValidatorContext,\n\tcurrentSchema?: string\n): string {\n\tif (schemas.length === 1) {\n\t\t// Single-item allOf is essentially an alias - suppress defaultNullable\n\t\t// because this is a schema definition, not a property value\n\t\tconst singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false, true);\n\t\treturn wrapNullable(singleSchema, isNullable);\n\t}\n\n\t// Detect conflicting properties and warn\n\tconst conflicts = detectConflictingProperties(schemas, context);\n\tlet conflictDescription = \"\";\n\tif (conflicts.length > 0) {\n\t\tfor (const conflict of conflicts) {\n\t\t\tconsole.warn(`[openapi-to-zod] Warning: allOf composition conflict - ${conflict}`);\n\t\t}\n\t\tconflictDescription = `allOf property conflicts detected: ${conflicts.join(\"; \")}`;\n\t}\n\n\t// Check if all schemas are objects (for .extend() support)\n\tconst allObjects = schemas.every(s => s.type === \"object\" || s.properties || s.$ref || s.allOf);\n\n\tlet result: string;\n\tif (allObjects) {\n\t\t// Use .extend() for object schemas (Zod v4 compliant - .merge() is deprecated)\n\t\t// First schema is the base - generate with suppressDefaultNullable=true\n\t\t// because this is a schema shape, not a property value\n\t\tlet merged = context.generatePropertySchema(schemas[0], currentSchema, false, true);\n\n\t\t// For subsequent schemas, determine how to extend\n\t\tfor (let i = 1; i < schemas.length; i++) {\n\t\t\tconst schema = schemas[i];\n\n\t\t\tif (schema.$ref) {\n\t\t\t\t// For $ref schemas, use .extend(refSchema.shape)\n\t\t\t\t// Suppress defaultNullable - this is a schema shape, not a property value\n\t\t\t\tconst refSchema = context.generatePropertySchema(schema, currentSchema, false, true);\n\t\t\t\tmerged = `${merged}.extend(${refSchema}.shape)`;\n\t\t\t} else if (context.generateInlineObjectShape && (schema.properties || schema.type === \"object\")) {\n\t\t\t\t// For inline objects, generate shape directly as object literal\n\t\t\t\t// This avoids the .nullable().shape bug - we pass { prop: z.string() }\n\t\t\t\t// directly to .extend() instead of z.object({...}).nullable().shape\n\t\t\t\t// Note: generateInlineObjectShape respects defaultNullable for properties INSIDE the object\n\t\t\t\tconst inlineShape = context.generateInlineObjectShape(schema, currentSchema);\n\t\t\t\tmerged = `${merged}.extend(${inlineShape})`;\n\t\t\t} else {\n\t\t\t\t// Fallback for schemas without properties (e.g., just has allOf)\n\t\t\t\t// Generate full schema with suppressDefaultNullable and use .shape\n\t\t\t\tconst schemaString = context.generatePropertySchema(schema, currentSchema, false, true);\n\t\t\t\tmerged = `${merged}.extend(${schemaString}.shape)`;\n\t\t\t}\n\t\t}\n\t\tresult = merged;\n\t} else {\n\t\t// Use .and() for non-object schemas (intersection)\n\t\t// Suppress defaultNullable on each schema in the intersection\n\t\tconst schemaStrings = schemas.map(s => context.generatePropertySchema(s, currentSchema, false, true));\n\t\tlet merged = schemaStrings[0];\n\t\tfor (let i = 1; i < schemaStrings.length; i++) {\n\t\t\tmerged = `${merged}.and(${schemaStrings[i]})`;\n\t\t}\n\t\tresult = merged;\n\t}\n\n\t// Add description about conflicts if any\n\tif (conflictDescription) {\n\t\tresult = `${result}.describe(\"${conflictDescription}\")`;\n\t}\n\n\t// Apply nullable at the END, after all .extend() calls\n\t// This is critical - .nullable() must come after .extend(), not before\n\treturn wrapNullable(result, isNullable);\n}\n","import type { OpenAPISchema } from \"../types\";\nimport { addDescription } from \"../utils/string-utils\";\n\n/**\n * Generate Zod validation for number\n */\nexport function generateNumberValidation(schema: OpenAPISchema, isInt: boolean, useDescribe: boolean): string {\n\tlet validation = isInt ? \"z.number().int()\" : \"z.number()\";\n\n\t// Handle minimum with exclusive bounds\n\tif (schema.minimum !== undefined) {\n\t\tconst isExclusive = schema.exclusiveMinimum === true;\n\t\tvalidation += isExclusive ? `.gt(${schema.minimum})` : `.gte(${schema.minimum})`;\n\t} else if (typeof schema.exclusiveMinimum === \"number\") {\n\t\t// OpenAPI 3.1 style: exclusiveMinimum as number\n\t\tvalidation += `.gt(${schema.exclusiveMinimum})`;\n\t}\n\n\t// Handle maximum with exclusive bounds\n\tif (schema.maximum !== undefined) {\n\t\tconst isExclusive = schema.exclusiveMaximum === true;\n\t\tvalidation += isExclusive ? `.lt(${schema.maximum})` : `.lte(${schema.maximum})`;\n\t} else if (typeof schema.exclusiveMaximum === \"number\") {\n\t\t// OpenAPI 3.1 style: exclusiveMaximum as number\n\t\tvalidation += `.lt(${schema.exclusiveMaximum})`;\n\t}\n\n\tif (schema.multipleOf !== undefined) {\n\t\tvalidation += `.multipleOf(${schema.multipleOf})`;\n\t}\n\n\t// Add description if useDescribe is enabled\n\treturn addDescription(validation, schema.description, useDescribe);\n}\n","import type { OpenAPISchema } from \"../types\";\nimport { escapeJSDoc } from \"../utils/string-utils\";\n\nexport interface JSDocOptions {\n\tincludeDescriptions: boolean;\n}\n\n/**\n * Generate JSDoc comment for a schema or property\n * Type-safe with input validation to prevent JSDoc injection\n */\nexport function generateJSDoc(\n\tschema: OpenAPISchema,\n\tname?: string,\n\toptions: JSDocOptions = { includeDescriptions: true }\n): string {\n\t// Type safety: Validate schema input\n\tif (!schema || typeof schema !== \"object\") {\n\t\treturn \"\";\n\t}\n\n\tif (!options.includeDescriptions) {\n\t\t// Only add @deprecated if descriptions are disabled\n\t\tif (schema.deprecated) {\n\t\t\treturn \"/** @deprecated */\\n\";\n\t\t}\n\t\treturn \"\";\n\t}\n\n\t// Check if we have anything to document\n\tif (!schema.description && !schema.title && !schema.deprecated && !schema.examples && schema.example === undefined) {\n\t\treturn \"\";\n\t}\n\n\tconst parts: string[] = [];\n\n\t// Add title if different from name (sanitized)\n\tif (schema.title && typeof schema.title === \"string\" && (!name || schema.title !== name)) {\n\t\t// Sanitize title to prevent JSDoc injection\n\t\tconst sanitizedTitle = escapeJSDoc(schema.title).replace(/@/g, \"\\\\@\");\n\t\tparts.push(sanitizedTitle);\n\t}\n\n\t// Add description (sanitized to prevent injection)\n\tif (schema.description && typeof schema.description === \"string\") {\n\t\t// Escape @ symbols and other JSDoc tags to prevent injection\n\t\tconst sanitizedDesc = escapeJSDoc(schema.description).replace(/@/g, \"\\\\@\").replace(/\\*\\//g, \"*\\\\/\");\n\t\tparts.push(sanitizedDesc);\n\t}\n\n\t// Add examples (with type safety)\n\tif (schema.examples && Array.isArray(schema.examples) && schema.examples.length > 0) {\n\t\ttry {\n\t\t\tconst examplesStr = schema.examples.map(ex => JSON.stringify(ex)).join(\", \");\n\t\t\tparts.push(`@example ${examplesStr}`);\n\t\t} catch (error) {\n\t\t\t// Skip examples that can't be serialized\n\t\t\tconsole.warn(\"Warning: Could not serialize schema examples\", error);\n\t\t}\n\t} else if (schema.example !== undefined) {\n\t\ttry {\n\t\t\tparts.push(`@example ${JSON.stringify(schema.example)}`);\n\t\t} catch (error) {\n\t\t\t// Skip example that can't be serialized\n\t\t\tconsole.warn(\"Warning: Could not serialize schema example\", error);\n\t\t}\n\t}\n\n\t// Add deprecated\n\tif (schema.deprecated) {\n\t\tparts.push(\"@deprecated\");\n\t}\n\n\tif (parts.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst fullComment = parts.join(\" \");\n\treturn `/** ${fullComment} */\\n`;\n}\n","import type { OpenAPISchema } from \"../types\";\n\n/**\n * Generate property access expression (use dot notation for valid identifiers, bracket notation otherwise)\n */\nfunction generatePropertyAccess(propName: string): string {\n\t// Valid identifier: starts with letter/underscore/$, followed by letters/digits/underscores/$\n\tconst validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\treturn validIdentifier.test(propName) ? `obj.${propName}` : `obj[\"${propName}\"]`;\n}\n\n/**\n * Generate validation for dependencies (OpenAPI 3.0)\n * Generates detailed error messages showing which specific fields are missing\n */\nexport function generateDependencies(\n\tschema: OpenAPISchema,\n\tgeneratePropertySchema?: (schema: OpenAPISchema, currentSchema?: string) => string,\n\tcurrentSchema?: string\n): string {\n\tif (!schema.dependencies) {\n\t\treturn \"\";\n\t}\n\n\tlet result = \"\";\n\tfor (const [prop, dependency] of Object.entries(schema.dependencies)) {\n\t\tif (Array.isArray(dependency)) {\n\t\t\t// Skip empty dependency arrays (no dependencies to enforce)\n\t\t\tif (dependency.length === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Property dependency - show specific missing properties in error message\n\t\t\tconst propAccess = generatePropertyAccess(prop);\n\t\t\tconst checkLogic = dependency\n\t\t\t\t.map(p => {\n\t\t\t\t\tconst pAccess = generatePropertyAccess(p);\n\t\t\t\t\treturn `if (${pAccess} === undefined) missing.push('${p}');`;\n\t\t\t\t})\n\t\t\t\t.join(\"\\n\\t\\t\");\n\n\t\t\tresult += `.superRefine((obj, ctx) => {\n\t\t\t\tif (${propAccess} === undefined) return;\n\t\t\t\tconst missing: string[] = [];\n\t\t\t\t${checkLogic}\n\t\t\t\tif (missing.length > 0) {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: \\`When '${prop}' is present, the following properties are required: \\${missing.join(', ')}\\`,\n\t\t\t\t\t\tpath: []\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})`;\n\t\t} else if (generatePropertySchema) {\n\t\t\t// Schema dependency - show detailed validation errors\n\t\t\tconst depSchema: OpenAPISchema = { ...dependency, type: dependency.type || \"object\" };\n\t\t\tconst depSchemaValidation = generatePropertySchema(depSchema, currentSchema);\n\t\t\tconst propAccess = generatePropertyAccess(prop);\n\n\t\t\tresult += `.superRefine((obj, ctx) => {\n\t\t\t\tif (${propAccess} === undefined) return;\n\t\t\t\tconst validation = ${depSchemaValidation}.safeParse(obj);\n\t\t\t\tif (!validation.success) {\n\t\t\t\t\tconst errors = validation.error.issues.map(i => \\` - \\${i.path.join('.')}: \\${i.message}\\`).join('\\\\n');\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: \\`When '${prop}' is present, object must satisfy additional constraints:\\\\n\\${errors}\\`,\n\t\t\t\t\t\tpath: []\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})`;\n\t\t}\n\t}\n\treturn result;\n}\n\n/**\n * Generate condition check for if/then/else\n */\nexport function generateConditionalCheck(schema: OpenAPISchema): string {\n\tconst conditions: string[] = [];\n\n\t// Check properties\n\tif (schema.properties) {\n\t\tfor (const [prop, propSchema] of Object.entries(schema.properties)) {\n\t\t\tconst propAccess = generatePropertyAccess(prop);\n\t\t\tif (propSchema.type) {\n\t\t\t\tconditions.push(`typeof ${propAccess} === \"${propSchema.type}\"`);\n\t\t\t}\n\t\t\tif (propSchema.const !== undefined) {\n\t\t\t\tconst value = typeof propSchema.const === \"string\" ? `\"${propSchema.const}\"` : propSchema.const;\n\t\t\t\tconditions.push(`${propAccess} === ${value}`);\n\t\t\t}\n\t\t\tif (propSchema.minimum !== undefined) {\n\t\t\t\tconditions.push(`${propAccess} >= ${propSchema.minimum}`);\n\t\t\t}\n\t\t\tif (propSchema.maximum !== undefined) {\n\t\t\t\tconditions.push(`${propAccess} <= ${propSchema.maximum}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check required properties\n\tif (schema.required) {\n\t\tfor (const prop of schema.required) {\n\t\t\tconditions.push(`${generatePropertyAccess(prop)} !== undefined`);\n\t\t}\n\t}\n\n\treturn conditions.length > 0 ? conditions.join(\" && \") : \"true\";\n}\n\n/**\n * Generate validation for then/else clauses\n */\nexport function generateConditionalValidation(schema: OpenAPISchema): string {\n\tconst checks: string[] = [];\n\n\t// Check required properties\n\tif (schema.required) {\n\t\tfor (const prop of schema.required) {\n\t\t\tchecks.push(`${generatePropertyAccess(prop)} !== undefined`);\n\t\t}\n\t}\n\n\t// Check properties constraints\n\tif (schema.properties) {\n\t\tfor (const [prop, propSchema] of Object.entries(schema.properties)) {\n\t\t\tconst propAccess = generatePropertyAccess(prop);\n\t\t\tif (propSchema.minimum !== undefined) {\n\t\t\t\tchecks.push(`${propAccess} === undefined || ${propAccess} >= ${propSchema.minimum}`);\n\t\t\t}\n\t\t\tif (propSchema.maximum !== undefined) {\n\t\t\t\tchecks.push(`${propAccess} === undefined || ${propAccess} <= ${propSchema.maximum}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn checks.length > 0 ? checks.join(\" && \") : \"true\";\n}\n\n/**\n * Generate if/then/else conditional validation with better error messages\n * Uses superRefine with detailed error messages for complex cases\n */\nexport function generateIfThenElse(schema: OpenAPISchema): string {\n\tif (!schema.if || (!schema.then && !schema.else)) {\n\t\treturn \"\";\n\t}\n\n\tconst ifCondition = generateConditionalCheck(schema.if);\n\n\tif (schema.then && schema.else) {\n\t\t// Both then and else - provide detailed error messages\n\t\tconst thenValidation = generateConditionalValidation(schema.then);\n\t\tconst elseValidation = generateConditionalValidation(schema.else);\n\n\t\t// Try to detect which specific validations failed\n\t\tconst thenRequiredProps = schema.then.required || [];\n\t\tconst elseRequiredProps = schema.else.required || [];\n\n\t\treturn `.superRefine((obj, ctx) => {\n\t\t\tconst ifConditionMet = ${ifCondition};\n\t\t\tif (ifConditionMet) {\n\t\t\t\t// Then branch\n\t\t\t\tconst thenValid = ${thenValidation};\n\t\t\t\tif (!thenValid) {\n\t\t\t\t\t${\n\t\t\t\t\t\tthenRequiredProps.length > 0\n\t\t\t\t\t\t\t? `\n\t\t\t\t\tconst missingThenProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);\n\t\t\t\t\tconst message = missingThenProps.length > 0 \n\t\t\t\t\t\t? \\`When condition is met, required properties are missing: \\${missingThenProps.join(', ')}\\`\n\t\t\t\t\t\t: \"When condition is met, validation constraints failed\";\n\t\t\t\t\t`\n\t\t\t\t\t\t\t: `\n\t\t\t\t\tconst message = \"When condition is met, validation constraints failed\";\n\t\t\t\t\t`\n\t\t\t\t\t}\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: message,\n\t\t\t\t\t\tpath: []\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Else branch\n\t\t\t\tconst elseValid = ${elseValidation};\n\t\t\t\tif (!elseValid) {\n\t\t\t\t\t${\n\t\t\t\t\t\telseRequiredProps.length > 0\n\t\t\t\t\t\t\t? `\n\t\t\t\t\tconst missingElseProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);\n\t\t\t\t\tconst message = missingElseProps.length > 0 \n\t\t\t\t\t\t? \\`When condition is not met, required properties are missing: \\${missingElseProps.join(', ')}\\`\n\t\t\t\t\t\t: \"When condition is not met, validation constraints failed\";\n\t\t\t\t\t`\n\t\t\t\t\t\t\t: `\n\t\t\t\t\tconst message = \"When condition is not met, validation constraints failed\";\n\t\t\t\t\t`\n\t\t\t\t\t}\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: message,\n\t\t\t\t\t\tpath: []\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t})`;\n\t}\n\n\tif (schema.then) {\n\t\t// Only then - provide detailed error message\n\t\tconst thenValidation = generateConditionalValidation(schema.then);\n\t\tconst thenRequiredProps = schema.then.required || [];\n\n\t\treturn `.superRefine((obj, ctx) => {\n\t\t\tconst ifConditionMet = ${ifCondition};\n\t\t\tif (ifConditionMet) {\n\t\t\t\tconst thenValid = ${thenValidation};\n\t\t\t\tif (!thenValid) {\n\t\t\t\t\t${\n\t\t\t\t\t\tthenRequiredProps.length > 0\n\t\t\t\t\t\t\t? `\n\t\t\t\t\tconst missingProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);\n\t\t\t\t\tconst message = missingProps.length > 0 \n\t\t\t\t\t\t? \\`When condition is met, required properties are missing: \\${missingProps.join(', ')}\\`\n\t\t\t\t\t\t: \"When condition is met, validation constraints failed\";\n\t\t\t\t\t`\n\t\t\t\t\t\t\t: `\n\t\t\t\t\tconst message = \"When condition is met, validation constraints failed\";\n\t\t\t\t\t`\n\t\t\t\t\t}\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: message,\n\t\t\t\t\t\tpath: []\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t})`;\n\t}\n\n\t// Only else - provide detailed error message\n\tif (!schema.else) return \"\";\n\tconst elseValidation = generateConditionalValidation(schema.else);\n\tconst elseRequiredProps = schema.else.required || [];\n\n\treturn `.superRefine((obj, ctx) => {\n\t\tconst ifConditionMet = ${ifCondition};\n\t\tif (!ifConditionMet) {\n\t\t\tconst elseValid = ${elseValidation};\n\t\t\tif (!elseValid) {\n\t\t\t\t${\n\t\t\t\t\telseRequiredProps.length > 0\n\t\t\t\t\t\t? `\n\t\t\t\tconst missingProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);\n\t\t\t\tconst message = missingProps.length > 0 \n\t\t\t\t\t? \\`When condition is not met, required properties are missing: \\${missingProps.join(', ')}\\`\n\t\t\t\t\t: \"When condition is not met, validation constraints failed\";\n\t\t\t\t`\n\t\t\t\t\t\t: `\n\t\t\t\tconst message = \"When condition is not met, validation constraints failed\";\n\t\t\t\t`\n\t\t\t\t}\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: message,\n\t\t\t\t\tpath: []\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t})`;\n}\n\n/**\n * Generate dependent required validation (OpenAPI 3.1)\n * Generates detailed error messages showing which specific fields are missing\n */\nexport function generateDependentRequired(schema: OpenAPISchema): string {\n\tif (!schema.dependentRequired) {\n\t\treturn \"\";\n\t}\n\n\tlet result = \"\";\n\tfor (const [prop, requiredProps] of Object.entries(schema.dependentRequired)) {\n\t\t// Skip empty required arrays (no dependencies to enforce)\n\t\tif (requiredProps.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst propAccess = generatePropertyAccess(prop);\n\t\tconst checkLogic = requiredProps\n\t\t\t.map(rp => {\n\t\t\t\tconst rpAccess = generatePropertyAccess(rp);\n\t\t\t\treturn `if (${rpAccess} === undefined) missing.push('${rp}');`;\n\t\t\t})\n\t\t\t.join(\"\\n\\t\\t\");\n\n\t\tresult += `.superRefine((obj, ctx) => {\n\t\t\tif (${propAccess} === undefined) return;\n\t\t\tconst missing: string[] = [];\n\t\t\t${checkLogic}\n\t\t\tif (missing.length > 0) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: \\`When '${prop}' is present, the following properties are required: \\${missing.join(', ')}\\`,\n\t\t\t\t\tpath: []\n\t\t\t\t});\n\t\t\t}\n\t\t})`;\n\t}\n\n\treturn result;\n}\n\n/**\n * Generate dependent schemas validation (JSON Schema 2019-09 / OpenAPI 3.1)\n * This is the modern replacement for schema-based dependencies\n * Generates detailed error messages showing validation failures\n */\nexport function generateDependentSchemas(\n\tschema: OpenAPISchema & { dependentSchemas?: Record<string, OpenAPISchema> },\n\tgeneratePropertySchema?: (schema: OpenAPISchema, currentSchema?: string) => string,\n\tcurrentSchema?: string\n): string {\n\tif (!schema.dependentSchemas || !generatePropertySchema) {\n\t\treturn \"\";\n\t}\n\n\tlet result = \"\";\n\tfor (const [prop, depSchema] of Object.entries(schema.dependentSchemas)) {\n\t\tconst depSchemaValidation = generatePropertySchema(depSchema, currentSchema);\n\t\tconst propAccess = generatePropertyAccess(prop);\n\n\t\tresult += `.superRefine((obj, ctx) => {\n\t\t\tif (${propAccess} === undefined) return;\n\t\t\tconst validation = ${depSchemaValidation}.safeParse(obj);\n\t\t\tif (!validation.success) {\n\t\t\t\tconst errors = validation.error.issues.map(i => \\` - \\${i.path.join('.')}: \\${i.message}\\`).join('\\\\n');\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: \\`When '${prop}' is present, dependent schema validation failed:\\\\n\\${errors}\\`,\n\t\t\t\t\tpath: []\n\t\t\t\t});\n\t\t\t}\n\t\t})`;\n\t}\n\treturn result;\n}\n\n/**\n * Validate dependency graph for circular dependencies\n * Returns validation result with any detected circular dependency errors\n */\nexport function validateDependencyGraph(\n\tschema: OpenAPISchema,\n\tschemaName: string\n): { valid: boolean; errors: string[] } {\n\tconst errors: string[] = [];\n\n\tif (!schema.dependencies && !schema.dependentRequired) {\n\t\treturn { valid: true, errors: [] };\n\t}\n\n\t// Build dependency graph\n\tconst graph = new Map<string, Set<string>>();\n\n\t// Add dependentRequired edges\n\tif (schema.dependentRequired) {\n\t\tfor (const [prop, deps] of Object.entries(schema.dependentRequired)) {\n\t\t\tif (!graph.has(prop)) {\n\t\t\t\tgraph.set(prop, new Set());\n\t\t\t}\n\t\t\tconst propDeps = graph.get(prop);\n\t\t\tif (propDeps) {\n\t\t\t\tfor (const dep of deps) {\n\t\t\t\t\tpropDeps.add(dep);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Add dependencies (array type) edges\n\tif (schema.dependencies) {\n\t\tfor (const [prop, dep] of Object.entries(schema.dependencies)) {\n\t\t\tif (Array.isArray(dep)) {\n\t\t\t\tif (!graph.has(prop)) {\n\t\t\t\t\tgraph.set(prop, new Set());\n\t\t\t\t}\n\t\t\t\tconst propDeps = graph.get(prop);\n\t\t\t\tif (propDeps) {\n\t\t\t\t\tfor (const d of dep) {\n\t\t\t\t\t\tpropDeps.add(d);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Detect cycles using DFS\n\tconst visited = new Set<string>();\n\tconst recStack = new Set<string>();\n\tconst path: string[] = [];\n\n\tfunction detectCycle(prop: string): boolean {\n\t\tvisited.add(prop);\n\t\trecStack.add(prop);\n\t\tpath.push(prop);\n\n\t\tconst deps = graph.get(prop) || new Set();\n\t\tfor (const dep of deps) {\n\t\t\tif (!visited.has(dep)) {\n\t\t\t\tif (detectCycle(dep)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else if (recStack.has(dep)) {\n\t\t\t\t// Cycle detected\n\t\t\t\tconst cycleStart = path.indexOf(dep);\n\t\t\t\tconst cycle = [...path.slice(cycleStart), dep];\n\t\t\t\terrors.push(`Circular dependency detected in schema '${schemaName}': ${cycle.join(\" -> \")}`);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\trecStack.delete(prop);\n\t\tpath.pop();\n\t\treturn false;\n\t}\n\n\t// Check all roots\n\tfor (const prop of graph.keys()) {\n\t\tif (!visited.has(prop)) {\n\t\t\tdetectCycle(prop);\n\t\t}\n\t}\n\n\treturn { valid: errors.length === 0, errors };\n}\n\n/**\n * Extract schema dependencies as reusable schemas\n * Useful for code generation and schema reuse\n */\nexport function extractSchemaDependencies(schema: OpenAPISchema, schemaName: string): Map<string, OpenAPISchema> {\n\tconst extracted = new Map<string, OpenAPISchema>();\n\n\tif (!schema.dependencies) {\n\t\treturn extracted;\n\t}\n\n\tfor (const [prop, dependency] of Object.entries(schema.dependencies)) {\n\t\tif (!Array.isArray(dependency)) {\n\t\t\t// This is a schema dependency\n\t\t\tconst depSchemaName = `${schemaName}_${prop}_Dependency`;\n\t\t\tconst depSchema: OpenAPISchema = {\n\t\t\t\t...dependency,\n\t\t\t\ttype: dependency.type || \"object\",\n\t\t\t};\n\t\t\textracted.set(depSchemaName, depSchema);\n\t\t}\n\t}\n\n\treturn extracted;\n}\n","import { generateJSDoc } from \"../generators/jsdoc-generator\";\nimport type { OpenAPISchema } from \"../types\";\nimport { generateDependencies, generateDependentRequired, generateIfThenElse } from \"./conditional-validator\";\n\n/**\n * Check if a property name needs to be quoted in TypeScript object literal\n */\nfunction needsQuoting(propName: string): boolean {\n\t// Valid identifier: starts with letter/underscore/$, followed by letters/digits/underscores/$\n\tconst validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\treturn !validIdentifier.test(propName);\n}\n\n/**\n * Generate property access expression (use dot notation for valid identifiers, bracket notation otherwise)\n */\nfunction generatePropertyAccess(propName: string): string {\n\treturn needsQuoting(propName) ? `obj[\"${propName}\"]` : `obj.${propName}`;\n}\n\nexport type ObjectMode = \"strict\" | \"normal\" | \"loose\";\n\nexport interface ObjectValidatorContext {\n\tgeneratePropertySchema: (schema: OpenAPISchema, currentSchema?: string) => string;\n\tshouldIncludeProperty: (schema: OpenAPISchema) => boolean;\n\tmode: ObjectMode;\n\tincludeDescriptions: boolean;\n\tuseDescribe: boolean;\n}\n\n/**\n * Generate object schema\n */\nexport function generateObjectSchema(\n\tschema: OpenAPISchema,\n\tcontext: ObjectValidatorContext,\n\tcurrentSchema?: string\n): string {\n\tconst required = new Set(schema.required || []);\n\tconst properties: string[] = [];\n\n\t// Process properties if they exist\n\tif (schema.properties) {\n\t\tfor (const [propName, propSchema] of Object.entries(schema.properties)) {\n\t\t\t// Skip properties based on readOnly/writeOnly and schemaType\n\t\t\tif (!context.shouldIncludeProperty(propSchema)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst isRequired = required.has(propName);\n\t\t\tconst zodSchema = context.generatePropertySchema(propSchema, currentSchema);\n\n\t\t\t// Quote property name if it contains special characters\n\t\t\tconst quotedPropName = needsQuoting(propName) ? `\"${propName}\"` : propName;\n\t\t\tlet propertyDef = ` ${quotedPropName}: ${zodSchema}`;\n\t\t\tif (!isRequired) {\n\t\t\t\tpropertyDef += \".optional()\";\n\t\t\t}\n\n\t\t\t// Add JSDoc for property if enabled\n\t\t\tconst jsdoc = generateJSDoc(propSchema, propName, { includeDescriptions: context.includeDescriptions });\n\t\t\tif (jsdoc) {\n\t\t\t\tproperties.push(`${jsdoc.trimEnd()}\\n${propertyDef}`);\n\t\t\t} else {\n\t\t\t\tproperties.push(propertyDef);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Determine object method based on mode and additionalProperties\n\tlet objectMethod: string;\n\n\t// additionalProperties: false always uses strictObject\n\tif (schema.additionalProperties === false) {\n\t\tobjectMethod = \"z.strictObject\";\n\t} else {\n\t\t// Otherwise respect the mode setting\n\t\tswitch (context.mode) {\n\t\t\tcase \"strict\":\n\t\t\t\tobjectMethod = \"z.strictObject\";\n\t\t\t\tbreak;\n\t\t\tcase \"loose\":\n\t\t\t\tobjectMethod = \"z.looseObject\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tobjectMethod = \"z.object\";\n\t\t}\n\t}\n\n\tlet objectDef = `${objectMethod}({\\n${properties.join(\",\\n\")}\\n})`;\n\n\t// Handle additionalProperties for typed catchall\n\tif (schema.additionalProperties !== undefined) {\n\t\tif (typeof schema.additionalProperties === \"object\") {\n\t\t\t// Additional properties with specific schema\n\t\t\tconst additionalSchema = context.generatePropertySchema(schema.additionalProperties, currentSchema);\n\t\t\tobjectDef += `.catchall(${additionalSchema})`;\n\t\t} else if (schema.additionalProperties === true) {\n\t\t\t// Any additional properties allowed\n\t\t\tobjectDef += \".catchall(z.unknown())\";\n\t\t}\n\t\t// Note: additionalProperties: false is handled by using z.strictObject\n\t} else if (schema.patternProperties) {\n\t\t// If pattern properties are defined but additionalProperties is not, allow properties through\n\t\t// so they can be validated by pattern property refinements\n\t\tobjectDef += \".catchall(z.unknown())\";\n\t}\n\n\t// Handle minProperties and maxProperties\n\tif (schema.minProperties !== undefined || schema.maxProperties !== undefined) {\n\t\tconst conditions: string[] = [];\n\t\tif (schema.minProperties !== undefined) {\n\t\t\tconditions.push(`Object.keys(obj).length >= ${schema.minProperties}`);\n\t\t}\n\t\tif (schema.maxProperties !== undefined) {\n\t\t\tconditions.push(`Object.keys(obj).length <= ${schema.maxProperties}`);\n\t\t}\n\t\tconst condition = conditions.join(\" && \");\n\t\tlet message = \"Object \";\n\t\tif (schema.minProperties !== undefined && schema.maxProperties !== undefined) {\n\t\t\tmessage += `must have between ${schema.minProperties} and ${schema.maxProperties} properties`;\n\t\t} else if (schema.minProperties !== undefined) {\n\t\t\tmessage += `must have at least ${schema.minProperties} ${schema.minProperties === 1 ? \"property\" : \"properties\"}`;\n\t\t} else {\n\t\t\tmessage += `must have at most ${schema.maxProperties} ${schema.maxProperties === 1 ? \"property\" : \"properties\"}`;\n\t\t}\n\t\tobjectDef += `.refine((obj) => ${condition}, { message: \"${message}\" })`;\n\t}\n\n\t// Handle required fields that aren't in properties (common in schema dependencies)\n\tconst definedProps = new Set(Object.keys(schema.properties || {}));\n\tconst undefinedRequired = (schema.required || []).filter(prop => !definedProps.has(prop));\n\tif (undefinedRequired.length > 0) {\n\t\t// Need catchall to allow required fields that aren't in properties\n\t\tif (!objectDef.includes(\".catchall(\")) {\n\t\t\tobjectDef += \".catchall(z.unknown())\";\n\t\t}\n\t\tconst requiredChecks = undefinedRequired.map(prop => `${generatePropertyAccess(prop)} !== undefined`).join(\" && \");\n\t\tconst propList = undefinedRequired.join(\", \");\n\t\tobjectDef += `.refine((obj) => ${requiredChecks}, { message: \"Missing required fields: ${propList}\" })`;\n\t}\n\n\t// Handle pattern properties with first-match-wins priority\n\tif (schema.patternProperties) {\n\t\tconst definedProps = Object.keys(schema.properties || {});\n\t\tconst definedPropsSet = `new Set(${JSON.stringify(definedProps)})`;\n\t\tconst patterns = Object.entries(schema.patternProperties);\n\n\t\t// Generate schemas for all patterns\n\t\tconst patternSchemas = patterns.map(([pattern, patternSchema]) => ({\n\t\t\tpattern,\n\t\t\tescapedPattern: pattern.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\"),\n\t\t\tzodSchema: context.generatePropertySchema(patternSchema, currentSchema),\n\t\t}));\n\n\t\t// Single superRefine for all patterns (more efficient)\n\t\tobjectDef += `.superRefine((obj, ctx) => {\n\t\t\tconst definedPropsSet = ${definedPropsSet};\n\t\t\tconst patterns = ${JSON.stringify(patternSchemas.map(p => ({ pattern: p.escapedPattern })))};\n\t\t\tconst schemas = [${patternSchemas.map(p => p.zodSchema).join(\", \")}];\n\t\t\tconst regexps = patterns.map(p => new RegExp(p.pattern));\n\n\t\t\t// Check all object keys\n\t\t\tfor (const key of Object.keys(obj)) {\n\t\t\t\t// Skip properties that are explicitly defined\n\t\t\t\tif (definedPropsSet.has(key)) continue;\n\n\t\t\t\t// Find first matching pattern (first-match-wins priority)\n\t\t\t\tfor (let i = 0; i < regexps.length; i++) {\n\t\t\t\t\tif (regexps[i].test(key)) {\n\t\t\t\t\t\tconst validation = schemas[i].safeParse(obj[key]);\n\t\t\t\t\t\tif (!validation.success) {\n\t\t\t\t\t\t\t// Add detailed error messages with property name and pattern\n\t\t\t\t\t\t\tfor (const issue of validation.error.issues) {\n\t\t\t\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\tpath: [key, ...issue.path],\n\t\t\t\t\t\t\t\t\tmessage: \\`Property '\\${key}' (pattern '\\${patterns[i].pattern}'): \\${issue.message}\\`\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak; // First match wins, stop checking other patterns\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})`;\n\t}\n\n\t// Handle property names validation (consolidated for efficiency)\n\tif (schema.propertyNames) {\n\t\tconst hasPattern = schema.propertyNames.pattern !== undefined;\n\t\tconst hasMinLength = schema.propertyNames.minLength !== undefined;\n\t\tconst hasMaxLength = schema.propertyNames.maxLength !== undefined;\n\n\t\tif (hasPattern || hasMinLength || hasMaxLength) {\n\t\t\tconst escapedPattern =\n\t\t\t\thasPattern && schema.propertyNames.pattern\n\t\t\t\t\t? schema.propertyNames.pattern.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")\n\t\t\t\t\t: null;\n\t\t\tconst minLen = schema.propertyNames.minLength;\n\t\t\tconst maxLen = schema.propertyNames.maxLength;\n\n\t\t\tobjectDef += `.superRefine((obj, ctx) => {\n\t\t\t\t${escapedPattern ? `const pattern = /${escapedPattern}/;` : \"\"}\n\n\t\t\t\tfor (const key of Object.keys(obj)) {\n\t\t\t\t\tconst failures: string[] = [];\n\n\t\t\t\t\t${\n\t\t\t\t\t\thasPattern\n\t\t\t\t\t\t\t? `\n\t\t\t\t\tif (!pattern.test(key)) {\n\t\t\t\t\t\tfailures.push(\"must match pattern '${schema.propertyNames.pattern}'\");\n\t\t\t\t\t}\n\t\t\t\t\t`\n\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t}\n\n\t\t\t\t\t${\n\t\t\t\t\t\thasMinLength\n\t\t\t\t\t\t\t? `\n\t\t\t\t\tif (key.length < ${minLen}) {\n\t\t\t\t\t\tfailures.push(\"must be at least ${minLen} characters\");\n\t\t\t\t\t}\n\t\t\t\t\t`\n\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t}\n\n\t\t\t\t\t${\n\t\t\t\t\t\thasMaxLength\n\t\t\t\t\t\t\t? `\n\t\t\t\t\tif (key.length > ${maxLen}) {\n\t\t\t\t\t\tfailures.push(\"must be at most ${maxLen} characters\");\n\t\t\t\t\t}\n\t\t\t\t\t`\n\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t}\n\n\t\t\t\t\tif (failures.length > 0) {\n\t\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\t\tmessage: \\`Property name '\\${key}' \\${failures.join(\", \")}\\`,\n\t\t\t\t\t\t\tpath: [key]\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})`;\n\t\t}\n\t}\n\n\t// Handle dependencies (OpenAPI 3.0)\n\tobjectDef += generateDependencies(schema, context.generatePropertySchema, currentSchema);\n\n\t// Handle dependentRequired\n\tobjectDef += generateDependentRequired(schema);\n\n\t// Handle if/then/else conditionals\n\tobjectDef += generateIfThenElse(schema);\n\n\treturn objectDef;\n}\n","import type { OpenAPISchema } from \"../types\";\nimport type { LRUCache } from \"../utils/lru-cache\";\nimport { addDescription, escapePattern } from \"../utils/string-utils\";\n\n/**\n * Context for string validation generation (parallel-safe)\n */\nexport interface StringValidatorContext {\n\t/**\n\t * Zod validation string for date-time format fields\n\t */\n\tdateTimeValidation: string;\n\t/**\n\t * Instance-level cache for escaped regex patterns\n\t */\n\tpatternCache: LRUCache<string, string>;\n}\n\n// Default format map (immutable, without date-time which is passed via context)\nconst DEFAULT_FORMAT_MAP: Record<string, string> = {\n\tuuid: \"z.uuid()\",\n\temail: \"z.email()\",\n\turi: \"z.url()\",\n\turl: \"z.url()\",\n\t\"uri-reference\": 'z.string().refine((val) => !/\\\\s/.test(val), { message: \"Must be a valid URI reference\" })',\n\thostname:\n\t\t'z.string().refine((val) => /^(?=.{1,253}$)(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\\\.)*(?!-)[A-Za-z0-9-]{1,63}(?<!-)$/.test(val), { message: \"Must be a valid hostname\" })',\n\tbyte: \"z.base64()\",\n\tbinary: \"z.string()\",\n\tdate: \"z.iso.date()\",\n\ttime: \"z.iso.time()\",\n\tduration:\n\t\t'z.string().refine((val) => /^P(?:(?:\\\\d+Y)?(?:\\\\d+M)?(?:\\\\d+D)?(?:T(?:\\\\d+H)?(?:\\\\d+M)?(?:\\\\d+(?:\\\\.\\\\d+)?S)?)?|\\\\d+W)$/.test(val) && !/^PT?$/.test(val), { message: \"Must be a valid ISO 8601 duration\" })',\n\tipv4: \"z.ipv4()\",\n\tipv6: \"z.ipv6()\",\n\temoji: \"z.emoji()\",\n\tbase64: \"z.base64()\",\n\tbase64url: \"z.base64url()\",\n\tnanoid: \"z.nanoid()\",\n\tcuid: \"z.cuid()\",\n\tcuid2: \"z.cuid2()\",\n\tulid: \"z.ulid()\",\n\tcidr: \"z.cidrv4()\", // Default to v4\n\tcidrv4: \"z.cidrv4()\",\n\tcidrv6: \"z.cidrv6()\",\n\t\"json-pointer\":\n\t\t'z.string().refine((val) => val === \"\" || /^(\\\\/([^~/]|~0|~1)+)+$/.test(val), { message: \"Must be a valid JSON Pointer (RFC 6901)\" })',\n\t\"relative-json-pointer\":\n\t\t'z.string().refine((val) => /^(0|[1-9]\\\\d*)(#|(\\\\/([^~/]|~0|~1)+)*)$/.test(val), { message: \"Must be a valid relative JSON Pointer\" })',\n};\n\n/**\n * Build the Zod validation string for date-time format\n * Pure function that returns the validation string without side effects\n *\n * @param pattern - Optional regex pattern (string or RegExp) for date-time validation\n * @returns Zod validation string (either \"z.iso.datetime()\" or custom regex)\n * @throws {Error} If the provided pattern is not a valid regular expression\n *\n * @example\n * // Default (no pattern)\n * buildDateTimeValidation() // Returns \"z.iso.datetime()\"\n *\n * @example\n * // String pattern (for JSON/YAML configs)\n * buildDateTimeValidation('^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}$')\n *\n * @example\n * // RegExp literal (TypeScript configs)\n * buildDateTimeValidation(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/)\n */\nexport function buildDateTimeValidation(pattern?: string | RegExp): string {\n\tif (!pattern) {\n\t\treturn \"z.iso.datetime()\";\n\t}\n\n\t// Convert RegExp to string if needed\n\tconst patternStr = pattern instanceof RegExp ? pattern.source : pattern;\n\n\t// Empty string returns default\n\tif (patternStr === \"\") {\n\t\treturn \"z.iso.datetime()\";\n\t}\n\n\t// Validate the regex pattern\n\ttry {\n\t\tnew RegExp(patternStr);\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Invalid regular expression pattern for customDateTimeFormatRegex: ${patternStr}. ${\n\t\t\t\terror instanceof Error ? error.message : \"Pattern is malformed\"\n\t\t\t}`\n\t\t);\n\t}\n\n\t// Escape the pattern for use in generated code\n\tconst escapedPattern = escapePattern(patternStr);\n\n\treturn `z.string().regex(/${escapedPattern}/)`;\n}\n\n/**\n * Generate Zod validation for string with format (Zod v4 compatible)\n * Thread-safe: uses context for date-time validation and pattern cache\n *\n * @param schema - OpenAPI schema to generate validation for\n * @param useDescribe - Whether to add .describe() calls\n * @param context - Context containing dateTimeValidation and patternCache (parallel-safe)\n */\nexport function generateStringValidation(\n\tschema: OpenAPISchema,\n\tuseDescribe: boolean,\n\tcontext: StringValidatorContext\n): string {\n\t// Handle format with Zod v4 top-level functions\n\t// Use context.dateTimeValidation for date-time format, DEFAULT_FORMAT_MAP for others\n\tlet validation: string;\n\tconst format = schema.format || \"\";\n\n\tif (format === \"date-time\") {\n\t\tvalidation = context.dateTimeValidation;\n\t} else {\n\t\tvalidation = DEFAULT_FORMAT_MAP[format] || \"z.string()\";\n\t}\n\n\t// Add length constraints\n\tif (schema.minLength !== undefined) {\n\t\tvalidation += `.min(${schema.minLength})`;\n\t}\n\tif (schema.maxLength !== undefined) {\n\t\tvalidation += `.max(${schema.maxLength})`;\n\t}\n\n\t// Add pattern (with cached escaping for performance using context.patternCache)\n\tif (schema.pattern) {\n\t\tlet escapedPattern = context.patternCache.get(schema.pattern);\n\t\tif (escapedPattern === undefined) {\n\t\t\tescapedPattern = escapePattern(schema.pattern);\n\t\t\tcontext.patternCache.set(schema.pattern, escapedPattern);\n\t\t}\n\t\tvalidation += `.regex(/${escapedPattern}/)`;\n\t}\n\n\t// Handle content encoding (OpenAPI 3.1)\n\tif (schema.contentEncoding && !schema.format) {\n\t\tswitch (schema.contentEncoding) {\n\t\t\tcase \"base64\":\n\t\t\t\tvalidation = \"z.base64()\";\n\t\t\t\tbreak;\n\t\t\tcase \"base64url\":\n\t\t\t\tvalidation = \"z.base64url()\";\n\t\t\t\tbreak;\n\t\t\tcase \"quoted-printable\":\n\t\t\t\t// Quoted-printable validation\n\t\t\t\tvalidation =\n\t\t\t\t\t'z.string().refine((val) => /^[\\\\x20-\\\\x7E\\\\r\\\\n=]*$/.test(val), { message: \"Must be valid quoted-printable encoding\" })';\n\t\t\t\tbreak;\n\t\t\tcase \"7bit\":\n\t\t\tcase \"8bit\":\n\t\t\tcase \"binary\":\n\t\t\t\t// Basic string validation for these encodings\n\t\t\t\tvalidation = \"z.string()\";\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// Unknown encoding, use string with refinement note\n\t\t\t\tvalidation = `z.string().describe(\"Content encoding: ${schema.contentEncoding}\")`;\n\t\t}\n\n\t\t// Re-apply constraints after encoding\n\t\tif (schema.minLength !== undefined) {\n\t\t\tvalidation += `.min(${schema.minLength})`;\n\t\t}\n\t\tif (schema.maxLength !== undefined) {\n\t\t\tvalidation += `.max(${schema.maxLength})`;\n\t\t}\n\t\tif (schema.pattern) {\n\t\t\tlet escapedPattern = context.patternCache.get(schema.pattern);\n\t\t\tif (escapedPattern === undefined) {\n\t\t\t\tescapedPattern = escapePattern(schema.pattern);\n\t\t\t\tcontext.patternCache.set(schema.pattern, escapedPattern);\n\t\t\t}\n\t\t\tvalidation += `.regex(/${escapedPattern}/)`;\n\t\t}\n\t} else if (schema.contentMediaType) {\n\t\t// Add refinement for media type validation\n\t\tconst mediaType = schema.contentMediaType;\n\t\tif (mediaType === \"application/json\") {\n\t\t\tvalidation += `.refine((val) => { try { JSON.parse(val); return true; } catch { return false; } }, { message: \"Must be valid JSON\" })`;\n\t\t} else if (mediaType === \"application/xml\" || mediaType === \"text/xml\") {\n\t\t\t// Basic XML validation - check for well-formed XML structure\n\t\t\tvalidation += `.refine((val) => { try { if (typeof DOMParser !== \"undefined\") { const parser = new DOMParser(); const doc = parser.parseFromString(val, \"text/xml\"); return !doc.querySelector(\"parsererror\"); } return /^\\\\s*<[^>]+>/.test(val); } catch { return false; } }, { message: \"Must be valid XML\" })`;\n\t\t} else if (mediaType === \"application/yaml\" || mediaType === \"application/x-yaml\" || mediaType === \"text/yaml\") {\n\t\t\t// Basic YAML validation - check for basic YAML structure\n\t\t\tvalidation += `.refine((val) => { try { return val.trim().length > 0 && !/^[[{]/.test(val.trim()); } catch { return false; } }, { message: \"Must be valid YAML\" })`;\n\t\t} else if (mediaType === \"text/html\") {\n\t\t\t// Basic HTML validation - check for HTML tags\n\t\t\tvalidation += `.refine((val) => /<[^>]+>/.test(val), { message: \"Must contain HTML tags\" })`;\n\t\t} else if (mediaType === \"text/plain\") {\n\t\t\t// Plain text - no special validation needed, but mark it\n\t\t\tvalidation += `.refine(() => true, { message: \"Plain text content\" })`;\n\t\t}\n\t\t// Other media types default to no validation beyond string\n\t}\n\n\t// Add description if useDescribe is enabled\n\treturn addDescription(validation, schema.description, useDescribe);\n}\n","import type { OpenAPISchema, OpenAPISpec } from \"../types\";\nimport { LRUCache } from \"../utils/lru-cache\";\nimport type { NamingOptions } from \"../utils/name-utils\";\nimport { resolveRef, toCamelCase } from \"../utils/name-utils\";\nimport { stripPrefix } from \"../utils/pattern-utils\";\nimport { addDescription, getPrimaryType, hasMultipleTypes, isNullable, wrapNullable } from \"../utils/string-utils\";\nimport { generateArrayValidation } from \"../validators/array-validator\";\nimport { generateAllOf, generateUnion } from \"../validators/composition-validator\";\nimport { generateNumberValidation } from \"../validators/number-validator\";\nimport type { ObjectMode } from \"../validators/object-validator\";\nimport { generateObjectSchema } from \"../validators/object-validator\";\nimport { generateStringValidation } from \"../validators/string-validator\";\n\nexport interface PropertyGeneratorContext {\n\tspec: OpenAPISpec;\n\tschemaDependencies: Map<string, Set<string>>;\n\tschemaType: \"all\" | \"request\" | \"response\";\n\tmode: ObjectMode;\n\tincludeDescriptions: boolean;\n\tuseDescribe: boolean;\n\tnamingOptions: NamingOptions;\n\tstripSchemaPrefix?: string;\n\t/**\n\t * Default nullable behavior when not explicitly specified\n\t * @default false\n\t */\n\tdefaultNullable: boolean;\n\t/**\n\t * Behavior for empty object schemas (objects with no properties defined)\n\t * @default 'loose'\n\t */\n\temptyObjectBehavior: \"strict\" | \"loose\" | \"record\";\n\t/**\n\t * Zod validation string for date-time format fields\n\t * @default \"z.iso.datetime()\"\n\t */\n\tdateTimeValidation: string;\n\t/**\n\t * Instance-level cache for escaped regex patterns (parallel-safe)\n\t */\n\tpatternCache: LRUCache<string, string>;\n}\n\n/**\n * Property schema generator with memoization for performance\n */\nexport class PropertyGenerator {\n\tprivate context: PropertyGeneratorContext;\n\t// Performance optimization: Memoize filtered property results\n\tprivate filteredPropsCache = new Map<string, OpenAPISchema>();\n\t// Performance optimization: LRU cache for generated schemas\n\tprivate schemaCache = new LRUCache<string, string>(500);\n\n\t// Performance optimization: Lookup table for faster inclusion checks\n\tstatic readonly INCLUSION_RULES = {\n\t\trequest: (schema: OpenAPISchema) => !schema.readOnly,\n\t\tresponse: (schema: OpenAPISchema) => !schema.writeOnly,\n\t\tall: () => true,\n\t} as const;\n\n\tconstructor(context: PropertyGeneratorContext) {\n\t\tthis.context = context;\n\t}\n\n\t/**\n\t * Check if a property should be included based on schemaType and readOnly/writeOnly flags\n\t */\n\tshouldIncludeProperty(schema: OpenAPISchema): boolean {\n\t\tconst rule = PropertyGenerator.INCLUSION_RULES[this.context.schemaType];\n\t\treturn rule(schema);\n\t}\n\n\t/**\n\t * Recursively filter any schema type (helper for composition schemas)\n\t */\n\tprivate filterSchemaRecursive(schema: OpenAPISchema): OpenAPISchema {\n\t\tif (schema.$ref) {\n\t\t\t// Don't filter refs, they'll be filtered when resolved\n\t\t\treturn schema;\n\t\t}\n\n\t\tif (schema.properties) {\n\t\t\treturn this.filterNestedProperties(schema);\n\t\t}\n\n\t\tif (schema.type === \"array\" && schema.items && typeof schema.items === \"object\" && schema.items.properties) {\n\t\t\treturn {\n\t\t\t\t...schema,\n\t\t\t\titems: this.filterNestedProperties(schema.items),\n\t\t\t};\n\t\t}\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Recursively filter properties in nested objects based on readOnly/writeOnly\n\t * Performance optimized with memoization\n\t */\n\tprivate filterNestedProperties(schema: OpenAPISchema): OpenAPISchema {\n\t\t// Performance optimization: More efficient cache key generation\n\t\tconst propKeys = schema.properties ? Object.keys(schema.properties).sort().join(\",\") : \"\";\n\t\tconst cacheKey = `${this.context.schemaType}:${schema.type || \"unknown\"}:${propKeys}:${schema.required?.join(\",\") || \"\"}`;\n\t\tconst cached = this.filteredPropsCache.get(cacheKey);\n\t\tif (cached) {\n\t\t\treturn cached;\n\t\t}\n\n\t\tif (!schema.properties) {\n\t\t\treturn schema;\n\t\t}\n\n\t\tconst filteredProperties: Record<string, OpenAPISchema> = {};\n\t\tconst filteredRequired: string[] = [];\n\n\t\tfor (const [propName, propSchema] of Object.entries(schema.properties)) {\n\t\t\tif (!this.shouldIncludeProperty(propSchema)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Recursively filter nested structures\n\t\t\tlet filteredPropSchema = propSchema;\n\n\t\t\tif (propSchema.type === \"object\" && propSchema.properties) {\n\t\t\t\t// Nested object\n\t\t\t\tfilteredPropSchema = this.filterNestedProperties(propSchema);\n\t\t\t} else if (\n\t\t\t\tpropSchema.type === \"array\" &&\n\t\t\t\tpropSchema.items &&\n\t\t\t\ttypeof propSchema.items === \"object\" &&\n\t\t\t\tpropSchema.items.properties\n\t\t\t) {\n\t\t\t\t// Array of objects\n\t\t\t\tfilteredPropSchema = {\n\t\t\t\t\t...propSchema,\n\t\t\t\t\titems: this.filterNestedProperties(propSchema.items),\n\t\t\t\t};\n\t\t\t} else if (propSchema.allOf || propSchema.oneOf || propSchema.anyOf) {\n\t\t\t\t// Composition schemas - filter each branch\n\t\t\t\tif (propSchema.allOf) {\n\t\t\t\t\tfilteredPropSchema = {\n\t\t\t\t\t\t...propSchema,\n\t\t\t\t\t\tallOf: propSchema.allOf.map(s => this.filterSchemaRecursive(s)),\n\t\t\t\t\t};\n\t\t\t\t} else if (propSchema.oneOf) {\n\t\t\t\t\tfilteredPropSchema = {\n\t\t\t\t\t\t...propSchema,\n\t\t\t\t\t\toneOf: propSchema.oneOf.map(s => this.filterSchemaRecursive(s)),\n\t\t\t\t\t};\n\t\t\t\t} else if (propSchema.anyOf) {\n\t\t\t\t\tfilteredPropSchema = {\n\t\t\t\t\t\t...propSchema,\n\t\t\t\t\t\tanyOf: propSchema.anyOf.map(s => this.filterSchemaRecursive(s)),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfilteredProperties[propName] = filteredPropSchema;\n\n\t\t\t// Keep required status if property is included\n\t\t\tif (schema.required?.includes(propName)) {\n\t\t\t\tfilteredRequired.push(propName);\n\t\t\t}\n\t\t}\n\n\t\tconst result = {\n\t\t\t...schema,\n\t\t\tproperties: filteredProperties,\n\t\t\trequired: filteredRequired.length > 0 ? filteredRequired : undefined,\n\t\t};\n\n\t\t// Cache the result\n\t\tthis.filteredPropsCache.set(cacheKey, result);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Resolve discriminator mapping to actual schema references\n\t */\n\tprivate resolveDiscriminatorMapping(mapping: Record<string, string>, schemas: OpenAPISchema[]): OpenAPISchema[] {\n\t\t// If mapping is provided, use it to reorder/filter schemas\n\t\t// The mapping maps discriminator values to schema references\n\t\tconst mappedSchemas: OpenAPISchema[] = [];\n\n\t\tfor (const [_, schemaRef] of Object.entries(mapping)) {\n\t\t\t// Find the schema that matches this reference\n\t\t\tconst matchingSchema = schemas.find(s => {\n\t\t\t\tif (s.$ref) {\n\t\t\t\t\t// Check if the ref matches\n\t\t\t\t\treturn s.$ref === schemaRef || s.$ref.endsWith(schemaRef);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\n\t\t\tif (matchingSchema) {\n\t\t\t\tmappedSchemas.push(matchingSchema);\n\t\t\t} else {\n\t\t\t\t// Schema not found in oneOf/anyOf, create a reference\n\t\t\t\tmappedSchemas.push({ $ref: schemaRef });\n\t\t\t}\n\t\t}\n\n\t\t// Include any schemas that weren't in the mapping\n\t\tfor (const schema of schemas) {\n\t\t\tif (!mappedSchemas.includes(schema)) {\n\t\t\t\tmappedSchemas.push(schema);\n\t\t\t}\n\t\t}\n\n\t\treturn mappedSchemas;\n\t}\n\n\t/**\n\t * Resolve a $ref string to the actual schema\n\t */\n\tprivate resolveSchemaRef(ref: string): OpenAPISchema | undefined {\n\t\tconst schemaName = ref.split(\"/\").pop();\n\t\tif (!schemaName) return undefined;\n\t\treturn this.context.spec.components?.schemas?.[schemaName];\n\t}\n\n\t/**\n\t * Resolve a schema name through any aliases to get the actual schema name\n\t * If the schema is an alias (allOf with single $ref), return the target name\n\t */\n\tprivate resolveSchemaAlias(schemaName: string): string {\n\t\tconst schema = this.context.spec.components?.schemas?.[schemaName];\n\t\tif (!schema) return schemaName;\n\n\t\t// Check if this is a simple alias (allOf with single $ref and nothing else)\n\t\tif (\n\t\t\tschema.allOf &&\n\t\t\tschema.allOf.length === 1 &&\n\t\t\tschema.allOf[0].$ref &&\n\t\t\t!schema.properties &&\n\t\t\t!schema.oneOf &&\n\t\t\t!schema.anyOf\n\t\t) {\n\t\t\tconst targetName = resolveRef(schema.allOf[0].$ref);\n\t\t\t// Recursively resolve in case of chained aliases\n\t\t\treturn this.resolveSchemaAlias(targetName);\n\t\t}\n\n\t\treturn schemaName;\n\t}\n\n\t/**\n\t * Check if this is a circular dependency through aliases\n\t */\n\tprivate isCircularThroughAlias(fromSchema: string, toSchema: string): boolean {\n\t\tconst toSchemaSpec = this.context.spec.components?.schemas?.[toSchema];\n\t\tif (!toSchemaSpec) return false;\n\n\t\t// Check if toSchema is a simple alias (allOf with single $ref)\n\t\tif (toSchemaSpec.allOf && toSchemaSpec.allOf.length === 1 && toSchemaSpec.allOf[0].$ref) {\n\t\t\tconst aliasTarget = resolveRef(toSchemaSpec.allOf[0].$ref);\n\t\t\t// If the alias points back to the original schema, it's circular\n\t\t\treturn aliasTarget === fromSchema;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Generate union for multiple types (OpenAPI 3.1)\n\t */\n\tprivate generateMultiTypeUnion(schema: OpenAPISchema, currentSchema?: string): string {\n\t\tif (!Array.isArray(schema.type)) {\n\t\t\treturn \"z.unknown()\";\n\t\t}\n\t\tconst nonNullTypes = schema.type.filter(t => t !== \"null\");\n\t\tconst schemas = nonNullTypes.map(type => {\n\t\t\tconst typeSchema = { ...schema, type };\n\t\t\treturn this.generatePropertySchema(typeSchema, currentSchema);\n\t\t});\n\t\treturn `z.union([${schemas.join(\", \")}])`;\n\t}\n\n\t/**\n\t * Apply unevaluatedProperties validation to a schema\n\t */\n\tprivate applyUnevaluatedProperties(baseSchema: string, schema: OpenAPISchema): string {\n\t\t// Collect all evaluated properties from the schema and its composition\n\t\tconst evaluatedProps = new Set<string>();\n\n\t\t// Add properties from this schema\n\t\tif (schema.properties) {\n\t\t\tfor (const propName of Object.keys(schema.properties)) {\n\t\t\t\tevaluatedProps.add(propName);\n\t\t\t}\n\t\t}\n\n\t\t// Add properties from allOf/oneOf/anyOf (shallow scan)\n\t\tconst collectPropsFromComposition = (schemas?: OpenAPISchema[]) => {\n\t\t\tif (!schemas) return;\n\t\t\tfor (const subSchema of schemas) {\n\t\t\t\tif (subSchema.properties) {\n\t\t\t\t\tfor (const propName of Object.keys(subSchema.properties)) {\n\t\t\t\t\t\tevaluatedProps.add(propName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Also check $ref schemas\n\t\t\t\tif (subSchema.$ref) {\n\t\t\t\t\tconst refSchema = this.context.spec.components?.schemas?.[subSchema.$ref.split(\"/\").pop() || \"\"];\n\t\t\t\t\tif (refSchema?.properties) {\n\t\t\t\t\t\tfor (const propName of Object.keys(refSchema.properties)) {\n\t\t\t\t\t\t\tevaluatedProps.add(propName);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tcollectPropsFromComposition(schema.allOf);\n\t\tcollectPropsFromComposition(schema.oneOf);\n\t\tcollectPropsFromComposition(schema.anyOf);\n\n\t\tconst evaluatedPropsSet = `new Set(${JSON.stringify([...evaluatedProps])})`;\n\n\t\t// For unions (oneOf/anyOf), we need to add .catchall(z.unknown()) to EACH branch\n\t\t// For allOf with extend(), add catchall to the final result\n\t\tlet schemaWithCatchall = baseSchema;\n\t\tif (baseSchema.includes(\".union([\") || baseSchema.includes(\".discriminatedUnion(\")) {\n\t\t\t// For unions, we need to make each branch allow additional properties\n\t\t\t// This is complex, so we'll apply refinement and let the refinement check the raw input\n\t\t\t// The union will have already validated structure, refinement checks extra props\n\t\t\tschemaWithCatchall = baseSchema;\n\t\t} else if (baseSchema.includes(\".extend(\")) {\n\t\t\t// Wrap in catchall - apply to final result\n\t\t\tschemaWithCatchall = `${baseSchema}.catchall(z.unknown())`;\n\t\t}\n\n\t\tif (schema.unevaluatedProperties === false) {\n\t\t\t// No unevaluated properties allowed\n\t\t\treturn `${schemaWithCatchall}.refine((obj) => Object.keys(obj).every(key => ${evaluatedPropsSet}.has(key)), { message: \"No unevaluated properties allowed\" })`;\n\t\t} else if (typeof schema.unevaluatedProperties === \"object\") {\n\t\t\t// Unevaluated properties must match schema\n\t\t\tconst unevalSchema = this.generatePropertySchema(schema.unevaluatedProperties);\n\t\t\treturn `${schemaWithCatchall}.refine((obj) => Object.keys(obj).filter(key => !${evaluatedPropsSet}.has(key)).every(key => ${unevalSchema}.safeParse(obj[key]).success), { message: \"Unevaluated properties must match the schema\" })`;\n\t\t}\n\n\t\treturn baseSchema;\n\t}\n\n\t/**\n\t * Generate Zod schema for a property\n\t * @param schema - The OpenAPI schema to generate\n\t * @param currentSchema - The name of the current schema being processed (for circular ref detection)\n\t * @param isTopLevel - Whether this is a top-level schema definition\n\t * @param suppressDefaultNullable - When true, don't apply defaultNullable (used when outer schema has explicit nullable: false)\n\t */\n\tgeneratePropertySchema(\n\t\tschema: OpenAPISchema,\n\t\tcurrentSchema?: string,\n\t\tisTopLevel = false,\n\t\tsuppressDefaultNullable = false\n\t): string {\n\t\t// Performance optimization: Check cache for simple schemas\n\t\t// Only cache schemas without $ref or complex compositions to avoid stale circular refs\n\t\tconst isCacheable = !schema.$ref && !schema.allOf && !schema.oneOf && !schema.anyOf && !currentSchema;\n\t\tif (isCacheable) {\n\t\t\tconst cacheKey = JSON.stringify({\n\t\t\t\tschema,\n\t\t\t\ttype: this.context.schemaType,\n\t\t\t\tmode: this.context.mode,\n\t\t\t\tsuppressDefaultNullable,\n\t\t\t});\n\t\t\tconst cached = this.schemaCache.get(cacheKey);\n\t\t\tif (cached) {\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t}\n\n\t\t// Apply nested property filtering if needed\n\t\tif ((this.context.schemaType === \"request\" || this.context.schemaType === \"response\") && schema.properties) {\n\t\t\tschema = this.filterNestedProperties(schema);\n\t\t}\n\n\t\t// Determine if defaultNullable should apply to this schema.\n\t\t// defaultNullable should apply to property values within objects, NOT to:\n\t\t// 1. Top-level schema definitions (isTopLevel = true)\n\t\t// 2. Enum values - enums define discrete values and shouldn't be nullable by default\n\t\t// 3. Const/literal values - these are exact values and shouldn't be nullable by default\n\t\t// 4. When suppressDefaultNullable is true (outer schema has explicit nullable: false)\n\t\t//\n\t\t// Note: $ref properties DO respect defaultNullable. If you want a non-nullable\n\t\t// reference when defaultNullable is true, you must explicitly add `nullable: false`\n\t\t// to the schema containing the $ref.\n\t\tconst isEnum = !!schema.enum;\n\t\tconst isConst = schema.const !== undefined;\n\t\tconst shouldApplyDefaultNullable = !isTopLevel && !isEnum && !isConst && !suppressDefaultNullable;\n\t\tconst effectiveDefaultNullable = shouldApplyDefaultNullable ? this.context.defaultNullable : false;\n\t\tconst nullable = isNullable(schema, effectiveDefaultNullable);\n\n\t\t// Handle multiple types (OpenAPI 3.1)\n\t\tif (hasMultipleTypes(schema)) {\n\t\t\tconst union = this.generateMultiTypeUnion(schema, currentSchema);\n\t\t\treturn wrapNullable(union, nullable);\n\t\t}\n\n\t\t// Handle $ref\n\t\tif (schema.$ref) {\n\t\t\tconst refName = resolveRef(schema.$ref);\n\t\t\t// Resolve through any aliases to get the actual schema\n\t\t\tconst resolvedRefName = this.resolveSchemaAlias(refName);\n\n\t\t\t// Track dependency (but not if it's just an alias at top level)\n\t\t\tif (currentSchema && refName !== currentSchema && !isTopLevel) {\n\t\t\t\tif (!this.context.schemaDependencies.has(currentSchema)) {\n\t\t\t\t\tthis.context.schemaDependencies.set(currentSchema, new Set());\n\t\t\t\t}\n\t\t\t\tthis.context.schemaDependencies.get(currentSchema)?.add(refName);\n\t\t\t}\n\t\t\t// Use the resolved name for the schema reference\n\t\t\t// Apply stripSchemaPrefix to get consistent schema names\n\t\t\tconst strippedRefName = stripPrefix(resolvedRefName, this.context.stripSchemaPrefix);\n\t\t\tconst schemaName = `${toCamelCase(strippedRefName, this.context.namingOptions)}Schema`; // Check for direct self-reference or circular dependency through alias\n\t\t\tif (currentSchema && (refName === currentSchema || this.isCircularThroughAlias(currentSchema, refName))) {\n\t\t\t\t// Use lazy evaluation for circular references with explicit type annotation\n\t\t\t\tconst lazySchema = `z.lazy((): z.ZodTypeAny => ${schemaName})`;\n\t\t\t\treturn wrapNullable(lazySchema, nullable);\n\t\t\t}\n\n\t\t\treturn wrapNullable(schemaName, nullable);\n\t\t}\n\n\t\t// Handle const (literal values)\n\t\tif (schema.const !== undefined) {\n\t\t\tconst literalValue = typeof schema.const === \"string\" ? `\"${schema.const}\"` : schema.const;\n\t\t\tconst zodLiteral = `z.literal(${literalValue})`;\n\t\t\treturn wrapNullable(zodLiteral, nullable);\n\t\t}\n\n\t\t// Handle enum\n\t\tif (schema.enum) {\n\t\t\t// Check if all values are booleans\n\t\t\tconst allBooleans = schema.enum.every(v => typeof v === \"boolean\");\n\t\t\tif (allBooleans) {\n\t\t\t\tconst zodBoolean = \"z.boolean()\";\n\t\t\t\treturn wrapNullable(zodBoolean, nullable);\n\t\t\t}\n\n\t\t\t// Check if all values are strings\n\t\t\tconst allStrings = schema.enum.every(v => typeof v === \"string\");\n\t\t\tif (allStrings) {\n\t\t\t\tconst enumValues = schema.enum.map(v => `\"${v}\"`).join(\", \");\n\t\t\t\tconst zodEnum = `z.enum([${enumValues}])`;\n\t\t\t\treturn wrapNullable(zodEnum, nullable);\n\t\t\t}\n\n\t\t\t// For numeric or mixed enums, use z.union with z.literal\n\t\t\tconst literalValues = schema.enum\n\t\t\t\t.map(v => {\n\t\t\t\t\tif (typeof v === \"string\") {\n\t\t\t\t\t\treturn `z.literal(\"${v}\")`;\n\t\t\t\t\t}\n\t\t\t\t\treturn `z.literal(${v})`;\n\t\t\t\t})\n\t\t\t\t.join(\", \");\n\t\t\tconst zodUnion = `z.union([${literalValues}])`;\n\t\t\treturn wrapNullable(zodUnion, nullable);\n\t\t}\n\n\t\t// Handle allOf\n\t\tif (schema.allOf) {\n\t\t\t// For allOf compositions, only apply nullable if explicitly set on the schema.\n\t\t\t// defaultNullable should NOT apply to composition results - they define schema shapes,\n\t\t\t// not property values. The .nullable() on individual properties inside the composition\n\t\t\t// is handled by generateInlineObjectShape which respects defaultNullable.\n\t\t\tconst compositionNullable = isNullable(schema, false);\n\t\t\tlet composition = generateAllOf(\n\t\t\t\tschema.allOf,\n\t\t\t\tcompositionNullable,\n\t\t\t\t{\n\t\t\t\t\tgeneratePropertySchema: this.generatePropertySchema.bind(this),\n\t\t\t\t\tgenerateInlineObjectShape: this.generateInlineObjectShape.bind(this),\n\t\t\t\t\tresolveSchemaRef: this.resolveSchemaRef.bind(this),\n\t\t\t\t},\n\t\t\t\tcurrentSchema\n\t\t\t);\n\n\t\t\t// Apply unevaluatedProperties if specified\n\t\t\tif (schema.unevaluatedProperties !== undefined) {\n\t\t\t\tcomposition = this.applyUnevaluatedProperties(composition, schema);\n\t\t\t}\n\n\t\t\treturn composition;\n\t\t}\n\n\t\t// Handle oneOf with discriminator support\n\t\tif (schema.oneOf) {\n\t\t\t// For oneOf compositions, only apply nullable if explicitly set on the schema.\n\t\t\t// defaultNullable should NOT apply to composition results.\n\t\t\tconst compositionNullable = isNullable(schema, false);\n\t\t\tconst needsPassthrough = schema.unevaluatedProperties !== undefined;\n\t\t\tlet composition = generateUnion(\n\t\t\t\tschema.oneOf,\n\t\t\t\tschema.discriminator?.propertyName,\n\t\t\t\tcompositionNullable,\n\t\t\t\t{\n\t\t\t\t\tgeneratePropertySchema: this.generatePropertySchema.bind(this),\n\t\t\t\t\tresolveDiscriminatorMapping: this.resolveDiscriminatorMapping.bind(this),\n\t\t\t\t\tresolveSchemaRef: this.resolveSchemaRef.bind(this),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tpassthrough: needsPassthrough,\n\t\t\t\t\tdiscriminatorMapping: schema.discriminator?.mapping,\n\t\t\t\t},\n\t\t\t\tcurrentSchema\n\t\t\t);\n\n\t\t\t// Apply unevaluatedProperties if specified\n\t\t\tif (schema.unevaluatedProperties !== undefined) {\n\t\t\t\tcomposition = this.applyUnevaluatedProperties(composition, schema);\n\t\t\t}\n\n\t\t\treturn composition;\n\t\t}\n\n\t\t// Handle anyOf with discriminator support\n\t\tif (schema.anyOf) {\n\t\t\t// For anyOf compositions, only apply nullable if explicitly set on the schema.\n\t\t\t// defaultNullable should NOT apply to composition results.\n\t\t\tconst compositionNullable = isNullable(schema, false);\n\t\t\tconst needsPassthrough = schema.unevaluatedProperties !== undefined;\n\t\t\tlet composition = generateUnion(\n\t\t\t\tschema.anyOf,\n\t\t\t\tschema.discriminator?.propertyName,\n\t\t\t\tcompositionNullable,\n\t\t\t\t{\n\t\t\t\t\tgeneratePropertySchema: this.generatePropertySchema.bind(this),\n\t\t\t\t\tresolveDiscriminatorMapping: this.resolveDiscriminatorMapping.bind(this),\n\t\t\t\t\tresolveSchemaRef: this.resolveSchemaRef.bind(this),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tpassthrough: needsPassthrough,\n\t\t\t\t\tdiscriminatorMapping: schema.discriminator?.mapping,\n\t\t\t\t},\n\t\t\t\tcurrentSchema\n\t\t\t);\n\n\t\t\t// Apply unevaluatedProperties if specified\n\t\t\tif (schema.unevaluatedProperties !== undefined) {\n\t\t\t\tcomposition = this.applyUnevaluatedProperties(composition, schema);\n\t\t\t}\n\n\t\t\treturn composition;\n\t\t}\n\n\t\t// Handle not keyword (must be after compositions)\n\t\tif (schema.not) {\n\t\t\tconst notSchema = this.generatePropertySchema(schema.not, currentSchema);\n\t\t\tlet baseValidation: string;\n\n\t\t\t// If schema has a type, generate validation for that type first\n\t\t\tif (schema.type || schema.properties || schema.items) {\n\t\t\t\t// Create a copy without 'not' to generate base validation\n\t\t\t\tconst { not: _, ...baseSchema } = schema;\n\t\t\t\tbaseValidation = this.generatePropertySchema(baseSchema, currentSchema);\n\t\t\t} else {\n\t\t\t\t// No specific type, use unknown\n\t\t\t\tbaseValidation = \"z.unknown()\";\n\t\t\t}\n\n\t\t\tconst refined = `${baseValidation}.refine((val) => !${notSchema}.safeParse(val).success, { message: \"Value must not match the excluded schema\" })`;\n\t\t\treturn wrapNullable(refined, nullable);\n\t\t}\n\n\t\tlet validation = \"\";\n\t\tconst primaryType = getPrimaryType(schema);\n\n\t\tswitch (primaryType) {\n\t\t\tcase \"string\":\n\t\t\t\tvalidation = generateStringValidation(schema, this.context.useDescribe, {\n\t\t\t\t\tdateTimeValidation: this.context.dateTimeValidation,\n\t\t\t\t\tpatternCache: this.context.patternCache,\n\t\t\t\t});\n\t\t\t\tbreak;\n\n\t\t\tcase \"number\":\n\t\t\t\tvalidation = generateNumberValidation(schema, false, this.context.useDescribe);\n\t\t\t\tbreak;\n\n\t\t\tcase \"integer\":\n\t\t\t\tvalidation = generateNumberValidation(schema, true, this.context.useDescribe);\n\t\t\t\tbreak;\n\n\t\t\tcase \"boolean\":\n\t\t\t\tvalidation = \"z.boolean()\";\n\t\t\t\tvalidation = addDescription(validation, schema.description, this.context.useDescribe);\n\t\t\t\tbreak;\n\n\t\t\tcase \"array\":\n\t\t\t\tvalidation = generateArrayValidation(schema, {\n\t\t\t\t\tgeneratePropertySchema: this.generatePropertySchema.bind(this),\n\t\t\t\t\tuseDescribe: this.context.useDescribe,\n\t\t\t\t\tcurrentSchema,\n\t\t\t\t});\n\t\t\t\tbreak;\n\n\t\t\tcase \"object\":\n\t\t\t\tif (\n\t\t\t\t\tschema.properties ||\n\t\t\t\t\tschema.required ||\n\t\t\t\t\tschema.minProperties !== undefined ||\n\t\t\t\t\tschema.maxProperties !== undefined ||\n\t\t\t\t\tschema.patternProperties ||\n\t\t\t\t\tschema.propertyNames\n\t\t\t\t) {\n\t\t\t\t\tvalidation = generateObjectSchema(\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgeneratePropertySchema: this.generatePropertySchema.bind(this),\n\t\t\t\t\t\t\tshouldIncludeProperty: this.shouldIncludeProperty.bind(this),\n\t\t\t\t\t\t\tmode: this.context.mode,\n\t\t\t\t\t\t\tincludeDescriptions: this.context.includeDescriptions,\n\t\t\t\t\t\t\tuseDescribe: this.context.useDescribe,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcurrentSchema\n\t\t\t\t\t);\n\t\t\t\t\tvalidation = addDescription(validation, schema.description, this.context.useDescribe);\n\t\t\t\t} else {\n\t\t\t\t\t// Empty object schema - behavior controlled by emptyObjectBehavior option\n\t\t\t\t\tswitch (this.context.emptyObjectBehavior) {\n\t\t\t\t\t\tcase \"strict\":\n\t\t\t\t\t\t\tvalidation = \"z.strictObject({})\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"loose\":\n\t\t\t\t\t\t\tvalidation = \"z.looseObject({})\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tvalidation = \"z.record(z.string(), z.unknown())\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tvalidation = addDescription(validation, schema.description, this.context.useDescribe);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tvalidation = \"z.unknown()\";\n\t\t\t\tvalidation = addDescription(validation, schema.description, this.context.useDescribe);\n\t\t}\n\n\t\tconst result = wrapNullable(validation, nullable);\n\n\t\t// Store in cache if cacheable\n\t\tif (isCacheable) {\n\t\t\tconst cacheKey = JSON.stringify({ schema, type: this.context.schemaType, mode: this.context.mode });\n\t\t\tthis.schemaCache.set(cacheKey, result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Generate inline object shape for use with .extend()\n\t * Returns just the shape object literal: { prop1: z.string(), prop2: z.number() }\n\t *\n\t * This method is specifically for allOf compositions where we need to pass\n\t * the shape directly to .extend() instead of using z.object({...}).shape.\n\t * This avoids the .nullable().shape bug when inline objects have nullable: true.\n\t *\n\t * According to Zod docs (https://zod.dev/api?id=extend):\n\t * - .extend() accepts an object of shape definitions\n\t * - e.g., baseSchema.extend({ prop: z.string() })\n\t */\n\tgenerateInlineObjectShape(schema: OpenAPISchema, currentSchema?: string): string {\n\t\tconst required = new Set(schema.required || []);\n\t\tconst properties: string[] = [];\n\n\t\tif (schema.properties) {\n\t\t\tfor (const [propName, propSchema] of Object.entries(schema.properties)) {\n\t\t\t\t// Skip properties based on readOnly/writeOnly\n\t\t\t\tif (!this.shouldIncludeProperty(propSchema)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst isRequired = required.has(propName);\n\t\t\t\tconst zodSchema = this.generatePropertySchema(propSchema, currentSchema);\n\n\t\t\t\t// Quote property name if it contains special characters\n\t\t\t\tconst validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\t\t\t\tconst quotedPropName = validIdentifier.test(propName) ? propName : `\"${propName}\"`;\n\n\t\t\t\tlet propertyDef = `${quotedPropName}: ${zodSchema}`;\n\t\t\t\tif (!isRequired) {\n\t\t\t\t\tpropertyDef += \".optional()\";\n\t\t\t\t}\n\n\t\t\t\tproperties.push(propertyDef);\n\t\t\t}\n\t\t}\n\n\t\t// Return the shape as an object literal\n\t\tif (properties.length === 0) {\n\t\t\treturn \"{}\";\n\t\t}\n\n\t\treturn `{\\n${properties.map(p => `\\t${p}`).join(\",\\n\")}\\n}`;\n\t}\n}\n","import { z } from \"zod\";\n\n/**\n * @shared Zod schema for request/response options validation\n * @since 1.0.0\n * Utility used by core and playwright packages\n */\nexport const RequestResponseOptionsSchema = z.strictObject({\n\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tuseDescribe: z.boolean().optional(),\n\tincludeDescriptions: z.boolean().optional(),\n\tdefaultNullable: z.boolean().optional(),\n\temptyObjectBehavior: z.enum([\"strict\", \"loose\", \"record\"]).optional(),\n});\n\n/**\n * @shared Base Zod schema for operation filters (without status codes)\n * @since 1.0.0\n * Utility used by core and playwright packages\n */\nexport const OperationFiltersSchema = z.strictObject({\n\tincludeTags: z.array(z.string()).optional(),\n\texcludeTags: z.array(z.string()).optional(),\n\tincludePaths: z.array(z.string()).optional(),\n\texcludePaths: z.array(z.string()).optional(),\n\tincludeMethods: z.array(z.string()).optional(),\n\texcludeMethods: z.array(z.string()).optional(),\n\tincludeOperationIds: z.array(z.string()).optional(),\n\texcludeOperationIds: z.array(z.string()).optional(),\n\texcludeDeprecated: z.boolean().optional(),\n});\n\n/**\n * Inferred TypeScript type for request/response options\n */\nexport type RequestResponseOptions = z.infer<typeof RequestResponseOptionsSchema>;\n\n/**\n * Inferred TypeScript type for base operation filters\n */\nexport type BaseOperationFilters = z.infer<typeof OperationFiltersSchema>;\n","import { z } from \"zod\";\n\n/**\n * @shared Format Zod validation errors into user-friendly error messages\n * @since 1.0.0\n * Utility used by core and playwright packages\n *\n * @param error - The Zod validation error\n * @param filepath - Path to the config file that was being validated\n * @param configPath - Optional explicit config path provided by user\n * @param additionalNotes - Optional array of additional notes to append to the error message\n * @returns Formatted error message string\n */\nexport function formatConfigValidationError(\n\terror: z.ZodError,\n\tfilepath: string | undefined,\n\tconfigPath: string | undefined,\n\tadditionalNotes?: string[]\n): string {\n\tconst formattedErrors =\n\t\terror.issues\n\t\t\t?.map(err => {\n\t\t\t\tconst path = err.path.length > 0 ? err.path.join(\".\") : \"root\";\n\t\t\t\treturn ` - ${path}: ${err.message}`;\n\t\t\t})\n\t\t\t.join(\"\\n\") || \"Unknown validation error\";\n\n\tconst configSource = filepath || configPath || \"config file\";\n\tconst lines = [\n\t\t`Invalid configuration file at: ${configSource}`,\n\t\t\"\",\n\t\t\"Validation errors:\",\n\t\tformattedErrors,\n\t\t\"\",\n\t\t\"Please check your configuration file and ensure:\",\n\t\t\" - All required fields are present (specs array with input/output)\",\n\t\t\" - Field names are spelled correctly (no typos)\",\n\t\t\" - Values match the expected types (e.g., mode: 'strict' | 'normal' | 'loose')\",\n\t\t\" - No unknown/extra properties are included\",\n\t];\n\n\tif (additionalNotes && additionalNotes.length > 0) {\n\t\tlines.push(...additionalNotes.map(note => ` - ${note}`));\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n","/**\n * Content type utilities for determining response parsing methods\n */\n\n/**\n * Result of content type analysis\n */\nexport interface ContentTypeParseResult {\n\t/**\n\t * The recommended parsing method\n\t * - \"json\": Use response.json() for JSON content types\n\t * - \"text\": Use response.text() for text-based content types\n\t * - \"body\": Use response.body() for binary content types\n\t */\n\tmethod: \"json\" | \"text\" | \"body\";\n\n\t/**\n\t * Whether the content type was unknown and fallback was used\n\t */\n\tisUnknown: boolean;\n}\n\n/**\n * Fallback parsing method for unknown content types\n */\nexport type FallbackContentTypeParsing = \"json\" | \"text\" | \"body\";\n\n/**\n * Determines the appropriate response parsing method based on content type\n *\n * Categories:\n * - JSON: application/json, text/json, *+json suffix\n * - Text: text/* (except text/json), application/xml, *+xml suffix, application/javascript\n * - Binary: image/*, audio/*, video/*, font/*, application/octet-stream, application/pdf, etc.\n *\n * @param contentType - The content type to analyze (e.g., \"application/json; charset=utf-8\")\n * @param fallback - The method to use for unknown content types (default: \"text\" for safety)\n * @returns The recommended parsing method and whether the content type was unknown\n */\nexport function getResponseParseMethod(\n\tcontentType: string | undefined,\n\tfallback: FallbackContentTypeParsing = \"text\"\n): ContentTypeParseResult {\n\t// Handle missing content type\n\tif (!contentType) {\n\t\treturn { method: fallback, isUnknown: true };\n\t}\n\n\t// Normalize: lowercase, strip charset and parameters\n\tconst normalized = contentType.toLowerCase().split(\";\")[0].trim();\n\n\t// Empty after normalization\n\tif (!normalized) {\n\t\treturn { method: fallback, isUnknown: true };\n\t}\n\n\t// JSON family\n\tif (normalized === \"application/json\" || normalized === \"text/json\" || normalized.endsWith(\"+json\")) {\n\t\treturn { method: \"json\", isUnknown: false };\n\t}\n\n\t// Text family - text/* (except text/json already handled above)\n\tif (normalized.startsWith(\"text/\")) {\n\t\treturn { method: \"text\", isUnknown: false };\n\t}\n\n\t// XML family - both standalone and suffix\n\tif (\n\t\tnormalized === \"application/xml\" ||\n\t\tnormalized.endsWith(\"+xml\") // includes image/svg+xml\n\t) {\n\t\treturn { method: \"text\", isUnknown: false };\n\t}\n\n\t// JavaScript family (text-based)\n\tif (\n\t\tnormalized === \"application/javascript\" ||\n\t\tnormalized === \"application/x-javascript\" ||\n\t\tnormalized === \"application/ecmascript\"\n\t) {\n\t\treturn { method: \"text\", isUnknown: false };\n\t}\n\n\t// Binary - images\n\tif (normalized.startsWith(\"image/\")) {\n\t\treturn { method: \"body\", isUnknown: false };\n\t}\n\n\t// Binary - audio\n\tif (normalized.startsWith(\"audio/\")) {\n\t\treturn { method: \"body\", isUnknown: false };\n\t}\n\n\t// Binary - video\n\tif (normalized.startsWith(\"video/\")) {\n\t\treturn { method: \"body\", isUnknown: false };\n\t}\n\n\t// Binary - fonts\n\tif (normalized.startsWith(\"font/\")) {\n\t\treturn { method: \"body\", isUnknown: false };\n\t}\n\n\t// Binary - common application types\n\tif (\n\t\tnormalized === \"application/octet-stream\" ||\n\t\tnormalized === \"application/pdf\" ||\n\t\tnormalized === \"application/zip\" ||\n\t\tnormalized === \"application/gzip\" ||\n\t\tnormalized === \"application/x-tar\" ||\n\t\tnormalized === \"application/x-7z-compressed\" ||\n\t\tnormalized === \"application/x-rar-compressed\" ||\n\t\tnormalized === \"application/wasm\" ||\n\t\tnormalized === \"application/x-protobuf\"\n\t) {\n\t\treturn { method: \"body\", isUnknown: false };\n\t}\n\n\t// Unknown content type - use fallback\n\treturn { method: fallback, isUnknown: true };\n}\n","import { minimatch } from \"minimatch\";\nimport type { OperationFilters } from \"../types\";\n\n/**\n * Filter statistics to track which operations were included/excluded\n */\nexport interface FilterStatistics {\n\ttotalOperations: number;\n\tincludedOperations: number;\n\tfilteredByTags: number;\n\tfilteredByPaths: number;\n\tfilteredByMethods: number;\n\tfilteredByOperationIds: number;\n\tfilteredByDeprecated: number;\n}\n\n/**\n * Create a new filter statistics object with all counters initialized to zero\n */\nexport function createFilterStatistics(): FilterStatistics {\n\treturn {\n\t\ttotalOperations: 0,\n\t\tincludedOperations: 0,\n\t\tfilteredByTags: 0,\n\t\tfilteredByPaths: 0,\n\t\tfilteredByMethods: 0,\n\t\tfilteredByOperationIds: 0,\n\t\tfilteredByDeprecated: 0,\n\t};\n}\n\n/**\n * Check if a value matches any of the patterns (supports glob patterns)\n * Empty patterns array = no constraint (returns true)\n */\nfunction matchesAnyPattern(value: string | undefined, patterns: string[] | undefined): boolean {\n\tif (!patterns || patterns.length === 0) {\n\t\treturn false; // No constraint means \"don't use this filter\"\n\t}\n\tif (!value) {\n\t\treturn false;\n\t}\n\treturn patterns.some(pattern => minimatch(value, pattern));\n}\n\n/**\n * Check if an array contains any of the specified values\n * Empty values array = no constraint (returns false)\n */\nfunction containsAny(arr: string[] | undefined, values: string[] | undefined): boolean {\n\tif (!values || values.length === 0) {\n\t\treturn false; // No constraint means \"don't use this filter\"\n\t}\n\tif (!arr || arr.length === 0) {\n\t\treturn false;\n\t}\n\treturn values.some(value => arr.includes(value));\n}\n\n/**\n * Determine if an operation should be included based on filter criteria\n *\n * Filter logic:\n * 1. If no filters specified, include all operations\n * 2. Empty arrays are treated as \"no constraint\" (not as \"exclude all\")\n * 3. Include filters are applied first (allowlist)\n * 4. Exclude filters are applied second (blocklist)\n * 5. Exclude rules always win over include rules\n *\n * @param operation - The OpenAPI operation object\n * @param path - The operation path (e.g., \"/users/{id}\")\n * @param method - The HTTP method (e.g., \"get\", \"post\")\n * @param filters - Optional filter configuration\n * @param stats - Optional statistics object to track filtering reasons\n * @returns true if the operation should be included, false otherwise\n */\nexport function shouldIncludeOperation(\n\toperation: any,\n\tpath: string,\n\tmethod: string,\n\tfilters?: OperationFilters,\n\tstats?: FilterStatistics\n): boolean {\n\t// If no filters specified, include all operations\n\tif (!filters) {\n\t\treturn true;\n\t}\n\n\tconst methodLower = method.toLowerCase();\n\tconst operationId = operation?.operationId;\n\tconst tags = operation?.tags || [];\n\tconst deprecated = operation?.deprecated === true;\n\n\t// Apply include filters first (allowlist)\n\t// If any include filter is specified and the operation doesn't match, exclude it\n\n\t// Check includeTags\n\tif (filters.includeTags && filters.includeTags.length > 0) {\n\t\tif (!containsAny(tags, filters.includeTags)) {\n\t\t\tif (stats) stats.filteredByTags++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Check includePaths\n\tif (filters.includePaths && filters.includePaths.length > 0) {\n\t\tif (!matchesAnyPattern(path, filters.includePaths)) {\n\t\t\tif (stats) stats.filteredByPaths++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Check includeMethods\n\tif (filters.includeMethods && filters.includeMethods.length > 0) {\n\t\tconst methodsLower = filters.includeMethods.map(m => m.toLowerCase());\n\t\tif (!methodsLower.includes(methodLower)) {\n\t\t\tif (stats) stats.filteredByMethods++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Check includeOperationIds\n\tif (filters.includeOperationIds && filters.includeOperationIds.length > 0) {\n\t\tif (!matchesAnyPattern(operationId, filters.includeOperationIds)) {\n\t\t\tif (stats) stats.filteredByOperationIds++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Apply exclude filters second (blocklist)\n\t// If the operation matches any exclude filter, exclude it\n\n\t// Check excludeDeprecated\n\tif (filters.excludeDeprecated === true && deprecated) {\n\t\tif (stats) stats.filteredByDeprecated++;\n\t\treturn false;\n\t}\n\n\t// Check excludeTags\n\tif (filters.excludeTags && filters.excludeTags.length > 0) {\n\t\tif (containsAny(tags, filters.excludeTags)) {\n\t\t\tif (stats) stats.filteredByTags++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Check excludePaths\n\tif (filters.excludePaths && filters.excludePaths.length > 0) {\n\t\tif (matchesAnyPattern(path, filters.excludePaths)) {\n\t\t\tif (stats) stats.filteredByPaths++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Check excludeMethods\n\tif (filters.excludeMethods && filters.excludeMethods.length > 0) {\n\t\tconst methodsLower = filters.excludeMethods.map(m => m.toLowerCase());\n\t\tif (methodsLower.includes(methodLower)) {\n\t\t\tif (stats) stats.filteredByMethods++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Check excludeOperationIds\n\tif (filters.excludeOperationIds && filters.excludeOperationIds.length > 0) {\n\t\tif (matchesAnyPattern(operationId, filters.excludeOperationIds)) {\n\t\t\tif (stats) stats.filteredByOperationIds++;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Operation passed all filters\n\treturn true;\n}\n\n/**\n * Validate filter statistics and emit warnings for filters that matched nothing\n * Helps users debug filter configurations that might be too restrictive or contain typos\n *\n * @param stats - Filter statistics object\n * @param filters - The filter configuration to validate\n */\nexport function validateFilters(stats: FilterStatistics, filters?: OperationFilters): void {\n\tif (!filters || stats.totalOperations === 0) {\n\t\treturn;\n\t}\n\n\t// If all operations were filtered out, emit a warning\n\tif (stats.includedOperations === 0) {\n\t\tconsole.warn(\n\t\t\t`⚠️ Warning: All ${stats.totalOperations} operations were filtered out. Check your operationFilters configuration.`\n\t\t);\n\n\t\t// Provide specific guidance about which filters might be the issue\n\t\tconst filterBreakdown: string[] = [];\n\t\tif (stats.filteredByTags > 0) filterBreakdown.push(`${stats.filteredByTags} by tags`);\n\t\tif (stats.filteredByPaths > 0) filterBreakdown.push(`${stats.filteredByPaths} by paths`);\n\t\tif (stats.filteredByMethods > 0) filterBreakdown.push(`${stats.filteredByMethods} by methods`);\n\t\tif (stats.filteredByOperationIds > 0) filterBreakdown.push(`${stats.filteredByOperationIds} by operationIds`);\n\t\tif (stats.filteredByDeprecated > 0) filterBreakdown.push(`${stats.filteredByDeprecated} by deprecated flag`);\n\n\t\tif (filterBreakdown.length > 0) {\n\t\t\tconsole.warn(` Filtered: ${filterBreakdown.join(\", \")}`);\n\t\t}\n\t}\n}\n\n/**\n * Format filter statistics for display in generated output\n * Returns a formatted string suitable for inclusion in comments\n *\n * @param stats - Filter statistics object\n * @returns Formatted statistics string\n */\nexport function formatFilterStatistics(stats: FilterStatistics): string {\n\tif (stats.totalOperations === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines: string[] = [];\n\tlines.push(\"Operation Filtering:\");\n\tlines.push(` Total operations: ${stats.totalOperations}`);\n\tlines.push(` Included operations: ${stats.includedOperations}`);\n\n\tconst filteredCount =\n\t\tstats.filteredByTags +\n\t\tstats.filteredByPaths +\n\t\tstats.filteredByMethods +\n\t\tstats.filteredByOperationIds +\n\t\tstats.filteredByDeprecated;\n\n\tif (filteredCount > 0) {\n\t\tlines.push(` Filtered operations: ${filteredCount}`);\n\t\tif (stats.filteredByTags > 0) lines.push(` - By tags: ${stats.filteredByTags}`);\n\t\tif (stats.filteredByPaths > 0) lines.push(` - By paths: ${stats.filteredByPaths}`);\n\t\tif (stats.filteredByMethods > 0) lines.push(` - By methods: ${stats.filteredByMethods}`);\n\t\tif (stats.filteredByOperationIds > 0) lines.push(` - By operationIds: ${stats.filteredByOperationIds}`);\n\t\tif (stats.filteredByDeprecated > 0) lines.push(` - By deprecated: ${stats.filteredByDeprecated}`);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n","/**\n * OpenAPI $ref resolution utilities\n *\n * Provides functions to resolve $ref references to component definitions\n * Supports: parameters, requestBodies, responses, schemas\n *\n * @internal Used by core and playwright packages\n */\n\nimport type { OpenAPIParameter, OpenAPIRequestBody, OpenAPIResponse, OpenAPISchema, OpenAPISpec } from \"../types\";\n\n/**\n * Type for any resolvable component\n */\ntype ResolvableComponent = OpenAPIParameter | OpenAPIRequestBody | OpenAPIResponse | OpenAPISchema | any;\n\n/**\n * Resolve a $ref to a component definition\n * Handles nested $refs by recursively resolving until no more refs found\n *\n * @param obj - Object that may contain a $ref\n * @param spec - The OpenAPI specification\n * @param maxDepth - Maximum recursion depth to prevent infinite loops (default: 10)\n * @returns The resolved component, or the original object if not a reference\n */\nexport function resolveRef<T extends ResolvableComponent>(obj: T | any, spec: OpenAPISpec, maxDepth = 10): T {\n\tif (!obj || typeof obj !== \"object\" || maxDepth <= 0) return obj;\n\tif (!obj.$ref) return obj;\n\n\tconst ref = obj.$ref as string;\n\tlet resolved: any = null;\n\n\t// Match different component types\n\tconst paramMatch = ref.match(/^#\\/components\\/parameters\\/(.+)$/);\n\tconst requestBodyMatch = ref.match(/^#\\/components\\/requestBodies\\/(.+)$/);\n\tconst responseMatch = ref.match(/^#\\/components\\/responses\\/(.+)$/);\n\tconst schemaMatch = ref.match(/^#\\/components\\/schemas\\/(.+)$/);\n\n\tif (paramMatch && spec.components?.parameters) {\n\t\tconst name = paramMatch[1];\n\t\tresolved = spec.components.parameters[name];\n\t} else if (requestBodyMatch && spec.components?.requestBodies) {\n\t\tconst name = requestBodyMatch[1];\n\t\tresolved = spec.components.requestBodies[name];\n\t} else if (responseMatch && spec.components?.responses) {\n\t\tconst name = responseMatch[1];\n\t\tresolved = spec.components.responses[name];\n\t} else if (schemaMatch && spec.components?.schemas) {\n\t\tconst name = schemaMatch[1];\n\t\tresolved = spec.components.schemas[name];\n\t}\n\n\tif (resolved) {\n\t\t// Recursively resolve nested $refs\n\t\tif (resolved.$ref) {\n\t\t\treturn resolveRef(resolved, spec, maxDepth - 1);\n\t\t}\n\t\treturn resolved;\n\t}\n\n\t// Return original if can't resolve\n\treturn obj;\n}\n\n/**\n * Resolve a parameter reference\n * Convenience wrapper for resolveRef with parameter type\n */\nexport function resolveParameterRef(param: any, spec: OpenAPISpec): OpenAPIParameter | any {\n\treturn resolveRef<OpenAPIParameter>(param, spec);\n}\n\n/**\n * Resolve a request body reference\n * Convenience wrapper for resolveRef with request body type\n */\nexport function resolveRequestBodyRef(requestBody: any, spec: OpenAPISpec): OpenAPIRequestBody | any {\n\treturn resolveRef<OpenAPIRequestBody>(requestBody, spec);\n}\n\n/**\n * Resolve a response reference\n * Convenience wrapper for resolveRef with response type\n */\nexport function resolveResponseRef(response: any, spec: OpenAPISpec): OpenAPIResponse | any {\n\treturn resolveRef<OpenAPIResponse>(response, spec);\n}\n\n/**\n * Merge path-level parameters with operation-level parameters\n * Operation parameters override path-level parameters with the same name and location\n *\n * @param pathParams - Parameters defined at the path level\n * @param operationParams - Parameters defined at the operation level\n * @param spec - The OpenAPI specification for resolving $refs\n * @returns Merged array of resolved parameters\n */\nexport function mergeParameters(\n\tpathParams: any[] | undefined,\n\toperationParams: any[] | undefined,\n\tspec: OpenAPISpec\n): any[] {\n\tconst resolvedPathParams = (pathParams || []).map(p => resolveParameterRef(p, spec));\n\tconst resolvedOperationParams = (operationParams || []).map(p => resolveParameterRef(p, spec));\n\n\t// Start with path-level params\n\tconst merged = [...resolvedPathParams];\n\n\t// Operation params override path params by name + in\n\tfor (const opParam of resolvedOperationParams) {\n\t\tif (!opParam || typeof opParam !== \"object\") continue;\n\n\t\tconst existingIndex = merged.findIndex(\n\t\t\tp => p && typeof p === \"object\" && p.name === opParam.name && p.in === opParam.in\n\t\t);\n\n\t\tif (existingIndex >= 0) {\n\t\t\t// Override existing param\n\t\t\tmerged[existingIndex] = opParam;\n\t\t} else {\n\t\t\t// Add new param\n\t\t\tmerged.push(opParam);\n\t\t}\n\t}\n\n\treturn merged;\n}\n","import type { Loader } from \"cosmiconfig\";\n\n/**\n * @shared Create a TypeScript loader for cosmiconfig using esbuild\n * @since 1.0.0\n * Utility used by core and playwright packages\n *\n * Creates a loader that transpiles TypeScript config files to JavaScript\n * using esbuild, then executes them to load the configuration.\n *\n * @returns A cosmiconfig Loader function\n */\nexport function createTypeScriptLoader(): Loader {\n\treturn async (filepath: string) => {\n\t\ttry {\n\t\t\t// Use esbuild to transpile TypeScript to JavaScript\n\t\t\tconst esbuild = await import(\"esbuild\");\n\t\t\tconst fs = await import(\"node:fs\");\n\t\t\tconst path = await import(\"node:path\");\n\n\t\t\tconst tsCode = fs.readFileSync(filepath, \"utf-8\");\n\t\t\tconst result = await esbuild.build({\n\t\t\t\tstdin: {\n\t\t\t\t\tcontents: tsCode,\n\t\t\t\t\tloader: \"ts\",\n\t\t\t\t\tresolveDir: path.dirname(filepath),\n\t\t\t\t\tsourcefile: filepath,\n\t\t\t\t},\n\t\t\t\tformat: \"cjs\",\n\t\t\t\tplatform: \"node\",\n\t\t\t\ttarget: \"node18\",\n\t\t\t\tbundle: false,\n\t\t\t\twrite: false,\n\t\t\t});\n\n\t\t\tconst jsCode = result.outputFiles[0].text;\n\n\t\t\t// Create a module and execute it\n\t\t\tconst module = { exports: {} } as any;\n\t\t\tconst func = new Function(\"exports\", \"module\", \"require\", \"__filename\", \"__dirname\", jsCode);\n\t\t\tfunc(module.exports, module, require, filepath, path.dirname(filepath));\n\n\t\t\treturn module.exports.default || module.exports;\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to load TypeScript config from ${filepath}: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t);\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACzC,YACC,SACgB,MACA,SACf;AAZH;AAaE,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AACZ,gBAAM,sBAAN,+BAA0B,MAAM,KAAK;AAAA,EACtC;AACD;AAiFO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACtD,YAAY,SAAiB,SAAmC;AAC/D,UAAM,SAAS,uBAAuB,OAAO;AAC7C,SAAK,OAAO;AAAA,EACb;AACD;;;ACrEA,eAAe,YACd,MACA,OACA,OACA,iBACyB;AAEzB,QAAM,YAAa,KAAa,SAAS;AACzC,QAAM,aAAc,KAAa,UAAU;AAC3C,UAAQ,IAAI,eAAe,QAAQ,CAAC,IAAI,KAAK,KAAK,SAAS,KAAK;AAEhE,MAAI;AACH,UAAM,YAAY,gBAAgB,IAAI;AACtC,cAAU,SAAS;AAEnB,WAAO;AAAA,MACN;AAAA,MACA,SAAS;AAAA,IACV;AAAA,EACD,SAAS,OAAO;AACf,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC1E,YAAQ,MAAM,6BAAwB,UAAU,KAAK,YAAY,EAAE;AAEnE,WAAO;AAAA,MACN;AAAA,MACA,SAAS;AAAA,MACT,OAAO;AAAA,IACR;AAAA,EACD;AACD;AAOA,eAAe,gBACd,OACA,iBACA,WAC2B;AAC3B,UAAQ,IAAI;AAAA,YAAe,MAAM,MAAM,8CAA8C,SAAS;AAAA,C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AAA,MACR,CAAC;AAED,YAAM,SAAS,OAAO,YAAY,CAAC,EAAE;AAGrC,YAAMC,UAAS,EAAE,SAAS,CAAC,EAAE;AAC7B,YAAM,OAAO,IAAI,SAAS,WAAW,UAAU,WAAW,cAAc,aAAa,MAAM;AAC3F,WAAKA,QAAO,SAASA,SAAQ,SAAS,UAAU,KAAK,QAAQ,QAAQ,CAAC;AAEtE,aAAOA,QAAO,QAAQ,WAAWA,QAAO;AAAA,IACzC,SAAS,OAAO;AACf,YAAM,IAAI;AAAA,QACT,yCAAyC,QAAQ,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MAC7G;AAAA,IACD;AAAA,EACD;AACD;","names":["resolveRef","isNullable","isNullable","schemaStrings","union","elseValidation","elseRequiredProps","generatePropertyAccess","definedProps","import_minimatch","resolveRef","module"]}