@cerios/openapi-to-zod 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/errors.ts","../src/generator.ts","../src/utils/name-utils.ts","../src/generators/enum-generator.ts","../src/utils/string-utils.ts","../src/generators/jsdoc-generator.ts","../src/utils/lru-cache.ts","../src/validators/array-validator.ts","../src/validators/composition-validator.ts","../src/validators/number-validator.ts","../src/validators/conditional-validator.ts","../src/validators/object-validator.ts","../src/validators/string-validator.ts","../src/generators/property-generator.ts","../src/batch-executor.ts","../src/types.ts","../src/utils/config-loader.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport { z } from \"zod\";\nimport { executeBatch, getBatchExitCode } from \"./batch-executor\";\nimport { CliOptionsError } from \"./errors\";\nimport { ZodSchemaGenerator } from \"./generator\";\nimport type { ExecutionMode, GeneratorOptions } from \"./types\";\nimport { FilePath } from \"./types\";\nimport { loadConfig, mergeCliWithConfig, mergeConfigWithDefaults } from \"./utils/config-loader\";\n\n/**\n * Zod schema for CLI options validation\n */\nconst CliOptionsSchema = z.object({\n\tconfig: z.string().optional(),\n\tinput: z.string().optional(),\n\toutput: z.string().optional(),\n\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tdescriptions: z.boolean().optional(),\n\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tuseDescribe: z.boolean().optional(),\n\tschemaType: z.enum([\"all\", \"request\", \"response\"]).optional(),\n\tprefix: z.string().optional(),\n\tsuffix: z.string().optional(),\n\tstats: z.boolean().optional(),\n\tnativeEnumType: z.enum([\"union\", \"enum\"]).optional(),\n\trequestMode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\trequestTypeMode: z.enum([\"inferred\", \"native\"]).optional(),\n\trequestEnumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\trequestNativeEnumType: z.enum([\"union\", \"enum\"]).optional(),\n\trequestUseDescribe: z.boolean().optional(),\n\trequestDescriptions: z.boolean().optional(),\n\tresponseMode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tresponseEnumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tresponseNativeEnumType: z.enum([\"union\", \"enum\"]).optional(),\n\tresponseUseDescribe: z.boolean().optional(),\n\tresponseDescriptions: z.boolean().optional(),\n\texecutionMode: z.enum([\"parallel\", \"sequential\"]).optional(),\n});\n\n/**\n * Validate CLI options using Zod schema\n */\nfunction validateCliOptions(options: unknown): asserts options is z.infer<typeof CliOptionsSchema> {\n\ttry {\n\t\tCliOptionsSchema.parse(options);\n\t} catch (error) {\n\t\tif (error instanceof z.ZodError) {\n\t\t\tconst formattedErrors = error.issues.map(err => ` --${err.path.join(\".\")}: ${err.message}`).join(\"\\n\");\n\t\t\tthrow new CliOptionsError(`Invalid CLI options:\\n${formattedErrors}`, { zodError: error });\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nconst program = new Command();\n\nprogram\n\t.name(\"openapi-to-zod\")\n\t.description(\"Generate Zod v4 schemas from OpenAPI specifications\")\n\t.version(\"1.0.0\")\n\t.option(\"-c, --config <path>\", \"Path to config file (openapi-to-zod.config.{ts,json})\")\n\t.option(\"-i, --input <path>\", \"Input OpenAPI YAML file path (single-spec mode)\")\n\t.option(\"-o, --output <path>\", \"Output TypeScript file path (single-spec mode)\")\n\t.option(\"-m, --mode <mode>\", \"Validation mode: strict, normal, or loose\", \"normal\")\n\t.option(\"--no-descriptions\", \"Exclude JSDoc descriptions from generated schemas\")\n\t.option(\"-e, --enum-type <type>\", \"Enum type: zod or typescript\", \"zod\")\n\t.option(\"--use-describe\", \"Add .describe() calls for better runtime error messages\")\n\t.option(\"-s, --schema-type <type>\", \"Schema type: all, request, or response\", \"all\")\n\t.option(\"-p, --prefix <prefix>\", \"Add prefix to all generated schema names\")\n\t.option(\"--suffix <suffix>\", \"Add suffix before 'Schema' in generated names\")\n\t.option(\"--no-stats\", \"Exclude generation statistics from output file\")\n\t.option(\"--native-enum-type <type>\", \"Native enum type: union or enum\", \"union\")\n\t.option(\"--request-mode <mode>\", \"Request validation mode: strict, normal, or loose\")\n\t.option(\"--request-type-mode <mode>\", \"Request type generation: inferred or native\")\n\t.option(\"--request-enum-type <type>\", \"Request enum type: zod or typescript\")\n\t.option(\"--request-native-enum-type <type>\", \"Request native enum type: union or enum\")\n\t.option(\"--request-use-describe\", \"Add .describe() calls for request schemas\")\n\t.option(\"--request-descriptions\", \"Include descriptions for request schemas\")\n\t.option(\"--no-request-descriptions\", \"Exclude descriptions for request schemas\")\n\t.option(\"--response-mode <mode>\", \"Response validation mode: strict, normal, or loose\")\n\t.option(\"--response-enum-type <type>\", \"Response enum type: zod or typescript\")\n\t.option(\"--response-native-enum-type <type>\", \"Response native enum type: union or enum\")\n\t.option(\"--response-use-describe\", \"Add .describe() calls for response schemas\")\n\t.option(\"--response-descriptions\", \"Include descriptions for response schemas\")\n\t.option(\"--no-response-descriptions\", \"Exclude descriptions for response schemas\")\n\t.option(\"--execution-mode <mode>\", \"Batch execution mode: parallel (default) or sequential\")\n\t.addHelpText(\n\t\t\"after\",\n\t\t`\nExamples:\n # Generate Zod schemas (default - always generates response schemas)\n $ openapi-to-zod -i openapi.yaml -o schemas.ts\n\n # Generate native TypeScript types for requests, Zod schemas for responses\n $ openapi-to-zod -i openapi.yaml -o types.ts --request-type-mode native\n\n # Generate with config file\n $ openapi-to-zod -c openapi-to-zod.config.ts\n`\n\t)\n\t.action(async options => {\n\t\ttry {\n\t\t\t// Validate CLI options\n\t\t\tvalidateCliOptions(options);\n\n\t\t\t// Check if config file mode or single-spec mode\n\t\t\tif (options.config || (!options.input && !options.output)) {\n\t\t\t\t// Config file mode (batch processing)\n\t\t\t\tawait executeBatchMode(options);\n\t\t\t} else {\n\t\t\t\t// Single-spec mode (original behavior)\n\t\t\t\tawait executeSingleSpecMode(options);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof CliOptionsError) {\n\t\t\t\tconsole.error(error.message);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tconsole.error(\"Error:\", error instanceof Error ? error.message : String(error));\n\t\t\tif (error instanceof Error && error.stack) {\n\t\t\t\tconsole.error(\"\\nStack trace:\", error.stack);\n\t\t\t}\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n\nprogram.parse();\n\n/**\n * Execute single-spec mode (original CLI behavior)\n */\nasync function executeSingleSpecMode(options: z.infer<typeof CliOptionsSchema>): Promise<void> {\n\tif (!options.input || !options.output) {\n\t\tthrow new CliOptionsError(\"Both --input and --output are required in single-spec mode\", {\n\t\t\tinput: options.input,\n\t\t\toutput: options.output,\n\t\t});\n\t}\n\n\tconst generatorOptions: GeneratorOptions = {\n\t\tinput: FilePath.from(options.input),\n\t\toutput: FilePath.from(options.output),\n\t\tmode: options.mode,\n\t\tincludeDescriptions: options.descriptions,\n\t\tenumType: options.enumType,\n\t\tuseDescribe: options.useDescribe || false,\n\t\tschemaType: options.schemaType || \"all\",\n\t\tprefix: options.prefix,\n\t\tsuffix: options.suffix,\n\t\tshowStats: options.stats ?? true,\n\t\tnativeEnumType: options.nativeEnumType,\n\t};\n\n\t// Build request options if any request-specific flags are set\n\tif (\n\t\toptions.requestMode ||\n\t\toptions.requestTypeMode ||\n\t\toptions.requestEnumType ||\n\t\toptions.requestNativeEnumType ||\n\t\toptions.requestUseDescribe ||\n\t\toptions.requestDescriptions !== undefined\n\t) {\n\t\tgeneratorOptions.request = {\n\t\t\tmode: options.requestMode,\n\t\t\ttypeMode: options.requestTypeMode,\n\t\t\tenumType: options.requestEnumType,\n\t\t\tnativeEnumType: options.requestNativeEnumType,\n\t\t\tuseDescribe: options.requestUseDescribe || undefined,\n\t\t\tincludeDescriptions: options.requestDescriptions,\n\t\t};\n\t}\n\n\t// Build response options if any response-specific flags are set\n\tif (\n\t\toptions.responseMode ||\n\t\toptions.responseEnumType ||\n\t\toptions.responseNativeEnumType ||\n\t\toptions.responseUseDescribe ||\n\t\toptions.responseDescriptions !== undefined\n\t) {\n\t\tgeneratorOptions.response = {\n\t\t\tmode: options.responseMode,\n\t\t\tenumType: options.responseEnumType,\n\t\t\tnativeEnumType: options.responseNativeEnumType,\n\t\t\tuseDescribe: options.responseUseDescribe || undefined,\n\t\t\tincludeDescriptions: options.responseDescriptions,\n\t\t};\n\t}\n\n\tconst generator = new ZodSchemaGenerator(generatorOptions);\n\tgenerator.generate();\n\tconsole.log(`✓ Successfully generated schemas at ${options.output}`);\n}\n\n/**\n * Execute batch mode from config file\n */\nasync function executeBatchMode(options: z.infer<typeof CliOptionsSchema>): Promise<void> {\n\t// Load config file\n\tconst config = await loadConfig(options.config);\n\n\t// Merge defaults with specs\n\tlet specs = mergeConfigWithDefaults(config);\n\n\t// Extract CLI options that can override config\n\tconst cliOverrides: Partial<GeneratorOptions> = {};\n\tif (options.mode && options.mode !== \"normal\") cliOverrides.mode = options.mode;\n\tif (options.descriptions !== undefined) cliOverrides.includeDescriptions = options.descriptions;\n\tif (options.enumType && options.enumType !== \"zod\") cliOverrides.enumType = options.enumType;\n\tif (options.useDescribe) cliOverrides.useDescribe = true;\n\tif (options.schemaType && options.schemaType !== \"all\") cliOverrides.schemaType = options.schemaType;\n\tif (options.prefix) cliOverrides.prefix = options.prefix;\n\tif (options.suffix) cliOverrides.suffix = options.suffix;\n\tif (options.stats !== undefined) cliOverrides.showStats = options.stats;\n\tif (options.nativeEnumType) cliOverrides.nativeEnumType = options.nativeEnumType;\n\n\t// Build request/response overrides from CLI\n\tif (\n\t\toptions.requestMode ||\n\t\toptions.requestTypeMode ||\n\t\toptions.requestEnumType ||\n\t\toptions.requestNativeEnumType ||\n\t\toptions.requestUseDescribe ||\n\t\toptions.requestDescriptions !== undefined\n\t) {\n\t\tcliOverrides.request = {\n\t\t\tmode: options.requestMode,\n\t\t\ttypeMode: options.requestTypeMode,\n\t\t\tenumType: options.requestEnumType,\n\t\t\tnativeEnumType: options.requestNativeEnumType,\n\t\t\tuseDescribe: options.requestUseDescribe,\n\t\t\tincludeDescriptions: options.requestDescriptions,\n\t\t};\n\t}\n\n\tif (\n\t\toptions.responseMode ||\n\t\toptions.responseEnumType ||\n\t\toptions.responseNativeEnumType ||\n\t\toptions.responseUseDescribe ||\n\t\toptions.responseDescriptions !== undefined\n\t) {\n\t\tcliOverrides.response = {\n\t\t\tmode: options.responseMode,\n\t\t\tenumType: options.responseEnumType,\n\t\t\tnativeEnumType: options.responseNativeEnumType,\n\t\t\tuseDescribe: options.responseUseDescribe,\n\t\t\tincludeDescriptions: options.responseDescriptions,\n\t\t};\n\t}\n\n\t// Apply CLI overrides to all specs if any CLI options were provided\n\tif (Object.keys(cliOverrides).length > 0) {\n\t\tspecs = specs.map(spec => mergeCliWithConfig(spec, cliOverrides));\n\t}\n\n\t// Determine execution mode\n\tconst executionMode: ExecutionMode = (options.executionMode as ExecutionMode) || config.executionMode || \"parallel\";\n\n\t// Execute batch\n\tconst summary = await executeBatch(specs, executionMode);\n\n\t// Exit with appropriate code\n\tconst exitCode = getBatchExitCode(summary);\n\tif (exitCode !== 0) {\n\t\tprocess.exit(exitCode);\n\t}\n}\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 { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { parse } from \"yaml\";\nimport { ConfigurationError, FileOperationError, SchemaGenerationError, SpecValidationError } from \"./errors\";\nimport { generateEnum } from \"./generators/enum-generator\";\nimport { generateJSDoc } from \"./generators/jsdoc-generator\";\nimport { PropertyGenerator } from \"./generators/property-generator\";\nimport type { GeneratorOptions, OpenAPISchema, OpenAPISpec, ResolvedOptions, TypeMode } from \"./types\";\nimport { resolveRef, toCamelCase } from \"./utils/name-utils\";\n\ntype SchemaContext = \"request\" | \"response\" | \"both\";\n\nexport class ZodSchemaGenerator {\n\tprivate schemas: Map<string, string> = new Map();\n\tprivate types: Map<string, string> = new Map();\n\tprivate enums: Map<string, string> = new Map();\n\tprivate nativeEnums: Map<string, string> = new Map();\n\tprivate schemaDependencies: Map<string, Set<string>> = new Map();\n\tprivate options: GeneratorOptions;\n\tprivate spec: OpenAPISpec;\n\tprivate propertyGenerator: PropertyGenerator;\n\tprivate schemaUsageMap: Map<string, SchemaContext> = new Map();\n\tprivate schemaTypeModeMap: Map<string, TypeMode> = new Map();\n\tprivate requestOptions: ResolvedOptions;\n\tprivate responseOptions: ResolvedOptions;\n\tprivate needsZodImport = false;\n\n\tconstructor(options: GeneratorOptions) {\n\t\t// Validate input path early\n\t\tif (!options.input) {\n\t\t\tthrow new ConfigurationError(\"Input path is required\", { providedOptions: options });\n\t\t}\n\n\t\tthis.options = {\n\t\t\tmode: options.mode || \"normal\",\n\t\t\tinput: options.input,\n\t\t\toutput: options.output,\n\t\t\tincludeDescriptions: options.includeDescriptions ?? true,\n\t\t\tenumType: options.enumType || \"zod\",\n\t\t\tuseDescribe: options.useDescribe ?? false,\n\t\t\tschemaType: options.schemaType || \"all\",\n\t\t\tprefix: options.prefix,\n\t\t\tsuffix: options.suffix,\n\t\t\tshowStats: options.showStats ?? true,\n\t\t\tnativeEnumType: options.nativeEnumType || \"union\",\n\t\t\trequest: options.request,\n\t\t\tresponse: options.response,\n\t\t};\n\n\t\t// Validate input file exists\n\t\ttry {\n\t\t\tconst fs = require(\"node:fs\");\n\t\t\tif (!fs.existsSync(this.options.input)) {\n\t\t\t\tthrow new FileOperationError(`Input file not found: ${this.options.input}`, this.options.input);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FileOperationError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// If fs.existsSync fails for another reason, continue and let readFileSync throw\n\t\t}\n\n\t\ttry {\n\t\t\tconst yamlContent = readFileSync(this.options.input, \"utf-8\");\n\t\t\tthis.spec = parse(yamlContent);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tconst errorMessage = [\n\t\t\t\t\t`Failed to parse OpenAPI specification from: ${this.options.input}`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t`Error: ${error.message}`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Please ensure:\",\n\t\t\t\t\t\" - The file exists and is readable\",\n\t\t\t\t\t\" - The file contains valid YAML syntax\",\n\t\t\t\t\t\" - The file is a valid OpenAPI 3.x specification\",\n\t\t\t\t].join(\"\\n\");\n\t\t\t\tthrow new SpecValidationError(errorMessage, { filePath: this.options.input, originalError: error.message });\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tthis.validateSpec();\n\n\t\t// Resolve options for request and response contexts\n\t\tthis.requestOptions = this.resolveOptionsForContext(\"request\");\n\t\tthis.responseOptions = this.resolveOptionsForContext(\"response\");\n\n\t\t// Analyze schema usage to determine context (request/response/both)\n\t\tthis.analyzeSchemaUsage();\n\n\t\t// Determine typeMode for each schema based on usage context\n\t\tthis.determineSchemaTypeModes();\n\n\t\t// Initialize property generator with context\n\t\t// We'll update this dynamically based on schema context during generation\n\t\tthis.propertyGenerator = new PropertyGenerator({\n\t\t\tspec: this.spec,\n\t\t\tschemaDependencies: this.schemaDependencies,\n\t\t\tschemaType: this.options.schemaType || \"all\",\n\t\t\tmode: this.requestOptions.mode,\n\t\t\tincludeDescriptions: this.requestOptions.includeDescriptions,\n\t\t\tuseDescribe: this.requestOptions.useDescribe,\n\t\t\ttypeMode: this.requestOptions.typeMode,\n\t\t\tnativeEnumType: this.requestOptions.nativeEnumType,\n\t\t\tnamingOptions: {\n\t\t\t\tprefix: this.options.prefix,\n\t\t\t\tsuffix: this.options.suffix,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Generate schemas as a string (without writing to file)\n\t * @returns The generated TypeScript code as a string\n\t */\n\tgenerateString(): string {\n\t\tif (!this.spec.components?.schemas) {\n\t\t\tthrow new SpecValidationError(\"No schemas found in OpenAPI spec\", { filePath: this.options.input });\n\t\t}\n\n\t\t// First pass: generate enums\n\t\tfor (const [name, schema] of Object.entries(this.spec.components.schemas)) {\n\t\t\tif (schema.enum) {\n\t\t\t\tconst typeMode = this.schemaTypeModeMap.get(name) || \"inferred\";\n\t\t\t\tif (typeMode === \"inferred\") {\n\t\t\t\t\tconst { enumCode } = generateEnum(name, schema.enum, {\n\t\t\t\t\t\tenumType: this.options.enumType || \"zod\",\n\t\t\t\t\t\tprefix: this.options.prefix,\n\t\t\t\t\t\tsuffix: this.options.suffix,\n\t\t\t\t\t});\n\t\t\t\t\tif (enumCode) {\n\t\t\t\t\t\tthis.enums.set(name, enumCode);\n\t\t\t\t\t\t// Mark that we need Zod import for enum schemas\n\t\t\t\t\t\tthis.needsZodImport = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Generate native enum\n\t\t\t\t\tthis.generateNativeEnum(name, schema);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Second pass: generate schemas/types and track dependencies\n\t\tfor (const [name, schema] of Object.entries(this.spec.components.schemas)) {\n\t\t\tthis.generateComponentSchema(name, schema);\n\t\t}\n\n\t\t// Sort schemas by dependencies\n\t\tconst orderedSchemaNames = this.topologicalSort();\n\n\t\t// Build output\n\t\tconst output: string[] = [\"// Auto-generated by @cerios/openapi-to-zod\", \"// Do not edit this file manually\", \"\"];\n\n\t\t// Add statistics if enabled (must be explicitly true)\n\t\tif (this.options.showStats === true) {\n\t\t\toutput.push(...this.generateStats());\n\t\t\toutput.push(\"\");\n\t\t}\n\n\t\t// Conditionally import Zod only if needed\n\t\tif (this.needsZodImport) {\n\t\t\toutput.push('import { z } from \"zod\";');\n\t\t\toutput.push(\"\");\n\t\t}\n\n\t\t// Add enums\n\t\tif (this.enums.size > 0 || this.nativeEnums.size > 0) {\n\t\t\toutput.push(\"// Enums\");\n\n\t\t\t// Zod enums first\n\t\t\tfor (const enumCode of this.enums.values()) {\n\t\t\t\toutput.push(enumCode);\n\t\t\t\toutput.push(\"\");\n\t\t\t}\n\n\t\t\t// Native TypeScript enums\n\t\t\tfor (const enumCode of this.nativeEnums.values()) {\n\t\t\t\toutput.push(enumCode);\n\t\t\t\toutput.push(\"\");\n\t\t\t}\n\t\t}\n\n\t\t// Add schemas and types in dependency order (grouped by schema)\n\t\toutput.push(\"// Schemas and Types\");\n\t\tfor (const name of orderedSchemaNames) {\n\t\t\tconst schemaCode = this.schemas.get(name);\n\t\t\tconst typeCode = this.types.get(name);\n\n\t\t\tif (schemaCode) {\n\t\t\t\t// Zod schema with inferred type\n\t\t\t\toutput.push(schemaCode);\n\n\t\t\t\t// Add type immediately after schema (if not already included)\n\t\t\t\tif (!schemaCode.includes(`export type ${name}`)) {\n\t\t\t\t\tconst schemaName = `${toCamelCase(name, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;\n\t\t\t\t\toutput.push(`export type ${name} = z.infer<typeof ${schemaName}>;`);\n\t\t\t\t}\n\n\t\t\t\toutput.push(\"\");\n\t\t\t} else if (typeCode) {\n\t\t\t\t// Native TypeScript type\n\t\t\t\toutput.push(typeCode);\n\t\t\t\toutput.push(\"\");\n\t\t\t}\n\t\t}\n\n\t\treturn output.join(\"\\n\");\n\t}\n\n\t/**\n\t * Ensure directory exists for a file path\n\t */\n\tprivate ensureDirectoryExists(filePath: string): void {\n\t\tconst dir = dirname(filePath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true });\n\t\t}\n\t}\n\n\t/**\n\t * Generate the complete output file\n\t */\n\tgenerate(): void {\n\t\tif (!this.options.output) {\n\t\t\tthrow new ConfigurationError(\n\t\t\t\t\"Output path is required when calling generate(). \" +\n\t\t\t\t\t\"Either provide an 'output' option or use generateString() to get the result as a string.\",\n\t\t\t\t{ hasOutput: false }\n\t\t\t);\n\t\t}\n\t\tconst output = this.generateString();\n\t\tthis.ensureDirectoryExists(this.options.output);\n\t\twriteFileSync(this.options.output, output);\n\t}\n\n\t/**\n\t * Resolve options for a specific context (request or response)\n\t * Nested options silently override root-level options\n\t * Response schemas always use 'inferred' mode (Zod schemas)\n\t */\n\tprivate resolveOptionsForContext(context: \"request\" | \"response\"): ResolvedOptions {\n\t\tconst contextOptions = context === \"request\" ? this.options.request : this.options.response;\n\n\t\treturn {\n\t\t\tmode: contextOptions?.mode ?? this.options.mode ?? \"normal\",\n\t\t\tenumType: contextOptions?.enumType ?? this.options.enumType ?? \"zod\",\n\t\t\tuseDescribe: contextOptions?.useDescribe ?? this.options.useDescribe ?? false,\n\t\t\tincludeDescriptions: contextOptions?.includeDescriptions ?? this.options.includeDescriptions ?? true,\n\t\t\t// Response schemas always use 'inferred' mode (Zod schemas are required)\n\t\t\t// Request schemas can optionally use 'native' mode\n\t\t\ttypeMode: context === \"response\" ? \"inferred\" : (contextOptions?.typeMode ?? \"inferred\"),\n\t\t\tnativeEnumType: contextOptions?.nativeEnumType ?? this.options.nativeEnumType ?? \"union\",\n\t\t};\n\t}\n\n\t/**\n\t * Analyze schema usage across the OpenAPI spec to determine if schemas\n\t * are used in request, response, or both contexts\n\t */\n\tprivate analyzeSchemaUsage(): void {\n\t\tconst requestSchemas = new Set<string>();\n\t\tconst responseSchemas = new Set<string>();\n\n\t\t// Analyze paths section if available\n\t\tif (this.spec.paths) {\n\t\t\tfor (const [, pathItem] of Object.entries(this.spec.paths)) {\n\t\t\t\tfor (const [, operation] of Object.entries(pathItem)) {\n\t\t\t\t\tif (typeof operation !== \"object\" || !operation) continue;\n\n\t\t\t\t\t// Check request bodies\n\t\t\t\t\tif (\n\t\t\t\t\t\t\"requestBody\" in operation &&\n\t\t\t\t\t\toperation.requestBody &&\n\t\t\t\t\t\ttypeof operation.requestBody === \"object\" &&\n\t\t\t\t\t\t\"content\" in operation.requestBody &&\n\t\t\t\t\t\toperation.requestBody.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tfor (const mediaType of Object.values(operation.requestBody.content)) {\n\t\t\t\t\t\t\tif (mediaType && typeof mediaType === \"object\" && \"schema\" in mediaType && mediaType.schema) {\n\t\t\t\t\t\t\t\tthis.extractSchemaRefs(mediaType.schema, requestSchemas);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check responses\n\t\t\t\t\tif (\"responses\" in operation && operation.responses && typeof operation.responses === \"object\") {\n\t\t\t\t\t\tfor (const response of Object.values(operation.responses)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tresponse &&\n\t\t\t\t\t\t\t\ttypeof response === \"object\" &&\n\t\t\t\t\t\t\t\t\"content\" in response &&\n\t\t\t\t\t\t\t\tresponse.content &&\n\t\t\t\t\t\t\t\ttypeof response.content === \"object\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfor (const mediaType of Object.values(response.content)) {\n\t\t\t\t\t\t\t\t\tif (mediaType && typeof mediaType === \"object\" && \"schema\" in mediaType && mediaType.schema) {\n\t\t\t\t\t\t\t\t\t\tthis.extractSchemaRefs(mediaType.schema, responseSchemas);\n\t\t\t\t\t\t\t\t\t}\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}\n\n\t\t\t\t\t// Check parameters\n\t\t\t\t\tif (\"parameters\" in operation && Array.isArray(operation.parameters)) {\n\t\t\t\t\t\tfor (const param of operation.parameters) {\n\t\t\t\t\t\t\tif (param && typeof param === \"object\" && \"schema\" in param && param.schema) {\n\t\t\t\t\t\t\t\tthis.extractSchemaRefs(param.schema, requestSchemas);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Expand to include all transitively referenced schemas\n\t\t\tthis.expandTransitiveReferences(requestSchemas);\n\t\t\tthis.expandTransitiveReferences(responseSchemas);\n\t\t}\n\n\t\t// Fallback: analyze readOnly/writeOnly properties if paths not available\n\t\tif (!this.spec.paths || (requestSchemas.size === 0 && responseSchemas.size === 0)) {\n\t\t\tfor (const [name, schema] of Object.entries(this.spec.components?.schemas || {})) {\n\t\t\t\tconst hasReadOnly = this.hasReadOnlyProperties(schema);\n\t\t\t\tconst hasWriteOnly = this.hasWriteOnlyProperties(schema);\n\n\t\t\t\tif (hasWriteOnly && !hasReadOnly) {\n\t\t\t\t\trequestSchemas.add(name);\n\t\t\t\t} else if (hasReadOnly && !hasWriteOnly) {\n\t\t\t\t\tresponseSchemas.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Build usage map with circular reference detection\n\t\tfor (const [name] of Object.entries(this.spec.components?.schemas || {})) {\n\t\t\tif (requestSchemas.has(name) && responseSchemas.has(name)) {\n\t\t\t\tthis.schemaUsageMap.set(name, \"both\");\n\t\t\t} else if (requestSchemas.has(name)) {\n\t\t\t\tthis.schemaUsageMap.set(name, \"request\");\n\t\t\t} else if (responseSchemas.has(name)) {\n\t\t\t\tthis.schemaUsageMap.set(name, \"response\");\n\t\t\t}\n\t\t\t// Unreferenced schemas are not added to map (will use root typeMode)\n\t\t}\n\n\t\t// Detect circular references and mark entire chain as \"both\"\n\t\tthis.detectCircularReferences();\n\t}\n\n\t/**\n\t * Expand a set of schemas to include all transitively referenced schemas\n\t */\n\tprivate expandTransitiveReferences(schemas: Set<string>): void {\n\t\tconst toProcess = Array.from(schemas);\n\t\tconst processed = new Set<string>();\n\n\t\twhile (toProcess.length > 0) {\n\t\t\tconst schemaName = toProcess.pop();\n\t\t\tif (!schemaName || processed.has(schemaName)) continue;\n\n\t\t\tprocessed.add(schemaName);\n\n\t\t\tconst schema = this.spec.components?.schemas?.[schemaName];\n\t\t\tif (schema) {\n\t\t\t\tconst refs = new Set<string>();\n\t\t\t\tthis.extractSchemaRefs(schema, refs);\n\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\tif (!schemas.has(ref)) {\n\t\t\t\t\t\tschemas.add(ref);\n\t\t\t\t\t\ttoProcess.push(ref);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Extract schema names from $ref and nested structures\n\t */\n\tprivate extractSchemaRefs(schema: any, refs: Set<string>): void {\n\t\tif (!schema) return;\n\n\t\tif (schema.$ref) {\n\t\t\tconst refName = resolveRef(schema.$ref);\n\t\t\trefs.add(refName);\n\t\t}\n\n\t\tif (schema.allOf) {\n\t\t\tfor (const subSchema of schema.allOf) {\n\t\t\t\tthis.extractSchemaRefs(subSchema, refs);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.oneOf) {\n\t\t\tfor (const subSchema of schema.oneOf) {\n\t\t\t\tthis.extractSchemaRefs(subSchema, refs);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.anyOf) {\n\t\t\tfor (const subSchema of schema.anyOf) {\n\t\t\t\tthis.extractSchemaRefs(subSchema, refs);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.items) {\n\t\t\tthis.extractSchemaRefs(schema.items, refs);\n\t\t}\n\n\t\tif (schema.properties) {\n\t\t\tfor (const prop of Object.values(schema.properties)) {\n\t\t\t\tthis.extractSchemaRefs(prop, refs);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Check if schema has readOnly properties\n\t */\n\tprivate hasReadOnlyProperties(schema: OpenAPISchema): boolean {\n\t\tif (schema.readOnly) return true;\n\t\tif (schema.properties) {\n\t\t\tfor (const prop of Object.values(schema.properties)) {\n\t\t\t\tif (this.hasReadOnlyProperties(prop)) return true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if schema has writeOnly properties\n\t */\n\tprivate hasWriteOnlyProperties(schema: OpenAPISchema): boolean {\n\t\tif (schema.writeOnly) return true;\n\t\tif (schema.properties) {\n\t\t\tfor (const prop of Object.values(schema.properties)) {\n\t\t\t\tif (this.hasWriteOnlyProperties(prop)) return true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Detect circular references and mark them as \"both\" context for safety\n\t */\n\tprivate detectCircularReferences(): void {\n\t\tconst visited = new Set<string>();\n\t\tconst recursionStack = new Set<string>();\n\n\t\tconst detectCycle = (name: string): boolean => {\n\t\t\tif (recursionStack.has(name)) {\n\t\t\t\t// Found a cycle - mark all schemas in the cycle as \"both\"\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (visited.has(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tvisited.add(name);\n\t\t\trecursionStack.add(name);\n\n\t\t\tconst schema = this.spec.components?.schemas?.[name];\n\t\t\tif (schema) {\n\t\t\t\tconst refs = new Set<string>();\n\t\t\t\tthis.extractSchemaRefs(schema, refs);\n\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\tif (detectCycle(ref)) {\n\t\t\t\t\t\t// Mark this schema as \"both\" since it's part of a circular chain\n\t\t\t\t\t\tthis.schemaUsageMap.set(name, \"both\");\n\t\t\t\t\t\trecursionStack.delete(name);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trecursionStack.delete(name);\n\t\t\treturn false;\n\t\t};\n\n\t\tfor (const name of Object.keys(this.spec.components?.schemas || {})) {\n\t\t\tdetectCycle(name);\n\t\t}\n\t}\n\n\t/**\n\t * Determine the typeMode for each schema based on its usage context\n\t * Response schemas always use 'inferred' mode\n\t */\n\tprivate determineSchemaTypeModes(): void {\n\t\tfor (const [name] of Object.entries(this.spec.components?.schemas || {})) {\n\t\t\tconst context = this.schemaUsageMap.get(name);\n\n\t\t\tif (context === \"request\") {\n\t\t\t\tthis.schemaTypeModeMap.set(name, this.requestOptions.typeMode);\n\t\t\t} else if (context === \"response\") {\n\t\t\t\t// Response schemas always use 'inferred' mode (Zod schemas are required)\n\t\t\t\tthis.schemaTypeModeMap.set(name, \"inferred\");\n\t\t\t} else if (context === \"both\") {\n\t\t\t\t// Safety: always use inferred for schemas used in both contexts\n\t\t\t\tthis.schemaTypeModeMap.set(name, \"inferred\");\n\t\t\t} else {\n\t\t\t\t// Unreferenced schemas default to inferred\n\t\t\t\tthis.schemaTypeModeMap.set(name, \"inferred\");\n\t\t\t}\n\n\t\t\t// Track if we need Zod import\n\t\t\tif (this.schemaTypeModeMap.get(name) === \"inferred\") {\n\t\t\t\tthis.needsZodImport = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Validate the OpenAPI specification\n\t */\n\tprivate validateSpec(): void {\n\t\tif (!this.spec.components?.schemas) {\n\t\t\tthrow new SpecValidationError(\n\t\t\t\t`No schemas found in OpenAPI spec at ${this.options.input}. Expected to find schemas at components.schemas`,\n\t\t\t\t{ filePath: this.options.input }\n\t\t\t);\n\t\t}\n\n\t\t// Validate all $refs can be resolved\n\t\tconst allSchemas = Object.keys(this.spec.components.schemas);\n\t\tfor (const [name, schema] of Object.entries(this.spec.components.schemas)) {\n\t\t\ttry {\n\t\t\t\tthis.validateSchemaRefs(name, schema, allSchemas);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\tthrow new SchemaGenerationError(`Invalid schema '${name}': ${error.message}`, name, {\n\t\t\t\t\t\toriginalError: error.message,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Validate all $ref references in a schema\n\t */\n\tprivate validateSchemaRefs(schemaName: string, schema: OpenAPISchema, allSchemas: string[], path = \"\"): void {\n\t\tif (schema.$ref) {\n\t\t\tconst refName = resolveRef(schema.$ref);\n\t\t\tif (!allSchemas.includes(refName)) {\n\t\t\t\tthrow new SpecValidationError(\n\t\t\t\t\t`Invalid reference${path ? ` at '${path}'` : \"\"}: ` +\n\t\t\t\t\t\t`'${schema.$ref}' points to non-existent schema '${refName}'`,\n\t\t\t\t\t{ schemaName, path, ref: schema.$ref, refName }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Recursively validate nested schemas\n\t\tif (schema.properties) {\n\t\t\tfor (const [propName, propSchema] of Object.entries(schema.properties)) {\n\t\t\t\tthis.validateSchemaRefs(schemaName, propSchema, allSchemas, path ? `${path}.${propName}` : propName);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.items) {\n\t\t\tthis.validateSchemaRefs(schemaName, schema.items, allSchemas, `${path}[]`);\n\t\t}\n\n\t\tif (schema.prefixItems) {\n\t\t\tschema.prefixItems.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.prefixItems[${i}]`);\n\t\t\t});\n\t\t}\n\n\t\tif (schema.allOf) {\n\t\t\tschema.allOf.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.allOf[${i}]`);\n\t\t\t});\n\t\t}\n\n\t\tif (schema.oneOf) {\n\t\t\tschema.oneOf.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.oneOf[${i}]`);\n\t\t\t});\n\t\t}\n\n\t\tif (schema.anyOf) {\n\t\t\tschema.anyOf.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.anyOf[${i}]`);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Generate schema for a component\n\t */\n\tprivate generateComponentSchema(name: string, schema: OpenAPISchema): void {\n\t\t// Initialize dependencies for this schema\n\t\tif (!this.schemaDependencies.has(name)) {\n\t\t\tthis.schemaDependencies.set(name, new Set());\n\t\t}\n\n\t\t// Get the typeMode for this schema\n\t\tconst typeMode = this.schemaTypeModeMap.get(name) || \"inferred\";\n\t\tconst context = this.schemaUsageMap.get(name);\n\t\tconst resolvedOptions = context === \"response\" ? this.responseOptions : this.requestOptions;\n\n\t\t// Handle enums at the top level\n\t\tif (schema.enum) {\n\t\t\tif (typeMode === \"inferred\") {\n\t\t\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\t\t\t\tconst { enumCode, schemaCode, typeCode } = generateEnum(name, schema.enum, {\n\t\t\t\t\tenumType: resolvedOptions.enumType,\n\t\t\t\t\tprefix: this.options.prefix,\n\t\t\t\t\tsuffix: this.options.suffix,\n\t\t\t\t});\n\n\t\t\t\tif (enumCode) {\n\t\t\t\t\tthis.enums.set(name, enumCode);\n\t\t\t\t}\n\n\t\t\t\tconst enumSchemaCode = `${jsdoc}${schemaCode}\\n${typeCode}`;\n\t\t\t\tthis.schemas.set(name, enumSchemaCode);\n\t\t\t}\n\t\t\t// Native enum already generated in first pass\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeMode === \"native\") {\n\t\t\t// Generate native TypeScript type\n\t\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\t\t\tconst jsdocWithConstraints = this.addConstraintsToJSDoc(jsdoc, schema, resolvedOptions.includeDescriptions);\n\t\t\tconst typeDefinition = this.generateNativeTypeDefinition(schema, name);\n\t\t\tconst typeCode = `${jsdocWithConstraints}export type ${name} = ${typeDefinition};`;\n\t\t\tthis.types.set(name, typeCode);\n\t\t} else {\n\t\t\t// Generate Zod schema\n\t\t\tconst schemaName = `${toCamelCase(name, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;\n\t\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\n\t\t\t// For allOf with single $ref, track dependency manually since we simplify it\n\t\t\tif (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref) {\n\t\t\t\tconst refName = resolveRef(schema.allOf[0].$ref);\n\t\t\t\tthis.schemaDependencies.get(name)?.add(refName);\n\t\t\t}\n\n\t\t\t// Update property generator context for this schema\n\t\t\tthis.propertyGenerator = new PropertyGenerator({\n\t\t\t\tspec: this.spec,\n\t\t\t\tschemaDependencies: this.schemaDependencies,\n\t\t\t\tschemaType: this.options.schemaType || \"all\",\n\t\t\t\tmode: resolvedOptions.mode,\n\t\t\t\tincludeDescriptions: resolvedOptions.includeDescriptions,\n\t\t\t\tuseDescribe: resolvedOptions.useDescribe,\n\t\t\t\ttypeMode: resolvedOptions.typeMode,\n\t\t\t\tnativeEnumType: resolvedOptions.nativeEnumType,\n\t\t\t\tnamingOptions: {\n\t\t\t\t\tprefix: this.options.prefix,\n\t\t\t\t\tsuffix: this.options.suffix,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Check if this is just a simple $ref (alias)\n\t\t\tconst isAlias = !!(schema.$ref && !schema.properties && !schema.allOf && !schema.oneOf && !schema.anyOf);\n\t\t\tconst zodSchema = this.propertyGenerator.generatePropertySchema(schema, name, isAlias);\n\t\t\tconst zodSchemaCode = `${jsdoc}export const ${schemaName} = ${zodSchema};`;\n\n\t\t\t// Track dependencies from discriminated unions\n\t\t\t// Extract schema references like \"carSchema, truckSchema\" from discriminatedUnion calls\n\t\t\tif (zodSchema.includes(\"z.discriminatedUnion(\")) {\n\t\t\t\tconst match = zodSchema.match(/z\\.discriminatedUnion\\([^,]+,\\s*\\[([^\\]]+)\\]/);\n\t\t\t\tif (match) {\n\t\t\t\t\tconst refs = match[1].split(\",\").map(ref => ref.trim());\n\t\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\t\t// Extract schema name from camelCase reference (e.g., \"carSchema\" -> \"Car\")\n\t\t\t\t\t\tconst depMatch = ref.match(/^([a-z][a-zA-Z0-9]*?)Schema$/);\n\t\t\t\t\t\tif (depMatch) {\n\t\t\t\t\t\t\t// Convert camelCase to PascalCase (carSchema -> Car)\n\t\t\t\t\t\t\tconst depName = depMatch[1].charAt(0).toUpperCase() + depMatch[1].slice(1);\n\t\t\t\t\t\t\tthis.schemaDependencies.get(name)?.add(depName);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.schemas.set(name, zodSchemaCode);\n\t\t}\n\t}\n\n\t/**\n\t * Generate native TypeScript enum\n\t */\n\tprivate generateNativeEnum(name: string, schema: OpenAPISchema): void {\n\t\tif (!schema.enum) return;\n\n\t\tconst context = this.schemaUsageMap.get(name);\n\t\tconst resolvedOptions = context === \"response\" ? this.responseOptions : this.requestOptions;\n\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\n\t\tif (resolvedOptions.nativeEnumType === \"enum\") {\n\t\t\t// Generate TypeScript enum with Enum suffix (no prefix/suffix)\n\t\t\tconst enumName = `${name}Enum`;\n\t\t\tconst members = schema.enum\n\t\t\t\t.map((value, index) => {\n\t\t\t\t\tconst key = typeof value === \"string\" ? this.toEnumKey(value) : `Value${index}`;\n\t\t\t\t\tconst val = typeof value === \"string\" ? `\"${value}\"` : value;\n\t\t\t\t\treturn ` ${key} = ${val}`;\n\t\t\t\t})\n\t\t\t\t.join(\",\\n\");\n\n\t\t\tconst enumCode = `${jsdoc}export enum ${enumName} {\\n${members}\\n}`;\n\t\t\tthis.nativeEnums.set(name, enumCode);\n\n\t\t\t// Also create a type alias for convenience\n\t\t\tconst typeCode = `export type ${name} = ${enumName};`;\n\t\t\tthis.types.set(name, typeCode);\n\t\t} else {\n\t\t\t// Generate union type\n\t\t\tconst unionType = schema.enum.map(v => (typeof v === \"string\" ? `\"${v}\"` : v)).join(\" | \");\n\t\t\tconst typeCode = `${jsdoc}export type ${name} = ${unionType};`;\n\t\t\tthis.types.set(name, typeCode);\n\t\t}\n\t}\n\n\t/**\n\t * Convert string to valid enum key\n\t */\n\tprivate toEnumKey(value: string): string {\n\t\t// Convert to PascalCase and ensure it starts with a letter\n\t\tconst cleaned = value.replace(/[^a-zA-Z0-9]/g, \"_\");\n\t\tconst pascalCase = cleaned\n\t\t\t.split(\"_\")\n\t\t\t.map(part => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())\n\t\t\t.join(\"\");\n\t\treturn pascalCase || \"Value\";\n\t}\n\n\t/**\n\t * Add constraint annotations to JSDoc for native types\n\t */\n\tprivate addConstraintsToJSDoc(jsdoc: string, schema: OpenAPISchema, includeDescriptions: boolean): string {\n\t\tif (!includeDescriptions) return jsdoc;\n\n\t\tconst constraints: string[] = [];\n\n\t\tif (schema.minLength !== undefined) constraints.push(`@minLength ${schema.minLength}`);\n\t\tif (schema.maxLength !== undefined) constraints.push(`@maxLength ${schema.maxLength}`);\n\t\tif (schema.pattern) constraints.push(`@pattern ${schema.pattern}`);\n\t\tif (schema.minimum !== undefined) constraints.push(`@minimum ${schema.minimum}`);\n\t\tif (schema.maximum !== undefined) constraints.push(`@maximum ${schema.maximum}`);\n\t\tif (schema.minItems !== undefined) constraints.push(`@minItems ${schema.minItems}`);\n\t\tif (schema.maxItems !== undefined) constraints.push(`@maxItems ${schema.maxItems}`);\n\t\tif (schema.minProperties !== undefined) constraints.push(`@minProperties ${schema.minProperties}`);\n\t\tif (schema.maxProperties !== undefined) constraints.push(`@maxProperties ${schema.maxProperties}`);\n\t\tif (schema.multipleOf !== undefined) constraints.push(`@multipleOf ${schema.multipleOf}`);\n\t\tif (schema.format) constraints.push(`@format ${schema.format}`);\n\n\t\tif (constraints.length === 0) return jsdoc;\n\n\t\t// If there's already a JSDoc, add constraints to it\n\t\tif (jsdoc) {\n\t\t\tconst lines = jsdoc.trim().split(\"\\n\");\n\t\t\tif (lines[0] === \"/**\" && lines[lines.length - 1] === \" */\") {\n\t\t\t\t// Multi-line JSDoc\n\t\t\t\tconst newLines = [...lines.slice(0, -1), ...constraints.map(c => ` * ${c}`), \" */\\n\"];\n\t\t\t\treturn newLines.join(\"\\n\");\n\t\t\t}\n\t\t\t// Single-line JSDoc\n\t\t\tconst content = jsdoc.replace(\"/** \", \"\").replace(\" */\\n\", \"\");\n\t\t\treturn `/**\\n * ${content}\\n${constraints.map(c => ` * ${c}`).join(\"\\n\")}\\n */\\n`;\n\t\t}\n\n\t\t// No existing JSDoc, create new one with just constraints\n\t\treturn `/**\\n${constraints.map(c => ` * ${c}`).join(\"\\n\")}\\n */\\n`;\n\t}\n\n\t/**\n\t * Generate native TypeScript type definition from OpenAPI schema\n\t */\n\tprivate generateNativeTypeDefinition(schema: OpenAPISchema, _schemaName?: string): string {\n\t\t// Handle $ref\n\t\tif (schema.$ref) {\n\t\t\treturn resolveRef(schema.$ref);\n\t\t}\n\n\t\t// Handle const\n\t\tif (schema.const !== undefined) {\n\t\t\treturn typeof schema.const === \"string\" ? `\"${schema.const}\"` : String(schema.const);\n\t\t}\n\n\t\t// Handle nullable\n\t\tconst isNullable = schema.nullable || (Array.isArray(schema.type) && schema.type.includes(\"null\"));\n\t\tconst wrapNullable = (type: string) => (isNullable ? `(${type}) | null` : type);\n\n\t\t// Get primary type\n\t\tconst primaryType = Array.isArray(schema.type) ? schema.type.find(t => t !== \"null\") : schema.type;\n\n\t\t// Handle different types\n\t\tswitch (primaryType) {\n\t\t\tcase \"string\":\n\t\t\t\treturn wrapNullable(\"string\");\n\t\t\tcase \"number\":\n\t\t\tcase \"integer\":\n\t\t\t\treturn wrapNullable(\"number\");\n\t\t\tcase \"boolean\":\n\t\t\t\treturn wrapNullable(\"boolean\");\n\t\t\tcase \"array\":\n\t\t\t\tif (schema.items) {\n\t\t\t\t\tconst itemType = this.generateNativeTypeDefinition(schema.items);\n\t\t\t\t\treturn wrapNullable(`${itemType}[]`);\n\t\t\t\t}\n\t\t\t\treturn wrapNullable(\"unknown[]\");\n\t\t\tcase \"object\":\n\t\t\t\treturn wrapNullable(this.generateObjectType(schema));\n\t\t\tdefault:\n\t\t\t\t// Handle composition schemas\n\t\t\t\tif (schema.allOf) {\n\t\t\t\t\tconst types = schema.allOf.map(s => this.generateNativeTypeDefinition(s));\n\t\t\t\t\treturn wrapNullable(types.join(\" & \"));\n\t\t\t\t}\n\t\t\t\tif (schema.oneOf || schema.anyOf) {\n\t\t\t\t\tconst schemas = schema.oneOf || schema.anyOf || [];\n\t\t\t\t\tconst types = schemas.map(s => this.generateNativeTypeDefinition(s));\n\t\t\t\t\treturn wrapNullable(types.join(\" | \"));\n\t\t\t\t}\n\t\t\t\treturn wrapNullable(\"unknown\");\n\t\t}\n\t}\n\n\t/**\n\t * Generate TypeScript object type definition\n\t */\n\tprivate generateObjectType(schema: OpenAPISchema): string {\n\t\tif (!schema.properties || Object.keys(schema.properties).length === 0) {\n\t\t\treturn \"Record<string, unknown>\";\n\t\t}\n\n\t\tconst context = this.schemaUsageMap.get(schema.$ref ? resolveRef(schema.$ref) : \"\");\n\t\tconst resolvedOptions = context === \"response\" ? this.responseOptions : this.requestOptions;\n\t\tconst required = new Set(schema.required || []);\n\t\tconst props: string[] = [];\n\n\t\tfor (const [propName, propSchema] of Object.entries(schema.properties)) {\n\t\t\tconst propType = this.generateNativeTypeDefinition(propSchema);\n\t\t\tconst optional = !required.has(propName) ? \"?\" : \"\";\n\n\t\t\t// Generate JSDoc with constraints\n\t\t\tlet propJsdoc = generateJSDoc(propSchema, propName, { includeDescriptions: resolvedOptions.includeDescriptions });\n\t\t\tif (resolvedOptions.includeDescriptions && !propJsdoc) {\n\t\t\t\t// Add constraint-only JSDoc if no description exists\n\t\t\t\tpropJsdoc = this.addConstraintsToJSDoc(\"\", propSchema, resolvedOptions.includeDescriptions);\n\t\t\t} else if (propJsdoc && resolvedOptions.includeDescriptions) {\n\t\t\t\t// Add constraints to existing JSDoc\n\t\t\t\tpropJsdoc = this.addConstraintsToJSDoc(propJsdoc, propSchema, resolvedOptions.includeDescriptions);\n\t\t\t}\n\n\t\t\tif (propJsdoc) {\n\t\t\t\t// Remove trailing newline for inline property JSDoc\n\t\t\t\tconst cleanJsdoc = propJsdoc.trimEnd();\n\t\t\t\tprops.push(` ${cleanJsdoc}\\n ${propName}${optional}: ${propType};`);\n\t\t\t} else {\n\t\t\t\tprops.push(` ${propName}${optional}: ${propType};`);\n\t\t\t}\n\t\t}\n\n\t\treturn `{\\n${props.join(\"\\n\")}\\n}`;\n\t}\n\n\t/**\n\t * Topological sort for schema dependencies\n\t * Returns schemas in the order they should be declared\n\t */\n\tprivate topologicalSort(): string[] {\n\t\tconst sorted: string[] = [];\n\t\tconst visited = new Set<string>();\n\t\tconst visiting = new Set<string>();\n\t\tconst aliases: string[] = [];\n\n\t\t// Performance optimization: Cache schema and type code lookups\n\t\tconst codeCache = new Map<string, string>();\n\t\tfor (const [name, code] of this.schemas) {\n\t\t\tcodeCache.set(name, code);\n\t\t}\n\t\tfor (const [name, code] of this.types) {\n\t\t\tcodeCache.set(name, code);\n\t\t}\n\n\t\tconst visit = (name: string): void => {\n\t\t\tif (visited.has(name)) return;\n\n\t\t\t// Detect circular dependencies\n\t\t\tif (visiting.has(name)) {\n\t\t\t\t// For circular deps, we'll just continue - Zod can handle forward references in many cases\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvisiting.add(name);\n\n\t\t\t// Check if this is a simple alias (just assigns another schema directly)\n\t\t\tconst code = codeCache.get(name) || \"\";\n\t\t\tconst isSimpleAlias =\n\t\t\t\tcode.match(/= (\\w+Schema);$/) !== null &&\n\t\t\t\t!code.includes(\"z.object\") &&\n\t\t\t\t!code.includes(\"z.enum\") &&\n\t\t\t\t!code.includes(\"z.union\") &&\n\t\t\t\t!code.includes(\"z.array\") &&\n\t\t\t\t!code.includes(\".and(\");\n\n\t\t\tif (isSimpleAlias) {\n\t\t\t\t// For simple aliases, just mark as visited and add to aliases list\n\t\t\t\tvisiting.delete(name);\n\t\t\t\tvisited.add(name);\n\t\t\t\taliases.push(name);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Visit dependencies first for non-alias schemas\n\t\t\tconst deps = this.schemaDependencies.get(name);\n\t\t\tif (deps && deps.size > 0) {\n\t\t\t\tfor (const dep of deps) {\n\t\t\t\t\tif (this.schemas.has(dep) || this.types.has(dep)) {\n\t\t\t\t\t\tvisit(dep);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvisiting.delete(name);\n\t\t\tvisited.add(name);\n\t\t\tsorted.push(name);\n\t\t};\n\n\t\t// Visit all schemas and types\n\t\tconst allNames = new Set([...this.schemas.keys(), ...this.types.keys()]);\n\t\tfor (const name of allNames) {\n\t\t\tvisit(name);\n\t\t}\n\n\t\t// Add aliases at the end\n\t\treturn [...sorted, ...aliases];\n\t}\n\n\t/**\n\t * Generate statistics about the generated schemas\n\t */\n\tprivate generateStats(): string[] {\n\t\tconst stats = {\n\t\t\ttotalSchemas: this.schemas.size,\n\t\t\tenums: this.enums.size,\n\t\t\twithCircularRefs: 0,\n\t\t\twithDiscriminators: 0,\n\t\t\twithConstraints: 0,\n\t\t};\n\n\t\t// Count schemas with special features\n\t\tfor (const code of this.schemas.values()) {\n\t\t\tif (code.includes(\"z.lazy(\")) stats.withCircularRefs++;\n\t\t\tif (code.includes(\"z.discriminatedUnion\")) stats.withDiscriminators++;\n\t\t\tif (code.includes(\".min(\") || code.includes(\".max(\") || code.includes(\".gte(\")) {\n\t\t\t\tstats.withConstraints++;\n\t\t\t}\n\t\t}\n\n\t\treturn [\n\t\t\t\"// Generation Statistics:\",\n\t\t\t`// Total schemas: ${stats.totalSchemas}`,\n\t\t\t`// Enums: ${stats.enums}`,\n\t\t\t`// Circular references: ${stats.withCircularRefs}`,\n\t\t\t`// Discriminated unions: ${stats.withDiscriminators}`,\n\t\t\t`// With constraints: ${stats.withConstraints}`,\n\t\t\t`// Generated at: ${new Date().toISOString()}`,\n\t\t];\n\t}\n}\n","/**\n * Name conversion utilities\n */\n\nexport interface NamingOptions {\n\tprefix?: string;\n\tsuffix?: string;\n}\n\n/**\n * Convert schema name to camelCase with optional prefix/suffix\n */\nexport function toCamelCase(str: string, options?: NamingOptions): string {\n\tlet name = str.charAt(0).toLowerCase() + str.slice(1);\n\n\t// Add prefix\n\tif (options?.prefix) {\n\t\tconst prefix = options.prefix.toLowerCase();\n\t\tname = prefix + name.charAt(0).toUpperCase() + name.slice(1);\n\t}\n\n\t// Add suffix before \"Schema\"\n\tif (options?.suffix) {\n\t\tconst suffix = options.suffix;\n\t\tname = name + suffix.charAt(0).toUpperCase() + suffix.slice(1).toLowerCase();\n\t}\n\n\treturn name;\n}\n\n/**\n * Convert enum value to PascalCase and sanitize for TypeScript enum keys\n */\nexport function toPascalCase(str: string | number): string {\n\tconst stringValue = String(str);\n\t// Replace ALL special characters (not just dots/spaces) with underscores, then convert to PascalCase\n\t// Valid identifier chars: letters, digits, underscore. Everything else becomes underscore.\n\tlet result = stringValue\n\t\t.replace(/[^a-zA-Z0-9_]+/g, \"_\") // Replace all non-identifier chars with underscore\n\t\t.split(/[-_]+/)\n\t\t.filter(word => word.length > 0) // Remove empty parts\n\t\t.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\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\tresult = \"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 type { NamingOptions } from \"../utils/name-utils\";\nimport { toCamelCase, toPascalCase } from \"../utils/name-utils\";\n\nexport type EnumType = \"zod\" | \"typescript\";\n\nexport interface EnumGeneratorOptions extends NamingOptions {\n\tenumType: EnumType;\n}\n\nexport interface EnumResult {\n\tenumCode: string | null;\n\tschemaCode: string;\n\ttypeCode: string;\n}\n\n/**\n * Generate enum as TypeScript enum or Zod enum\n */\nexport function generateEnum(name: string, values: (string | number)[], options: EnumGeneratorOptions): EnumResult {\n\tconst enumName = name.endsWith(\"EnumOptions\") ? name.replace(\"EnumOptions\", \"Enum\") : `${name}Enum`;\n\tconst schemaName = `${toCamelCase(name, options)}Schema`;\n\n\tif (options.enumType === \"typescript\") {\n\t\t// Generate TypeScript enum\n\t\tconst usedKeys = new Set<string>();\n\t\tconst enumEntries = values\n\t\t\t.map(value => {\n\t\t\t\tlet key = toPascalCase(value);\n\n\t\t\t\t// Handle duplicate keys by appending a suffix\n\t\t\t\tif (usedKeys.has(key)) {\n\t\t\t\t\tlet counter = 2;\n\t\t\t\t\twhile (usedKeys.has(`${key}${counter}`)) {\n\t\t\t\t\t\tcounter++;\n\t\t\t\t\t}\n\t\t\t\t\tkey = `${key}${counter}`;\n\t\t\t\t}\n\t\t\t\tusedKeys.add(key);\n\n\t\t\t\tconst stringValue = typeof value === \"string\" ? `\"${value}\"` : value;\n\t\t\t\treturn ` ${key} = ${stringValue},`;\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\n\t\tconst enumCode = `export enum ${enumName} {\\n${enumEntries}\\n}`;\n\t\tconst schemaCode = `export const ${schemaName} = z.enum(${enumName});`;\n\t\tconst typeCode = `export type ${name} = z.infer<typeof ${schemaName}>;`;\n\n\t\treturn { enumCode, schemaCode, typeCode };\n\t}\n\n\t// Generate Zod enum (default)\n\t// Note: z.enum only accepts string values, so convert numbers to strings\n\tconst enumValues = values.map(v => `\"${v}\"`).join(\", \");\n\tconst schemaCode = `export const ${schemaName} = z.enum([${enumValues}]);`;\n\tconst typeCode = `export type ${name} = z.infer<typeof ${schemaName}>;`;\n\n\treturn { enumCode: null, schemaCode, typeCode };\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 */\nexport function escapePattern(str: string): string {\n\treturn str.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\");\n}\n\n/**\n * Escape JSDoc comment content\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 */\nexport function isNullable(schema: OpenAPISchema): boolean {\n\t// OpenAPI 3.0 style: nullable: true\n\tif (schema.nullable === true) {\n\t\treturn true;\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\treturn false;\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 { 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","/**\n * Simple LRU Cache implementation for performance optimization\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(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","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: (schema: OpenAPISchema, currentSchema?: string, isTopLevel?: boolean) => string;\n\tresolveDiscriminatorMapping?: (mapping: Record<string, string>, schemas: OpenAPISchema[]) => OpenAPISchema[];\n}\n\nexport interface UnionOptions {\n\tpassthrough?: boolean;\n\tdiscriminatorMapping?: Record<string, string>;\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): string {\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// Use discriminated union for better type inference\n\t\tlet schemaStrings = resolvedSchemas.map(s => context.generatePropertySchema(s));\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\tlet schemaStrings = schemas.map(s => context.generatePropertySchema(s));\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 * Generate allOf validation\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\tconst singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false);\n\t\treturn wrapNullable(singleSchema, isNullable);\n\t}\n\n\t// Check if all schemas are objects (for .merge() support)\n\tconst allObjects = schemas.every(s => s.type === \"object\" || s.properties || s.$ref || s.allOf);\n\n\tconst schemaStrings = schemas.map(s => context.generatePropertySchema(s, currentSchema, false));\n\n\tif (allObjects) {\n\t\t// Use .merge() for object schemas (better type inference)\n\t\tlet merged = schemaStrings[0];\n\t\tfor (let i = 1; i < schemaStrings.length; i++) {\n\t\t\tmerged = `${merged}.merge(${schemaStrings[i]})`;\n\t\t}\n\t\treturn wrapNullable(merged, isNullable);\n\t}\n\n\t// Use .and() for non-object schemas (intersection)\n\tlet merged = schemaStrings[0];\n\tfor (let i = 1; i < schemaStrings.length; i++) {\n\t\tmerged = `${merged}.and(${schemaStrings[i]})`;\n\t}\n\treturn wrapNullable(merged, 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\";\r\n\r\n/**\r\n * Generate property access expression (use dot notation for valid identifiers, bracket notation otherwise)\r\n */\r\nfunction generatePropertyAccess(propName: string): string {\r\n\t// Valid identifier: starts with letter/underscore/$, followed by letters/digits/underscores/$\r\n\tconst validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\r\n\treturn validIdentifier.test(propName) ? `obj.${propName}` : `obj[\"${propName}\"]`;\r\n}\r\n\r\n/**\r\n * Generate validation for dependencies (OpenAPI 3.0)\r\n * Generates detailed error messages showing which specific fields are missing\r\n */\r\nexport function generateDependencies(\r\n\tschema: OpenAPISchema,\r\n\tgeneratePropertySchema?: (schema: OpenAPISchema, currentSchema?: string) => string,\r\n\tcurrentSchema?: string\r\n): string {\r\n\tif (!schema.dependencies) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tlet result = \"\";\r\n\tfor (const [prop, dependency] of Object.entries(schema.dependencies)) {\r\n\t\tif (Array.isArray(dependency)) {\r\n\t\t\t// Skip empty dependency arrays (no dependencies to enforce)\r\n\t\t\tif (dependency.length === 0) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\t// Property dependency - show specific missing properties in error message\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\t\tconst checkLogic = dependency\r\n\t\t\t\t.map(p => {\r\n\t\t\t\t\tconst pAccess = generatePropertyAccess(p);\r\n\t\t\t\t\treturn `if (${pAccess} === undefined) missing.push('${p}');`;\r\n\t\t\t\t})\r\n\t\t\t\t.join(\"\\n\\t\\t\");\r\n\r\n\t\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\t\tconst missing: string[] = [];\r\n\t\t\t\t${checkLogic}\r\n\t\t\t\tif (missing.length > 0) {\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: \\`When '${prop}' is present, the following properties are required: \\${missing.join(', ')}\\`,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t})`;\r\n\t\t} else if (generatePropertySchema) {\r\n\t\t\t// Schema dependency - show detailed validation errors\r\n\t\t\tconst depSchema: OpenAPISchema = { ...dependency, type: dependency.type || \"object\" };\r\n\t\t\tconst depSchemaValidation = generatePropertySchema(depSchema, currentSchema);\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\r\n\t\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\t\tconst validation = ${depSchemaValidation}.safeParse(obj);\r\n\t\t\t\tif (!validation.success) {\r\n\t\t\t\t\tconst errors = validation.error.issues.map(i => \\` - \\${i.path.join('.')}: \\${i.message}\\`).join('\\\\n');\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: \\`When '${prop}' is present, object must satisfy additional constraints:\\\\n\\${errors}\\`,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t})`;\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Generate condition check for if/then/else\r\n */\r\nexport function generateConditionalCheck(schema: OpenAPISchema): string {\r\n\tconst conditions: string[] = [];\r\n\r\n\t// Check properties\r\n\tif (schema.properties) {\r\n\t\tfor (const [prop, propSchema] of Object.entries(schema.properties)) {\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\t\tif (propSchema.type) {\r\n\t\t\t\tconditions.push(`typeof ${propAccess} === \"${propSchema.type}\"`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.const !== undefined) {\r\n\t\t\t\tconst value = typeof propSchema.const === \"string\" ? `\"${propSchema.const}\"` : propSchema.const;\r\n\t\t\t\tconditions.push(`${propAccess} === ${value}`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.minimum !== undefined) {\r\n\t\t\t\tconditions.push(`${propAccess} >= ${propSchema.minimum}`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.maximum !== undefined) {\r\n\t\t\t\tconditions.push(`${propAccess} <= ${propSchema.maximum}`);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Check required properties\r\n\tif (schema.required) {\r\n\t\tfor (const prop of schema.required) {\r\n\t\t\tconditions.push(`${generatePropertyAccess(prop)} !== undefined`);\r\n\t\t}\r\n\t}\r\n\r\n\treturn conditions.length > 0 ? conditions.join(\" && \") : \"true\";\r\n}\r\n\r\n/**\r\n * Generate validation for then/else clauses\r\n */\r\nexport function generateConditionalValidation(schema: OpenAPISchema): string {\r\n\tconst checks: string[] = [];\r\n\r\n\t// Check required properties\r\n\tif (schema.required) {\r\n\t\tfor (const prop of schema.required) {\r\n\t\t\tchecks.push(`${generatePropertyAccess(prop)} !== undefined`);\r\n\t\t}\r\n\t}\r\n\r\n\t// Check properties constraints\r\n\tif (schema.properties) {\r\n\t\tfor (const [prop, propSchema] of Object.entries(schema.properties)) {\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\t\tif (propSchema.minimum !== undefined) {\r\n\t\t\t\tchecks.push(`${propAccess} === undefined || ${propAccess} >= ${propSchema.minimum}`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.maximum !== undefined) {\r\n\t\t\t\tchecks.push(`${propAccess} === undefined || ${propAccess} <= ${propSchema.maximum}`);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn checks.length > 0 ? checks.join(\" && \") : \"true\";\r\n}\r\n\r\n/**\r\n * Generate if/then/else conditional validation with better error messages\r\n * Uses superRefine with detailed error messages for complex cases\r\n */\r\nexport function generateIfThenElse(schema: OpenAPISchema): string {\r\n\tif (!schema.if || (!schema.then && !schema.else)) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tconst ifCondition = generateConditionalCheck(schema.if);\r\n\r\n\tif (schema.then && schema.else) {\r\n\t\t// Both then and else - provide detailed error messages\r\n\t\tconst thenValidation = generateConditionalValidation(schema.then);\r\n\t\tconst elseValidation = generateConditionalValidation(schema.else);\r\n\r\n\t\t// Try to detect which specific validations failed\r\n\t\tconst thenRequiredProps = schema.then.required || [];\r\n\t\tconst elseRequiredProps = schema.else.required || [];\r\n\r\n\t\treturn `.superRefine((obj, ctx) => {\r\n\t\t\tconst ifConditionMet = ${ifCondition};\r\n\t\t\tif (ifConditionMet) {\r\n\t\t\t\t// Then branch\r\n\t\t\t\tconst thenValid = ${thenValidation};\r\n\t\t\t\tif (!thenValid) {\r\n\t\t\t\t\t${\r\n\t\t\t\t\t\tthenRequiredProps.length > 0\r\n\t\t\t\t\t\t\t? `\r\n\t\t\t\t\tconst missingThenProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\t\tconst message = missingThenProps.length > 0 \r\n\t\t\t\t\t\t? \\`When condition is met, required properties are missing: \\${missingThenProps.join(', ')}\\`\r\n\t\t\t\t\t\t: \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t\t\t: `\r\n\t\t\t\t\tconst message = \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t}\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: message,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t// Else branch\r\n\t\t\t\tconst elseValid = ${elseValidation};\r\n\t\t\t\tif (!elseValid) {\r\n\t\t\t\t\t${\r\n\t\t\t\t\t\telseRequiredProps.length > 0\r\n\t\t\t\t\t\t\t? `\r\n\t\t\t\t\tconst missingElseProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\t\tconst message = missingElseProps.length > 0 \r\n\t\t\t\t\t\t? \\`When condition is not met, required properties are missing: \\${missingElseProps.join(', ')}\\`\r\n\t\t\t\t\t\t: \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t\t\t: `\r\n\t\t\t\t\tconst message = \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t}\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: message,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\r\n\tif (schema.then) {\r\n\t\t// Only then - provide detailed error message\r\n\t\tconst thenValidation = generateConditionalValidation(schema.then);\r\n\t\tconst thenRequiredProps = schema.then.required || [];\r\n\r\n\t\treturn `.superRefine((obj, ctx) => {\r\n\t\t\tconst ifConditionMet = ${ifCondition};\r\n\t\t\tif (ifConditionMet) {\r\n\t\t\t\tconst thenValid = ${thenValidation};\r\n\t\t\t\tif (!thenValid) {\r\n\t\t\t\t\t${\r\n\t\t\t\t\t\tthenRequiredProps.length > 0\r\n\t\t\t\t\t\t\t? `\r\n\t\t\t\t\tconst missingProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\t\tconst message = missingProps.length > 0 \r\n\t\t\t\t\t\t? \\`When condition is met, required properties are missing: \\${missingProps.join(', ')}\\`\r\n\t\t\t\t\t\t: \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t\t\t: `\r\n\t\t\t\t\tconst message = \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t}\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: message,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\r\n\t// Only else - provide detailed error message\r\n\tif (!schema.else) return \"\";\r\n\tconst elseValidation = generateConditionalValidation(schema.else);\r\n\tconst elseRequiredProps = schema.else.required || [];\r\n\r\n\treturn `.superRefine((obj, ctx) => {\r\n\t\tconst ifConditionMet = ${ifCondition};\r\n\t\tif (!ifConditionMet) {\r\n\t\t\tconst elseValid = ${elseValidation};\r\n\t\t\tif (!elseValid) {\r\n\t\t\t\t${\r\n\t\t\t\t\telseRequiredProps.length > 0\r\n\t\t\t\t\t\t? `\r\n\t\t\t\tconst missingProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\tconst message = missingProps.length > 0 \r\n\t\t\t\t\t? \\`When condition is not met, required properties are missing: \\${missingProps.join(', ')}\\`\r\n\t\t\t\t\t: \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t`\r\n\t\t\t\t\t\t: `\r\n\t\t\t\tconst message = \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t`\r\n\t\t\t\t}\r\n\t\t\t\tctx.addIssue({\r\n\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\tmessage: message,\r\n\t\t\t\t\tpath: []\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t})`;\r\n}\r\n\r\n/**\r\n * Generate dependent required validation (OpenAPI 3.1)\r\n * Generates detailed error messages showing which specific fields are missing\r\n */\r\nexport function generateDependentRequired(schema: OpenAPISchema): string {\r\n\tif (!schema.dependentRequired) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tlet result = \"\";\r\n\tfor (const [prop, requiredProps] of Object.entries(schema.dependentRequired)) {\r\n\t\t// Skip empty required arrays (no dependencies to enforce)\r\n\t\tif (requiredProps.length === 0) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\tconst checkLogic = requiredProps\r\n\t\t\t.map(rp => {\r\n\t\t\t\tconst rpAccess = generatePropertyAccess(rp);\r\n\t\t\t\treturn `if (${rpAccess} === undefined) missing.push('${rp}');`;\r\n\t\t\t})\r\n\t\t\t.join(\"\\n\\t\\t\");\r\n\r\n\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\tconst missing: string[] = [];\r\n\t\t\t${checkLogic}\r\n\t\t\tif (missing.length > 0) {\r\n\t\t\t\tctx.addIssue({\r\n\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\tmessage: \\`When '${prop}' is present, the following properties are required: \\${missing.join(', ')}\\`,\r\n\t\t\t\t\tpath: []\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Generate dependent schemas validation (JSON Schema 2019-09 / OpenAPI 3.1)\r\n * This is the modern replacement for schema-based dependencies\r\n * Generates detailed error messages showing validation failures\r\n */\r\nexport function generateDependentSchemas(\r\n\tschema: OpenAPISchema & { dependentSchemas?: Record<string, OpenAPISchema> },\r\n\tgeneratePropertySchema?: (schema: OpenAPISchema, currentSchema?: string) => string,\r\n\tcurrentSchema?: string\r\n): string {\r\n\tif (!schema.dependentSchemas || !generatePropertySchema) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tlet result = \"\";\r\n\tfor (const [prop, depSchema] of Object.entries(schema.dependentSchemas)) {\r\n\t\tconst depSchemaValidation = generatePropertySchema(depSchema, currentSchema);\r\n\t\tconst propAccess = generatePropertyAccess(prop);\r\n\r\n\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\tconst validation = ${depSchemaValidation}.safeParse(obj);\r\n\t\t\tif (!validation.success) {\r\n\t\t\t\tconst errors = validation.error.issues.map(i => \\` - \\${i.path.join('.')}: \\${i.message}\\`).join('\\\\n');\r\n\t\t\t\tctx.addIssue({\r\n\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\tmessage: \\`When '${prop}' is present, dependent schema validation failed:\\\\n\\${errors}\\`,\r\n\t\t\t\t\tpath: []\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Validate dependency graph for circular dependencies\r\n * Returns validation result with any detected circular dependency errors\r\n */\r\nexport function validateDependencyGraph(\r\n\tschema: OpenAPISchema,\r\n\tschemaName: string\r\n): { valid: boolean; errors: string[] } {\r\n\tconst errors: string[] = [];\r\n\r\n\tif (!schema.dependencies && !schema.dependentRequired) {\r\n\t\treturn { valid: true, errors: [] };\r\n\t}\r\n\r\n\t// Build dependency graph\r\n\tconst graph = new Map<string, Set<string>>();\r\n\r\n\t// Add dependentRequired edges\r\n\tif (schema.dependentRequired) {\r\n\t\tfor (const [prop, deps] of Object.entries(schema.dependentRequired)) {\r\n\t\t\tif (!graph.has(prop)) {\r\n\t\t\t\tgraph.set(prop, new Set());\r\n\t\t\t}\r\n\t\t\tconst propDeps = graph.get(prop);\r\n\t\t\tif (propDeps) {\r\n\t\t\t\tfor (const dep of deps) {\r\n\t\t\t\t\tpropDeps.add(dep);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Add dependencies (array type) edges\r\n\tif (schema.dependencies) {\r\n\t\tfor (const [prop, dep] of Object.entries(schema.dependencies)) {\r\n\t\t\tif (Array.isArray(dep)) {\r\n\t\t\t\tif (!graph.has(prop)) {\r\n\t\t\t\t\tgraph.set(prop, new Set());\r\n\t\t\t\t}\r\n\t\t\t\tconst propDeps = graph.get(prop);\r\n\t\t\t\tif (propDeps) {\r\n\t\t\t\t\tfor (const d of dep) {\r\n\t\t\t\t\t\tpropDeps.add(d);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Detect cycles using DFS\r\n\tconst visited = new Set<string>();\r\n\tconst recStack = new Set<string>();\r\n\tconst path: string[] = [];\r\n\r\n\tfunction detectCycle(prop: string): boolean {\r\n\t\tvisited.add(prop);\r\n\t\trecStack.add(prop);\r\n\t\tpath.push(prop);\r\n\r\n\t\tconst deps = graph.get(prop) || new Set();\r\n\t\tfor (const dep of deps) {\r\n\t\t\tif (!visited.has(dep)) {\r\n\t\t\t\tif (detectCycle(dep)) {\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t} else if (recStack.has(dep)) {\r\n\t\t\t\t// Cycle detected\r\n\t\t\t\tconst cycleStart = path.indexOf(dep);\r\n\t\t\t\tconst cycle = [...path.slice(cycleStart), dep];\r\n\t\t\t\terrors.push(`Circular dependency detected in schema '${schemaName}': ${cycle.join(\" -> \")}`);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\trecStack.delete(prop);\r\n\t\tpath.pop();\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Check all roots\r\n\tfor (const prop of graph.keys()) {\r\n\t\tif (!visited.has(prop)) {\r\n\t\t\tdetectCycle(prop);\r\n\t\t}\r\n\t}\r\n\r\n\treturn { valid: errors.length === 0, errors };\r\n}\r\n\r\n/**\r\n * Extract schema dependencies as reusable schemas\r\n * Useful for code generation and schema reuse\r\n */\r\nexport function extractSchemaDependencies(schema: OpenAPISchema, schemaName: string): Map<string, OpenAPISchema> {\r\n\tconst extracted = new Map<string, OpenAPISchema>();\r\n\r\n\tif (!schema.dependencies) {\r\n\t\treturn extracted;\r\n\t}\r\n\r\n\tfor (const [prop, dependency] of Object.entries(schema.dependencies)) {\r\n\t\tif (!Array.isArray(dependency)) {\r\n\t\t\t// This is a schema dependency\r\n\t\t\tconst depSchemaName = `${schemaName}_${prop}_Dependency`;\r\n\t\t\tconst depSchema: OpenAPISchema = {\r\n\t\t\t\t...dependency,\r\n\t\t\t\ttype: dependency.type || \"object\",\r\n\t\t\t};\r\n\t\t\textracted.set(depSchemaName, depSchema);\r\n\t\t}\r\n\t}\r\n\r\n\treturn extracted;\r\n}\r\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 { LRUCache } from \"../utils/lru-cache\";\nimport { addDescription, escapePattern } from \"../utils/string-utils\";\n\n// Performance optimization: Cache compiled regex patterns with size limit\nconst PATTERN_CACHE = new LRUCache<string, string>(1000);\n\nconst 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\t\"date-time\": \"z.iso.datetime()\",\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 * Generate Zod validation for string with format (Zod v4 compatible)\n */\nexport function generateStringValidation(schema: OpenAPISchema, useDescribe: boolean): string {\n\t// Handle format with Zod v4 top-level functions (performance optimized with map)\n\tlet validation = FORMAT_MAP[schema.format || \"\"] || \"z.string()\";\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)\n\tif (schema.pattern) {\n\t\tlet escapedPattern = PATTERN_CACHE.get(schema.pattern);\n\t\tif (escapedPattern === undefined) {\n\t\t\tescapedPattern = escapePattern(schema.pattern);\n\t\t\tPATTERN_CACHE.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 = PATTERN_CACHE.get(schema.pattern);\n\t\t\tif (escapedPattern === undefined) {\n\t\t\t\tescapedPattern = escapePattern(schema.pattern);\n\t\t\t\tPATTERN_CACHE.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 { NativeEnumType, OpenAPISchema, OpenAPISpec, TypeMode } from \"../types\";\nimport { LRUCache } from \"../utils/lru-cache\";\nimport type { NamingOptions } from \"../utils/name-utils\";\nimport { resolveRef, toCamelCase } from \"../utils/name-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\ttypeMode: TypeMode;\n\tnativeEnumType: NativeEnumType;\n\tnamingOptions: NamingOptions;\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 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 merge(), 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(\".merge(\")) {\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 */\n\tgeneratePropertySchema(schema: OpenAPISchema, currentSchema?: string, isTopLevel = false): 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({ schema, type: this.context.schemaType, mode: this.context.mode });\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\tconst nullable = isNullable(schema);\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\tconst schemaName = `${toCamelCase(resolvedRefName, this.context.namingOptions)}Schema`;\n\n\t\t\t// Check for circular dependency through alias\n\t\t\tif (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\tconst enumValues = schema.enum.map(v => `\"${v}\"`).join(\", \");\n\t\t\tconst zodEnum = `z.enum([${enumValues}])`;\n\t\t\treturn wrapNullable(zodEnum, nullable);\n\t\t}\n\n\t\t// Handle allOf\n\t\tif (schema.allOf) {\n\t\t\tlet composition = generateAllOf(\n\t\t\t\tschema.allOf,\n\t\t\t\tnullable,\n\t\t\t\t{ generatePropertySchema: this.generatePropertySchema.bind(this) },\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\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\tnullable,\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},\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);\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\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\tnullable,\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},\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);\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\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\tvalidation = \"z.record(z.string(), z.unknown())\";\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","import { ConfigurationError } from \"./errors\";\nimport { ZodSchemaGenerator } from \"./generator\";\nimport type { ExecutionMode, SpecConfig } from \"./types\";\n\n/**\n * Result of processing a single spec\n */\ninterface SpecResult {\n\tspec: SpecConfig;\n\tsuccess: boolean;\n\terror?: string;\n}\n\n/**\n * Summary of batch execution results\n */\ninterface BatchExecutionSummary {\n\ttotal: number;\n\tsuccessful: number;\n\tfailed: number;\n\tresults: SpecResult[];\n}\n\n/**\n * Process a single spec and return result with error handling\n */\nasync function processSpec(spec: SpecConfig, index: number, total: number): Promise<SpecResult> {\n\tconst specName = spec.name || spec.input;\n\n\t// Live progress to stdout\n\tconsole.log(`Processing [${index + 1}/${total}] ${specName}...`);\n\n\ttry {\n\t\tconst generator = new ZodSchemaGenerator(spec);\n\t\tgenerator.generate();\n\n\t\tconsole.log(`✓ Successfully generated ${spec.output}`);\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 ${spec.output}: ${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\n * Continues processing all specs even if some fail\n */\nasync function executeParallel(specs: SpecConfig[]): Promise<SpecResult[]> {\n\tconsole.log(`\\nExecuting ${specs.length} spec(s) in parallel...\\n`);\n\n\tconst promises = specs.map((spec, index) => processSpec(spec, index, specs.length));\n\n\tconst results = await Promise.allSettled(promises);\n\n\treturn results.map((result, index) => {\n\t\tif (result.status === \"fulfilled\") {\n\t\t\treturn result.value;\n\t\t}\n\n\t\t// Handle unexpected promise rejection (shouldn't happen as processSpec catches errors)\n\t\treturn {\n\t\t\tspec: specs[index],\n\t\t\tsuccess: false,\n\t\t\terror: result.reason instanceof Error ? result.reason.message : String(result.reason),\n\t\t};\n\t});\n}\n\n/**\n * Execute specs sequentially one at a time\n * Continues processing all specs even if some fail\n */\nasync function executeSequential(specs: SpecConfig[]): Promise<SpecResult[]> {\n\tconsole.log(`\\nExecuting ${specs.length} spec(s) sequentially...\\n`);\n\n\tconst results: SpecResult[] = [];\n\n\tfor (let i = 0; i < specs.length; i++) {\n\t\tconst result = await processSpec(specs[i], i, specs.length);\n\t\tresults.push(result);\n\t}\n\n\treturn results;\n}\n\n/**\n * Print final summary of batch execution\n */\nfunction printSummary(summary: BatchExecutionSummary): 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 specName = result.spec.name || result.spec.input;\n\t\t\t\tconsole.error(` ✗ ${specName}`);\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 * Execute batch processing of multiple OpenAPI specs\n *\n * @param specs - Array of spec configurations to process\n * @param executionMode - Execution mode: \"parallel\" (default) or \"sequential\"\n * @returns BatchExecutionSummary with results\n * @throws Never throws - collects all errors and reports them\n */\nexport async function executeBatch(\n\tspecs: SpecConfig[],\n\texecutionMode: ExecutionMode = \"parallel\"\n): Promise<BatchExecutionSummary> {\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[] = [];\n\n\ttry {\n\t\t// Execute based on mode\n\t\tresults = executionMode === \"parallel\" ? await executeParallel(specs) : await executeSequential(specs);\n\n\t\t// Calculate summary\n\t\tconst summary: BatchExecutionSummary = {\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 > 10) {\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(summary: BatchExecutionSummary): number {\n\treturn summary.failed > 0 ? 1 : 0;\n}\n","/**\n * Branded type for file paths to prevent string confusion\n */\nexport type FilePath = string & { readonly __brand: \"FilePath\" };\n\n/**\n * Branded type for schema names\n */\nexport type SchemaName = string & { readonly __brand: \"SchemaName\" };\n\n/**\n * Type guards and factories for branded types\n */\nexport const FilePath = {\n\tfrom: (path: string): FilePath => path as FilePath,\n\tis: (value: unknown): value is FilePath => typeof value === \"string\" && value.length > 0,\n};\n\nexport const SchemaName = {\n\tfrom: (name: string): SchemaName => name as SchemaName,\n\tis: (value: unknown): value is SchemaName => typeof value === \"string\" && /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value),\n};\n\n/**\n * Type generation mode\n * - 'inferred': Generate Zod schemas with z.infer<typeof schema> types (default)\n * - 'native': Generate native TypeScript types without Zod schemas\n */\nexport type TypeMode = \"inferred\" | \"native\";\n\n/**\n * Native enum generation type (used when typeMode is 'native')\n * - 'union': Generate union types like 'a' | 'b' | 'c' (default)\n * - 'enum': Generate TypeScript enums like enum StatusEnum { A = 'a', B = 'b' }\n */\nexport type NativeEnumType = \"union\" | \"enum\";\n\n/**\n * Options that can be overridden per request/response context\n * These options override root-level options when specified.\n * Resolution order: root options → request/response overrides (nested wins silently)\n */\nexport interface RequestResponseOptions {\n\t/**\n\t * Object validation mode\n\t * - 'strict': Uses z.strictObject() - no additional properties allowed\n\t * - 'normal': Uses z.object() - additional properties allowed\n\t * - 'loose': Uses z.looseObject() - explicitly allows additional properties\n\t */\n\tmode?: \"strict\" | \"normal\" | \"loose\";\n\n\t/**\n\t * Enum generation type\n\t * - 'zod': Uses z.enum() with inferred types (default)\n\t * - 'typescript': Uses TypeScript enums with z.enum() referencing them\n\t */\n\tenumType?: \"zod\" | \"typescript\";\n\n\t/**\n\t * Whether to add .describe() calls for better error messages\n\t * @default false\n\t */\n\tuseDescribe?: boolean;\n\n\t/**\n\t * Whether to include descriptions as JSDoc comments\n\t */\n\tincludeDescriptions?: boolean;\n\n\t/**\n\t * Type generation mode (only for requests)\n\t * - 'inferred': Generate Zod schemas with z.infer types (default)\n\t * - 'native': Generate native TypeScript types\n\t */\n\ttypeMode?: TypeMode;\n\n\t/**\n\t * Native enum generation type (when typeMode is 'native')\n\t * - 'union': Generate union types (default)\n\t * - 'enum': Generate TypeScript enums\n\t */\n\tnativeEnumType?: NativeEnumType;\n}\n\nexport interface GeneratorOptions {\n\t/**\n\t * Object validation mode\n\t * - 'strict': Uses z.strictObject() - no additional properties allowed\n\t * - 'normal': Uses z.object() - additional properties allowed\n\t * - 'loose': Uses z.looseObject() - explicitly allows additional properties\n\t */\n\tmode?: \"strict\" | \"normal\" | \"loose\";\n\n\t/**\n\t * Input OpenAPI YAML file path\n\t */\n\tinput: string;\n\n\t/**\n\t * Output TypeScript file path\n\t * Optional when using string generation methods (generateString)\n\t * Required when calling generate() to write to a file\n\t */\n\toutput?: string;\n\n\t/**\n\t * Whether to include descriptions as JSDoc comments\n\t */\n\tincludeDescriptions?: boolean;\n\n\t/**\n\t * Enum generation type\n\t * - 'zod': Uses z.enum() with inferred types (default)\n\t * - 'typescript': Uses TypeScript enums with z.enum() referencing them\n\t */\n\tenumType?: \"zod\" | \"typescript\";\n\n\t/**\n\t * Whether to add .describe() calls for better error messages\n\t * @default false\n\t */\n\tuseDescribe?: boolean;\n\n\t/**\n\t * Schema filtering mode\n\t * - 'all': Generate all schemas (default)\n\t * - 'request': Only include schemas suitable for requests (excludes readOnly)\n\t * - 'response': Only include schemas suitable for responses (excludes writeOnly)\n\t */\n\tschemaType?: \"all\" | \"request\" | \"response\";\n\n\t/**\n\t * Prefix to add to all generated schema names\n\t * @example \"api\" -> \"apiUserSchema\"\n\t */\n\tprefix?: string;\n\n\t/**\n\t * Suffix to add before \"Schema\" in generated names\n\t * @example \"dto\" -> \"userDtoSchema\"\n\t */\n\tsuffix?: string;\n\n\t/**\n\t * Whether to include generation statistics in output file\n\t * @default true\n\t */\n\tshowStats?: boolean;\n\n\t/**\n\t * Native enum generation type (when typeMode is 'native')\n\t * - 'union': Generate union types (default)\n\t * - 'enum': Generate TypeScript enums with 'Enum' suffix\n\t * @default 'union'\n\t */\n\tnativeEnumType?: NativeEnumType;\n\n\t/**\n\t * Request-specific options that override root-level options\n\t * Applied when schemas are used in request contexts\n\t */\n\trequest?: Partial<RequestResponseOptions>;\n\n\t/**\n\t * Response-specific options that override root-level options\n\t * Applied when schemas are used in response contexts\n\t */\n\tresponse?: Partial<RequestResponseOptions>;\n}\n\nexport interface OpenAPISchema {\n\ttype?: string | string[];\n\tformat?: string;\n\tenum?: (string | number)[];\n\tconst?: string | number | boolean | null;\n\tproperties?: Record<string, OpenAPISchema>;\n\trequired?: string[];\n\titems?: OpenAPISchema;\n\tprefixItems?: OpenAPISchema[];\n\tallOf?: OpenAPISchema[];\n\toneOf?: OpenAPISchema[];\n\tanyOf?: OpenAPISchema[];\n\t$ref?: string;\n\tnullable?: boolean;\n\tminLength?: number;\n\tmaxLength?: number;\n\tminimum?: number;\n\tmaximum?: number;\n\texclusiveMinimum?: boolean | number;\n\texclusiveMaximum?: boolean | number;\n\tmultipleOf?: number;\n\tpattern?: string;\n\tdescription?: string;\n\ttitle?: string;\n\texample?: any;\n\texamples?: any[];\n\tadditionalProperties?: boolean | OpenAPISchema;\n\tminProperties?: number;\n\tmaxProperties?: number;\n\tminItems?: number;\n\tmaxItems?: number;\n\tuniqueItems?: boolean;\n\tcontains?: OpenAPISchema;\n\tminContains?: number;\n\tmaxContains?: number;\n\tdiscriminator?: {\n\t\tpropertyName: string;\n\t\tmapping?: Record<string, string>;\n\t};\n\treadOnly?: boolean;\n\twriteOnly?: boolean;\n\tdeprecated?: boolean;\n\tdependentRequired?: Record<string, string[]>;\n\tdependencies?: Record<string, string[] | OpenAPISchema>;\n\tpatternProperties?: Record<string, OpenAPISchema>;\n\tpropertyNames?: OpenAPISchema;\n\tcontentMediaType?: string;\n\tcontentEncoding?: string;\n\tnot?: OpenAPISchema;\n\tif?: OpenAPISchema;\n\tthen?: OpenAPISchema;\n\telse?: OpenAPISchema;\n\tunevaluatedProperties?: boolean | OpenAPISchema;\n\tunevaluatedItems?: boolean | OpenAPISchema;\n}\n\nexport interface OpenAPISpec {\n\tcomponents?: {\n\t\tschemas?: Record<string, OpenAPISchema>;\n\t};\n\tpaths?: Record<string, any>;\n}\n\n/**\n * Execution mode for batch processing\n * - 'parallel': Process all specs concurrently (default, faster)\n * - 'sequential': Process specs one at a time (safer for resource constraints)\n */\nexport type ExecutionMode = \"parallel\" | \"sequential\";\n\n/**\n * Configuration for a single OpenAPI spec\n * Extends GeneratorOptions with all the same properties\n */\nexport interface SpecConfig extends GeneratorOptions {\n\t/**\n\t * Optional name/identifier for this spec (for logging purposes)\n\t */\n\tname?: string;\n}\n\n/**\n * Root configuration file structure\n */\nexport interface ConfigFile {\n\t/**\n\t * Global default options applied to all specs\n\t * Can be overridden by individual spec configurations\n\t */\n\tdefaults?: Partial<Omit<GeneratorOptions, \"input\" | \"output\">>;\n\n\t/**\n\t * Array of OpenAPI specifications to process\n\t * Each spec must have input and output paths\n\t */\n\tspecs: SpecConfig[];\n\n\t/**\n\t * Execution mode for batch processing\n\t * @default \"parallel\"\n\t */\n\texecutionMode?: ExecutionMode;\n}\n\n/**\n * Resolved options for a specific schema context (request or response)\n * All optional fields from RequestResponseOptions are required here\n */\nexport interface ResolvedOptions {\n\tmode: \"strict\" | \"normal\" | \"loose\";\n\tenumType: \"zod\" | \"typescript\";\n\tuseDescribe: boolean;\n\tincludeDescriptions: boolean;\n\ttypeMode: TypeMode;\n\tnativeEnumType: NativeEnumType;\n}\n\n/**\n * Helper function for type-safe config file creation\n * Provides IDE autocomplete and type checking for config files\n *\n * @example\n * ```typescript\n * import { defineConfig } from '@cerios/openapi-to-zod';\n *\n * export default defineConfig({\n * defaults: {\n * mode: 'strict',\n * includeDescriptions: true\n * },\n * specs: [\n * { input: 'api-v1.yaml', output: 'schemas/v1.ts' },\n * { input: 'api-v2.yaml', output: 'schemas/v2.ts', mode: 'normal' }\n * ]\n * });\n * ```\n */\nexport function defineConfig(config: ConfigFile): ConfigFile {\n\treturn config;\n}\n","import { cosmiconfig, type Loader } from \"cosmiconfig\";\nimport { z } from \"zod\";\nimport type { ConfigFile, GeneratorOptions, SpecConfig } from \"../types\";\n\n/**\n * Zod schema for strict validation of config files\n * Rejects unknown properties to catch typos and invalid options\n */\nconst TypeModeSchema = z.enum([\"inferred\", \"native\"]);\nconst NativeEnumTypeSchema = z.enum([\"union\", \"enum\"]);\n\nconst RequestResponseOptionsSchema = z.strictObject({\n\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tuseDescribe: z.boolean().optional(),\n\tincludeDescriptions: z.boolean().optional(),\n\ttypeMode: TypeModeSchema.optional(),\n\tnativeEnumType: NativeEnumTypeSchema.optional(),\n});\n\nconst GeneratorOptionsSchema = z.strictObject({\n\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tinput: z.string(),\n\toutput: z.string(),\n\tincludeDescriptions: z.boolean().optional(),\n\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tuseDescribe: z.boolean().optional(),\n\tschemaType: z.enum([\"all\", \"request\", \"response\"]).optional(),\n\tprefix: z.string().optional(),\n\tsuffix: z.string().optional(),\n\tshowStats: z.boolean().optional(),\n\tnativeEnumType: NativeEnumTypeSchema.optional(),\n\trequest: RequestResponseOptionsSchema.optional(),\n\tresponse: RequestResponseOptionsSchema.optional(),\n\tname: z.string().optional(),\n});\n\nconst ConfigFileSchema = z.strictObject({\n\tdefaults: z\n\t\t.strictObject({\n\t\t\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\t\t\tincludeDescriptions: z.boolean().optional(),\n\t\t\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\t\t\tuseDescribe: z.boolean().optional(),\n\t\t\tschemaType: z.enum([\"all\", \"request\", \"response\"]).optional(),\n\t\t\tprefix: z.string().optional(),\n\t\t\tsuffix: z.string().optional(),\n\t\t\tshowStats: z.boolean().optional(),\n\t\t\tnativeEnumType: NativeEnumTypeSchema.optional(),\n\t\t\trequest: RequestResponseOptionsSchema.optional(),\n\t\t\tresponse: RequestResponseOptionsSchema.optional(),\n\t\t})\n\t\t.optional(),\n\tspecs: z.array(GeneratorOptionsSchema).min(1, \"At least one spec is required\"),\n\texecutionMode: z.enum([\"parallel\", \"sequential\"]).optional(),\n});\n\n/**\n * TypeScript loader using tsx for executing .ts config files\n * Uses Node's module._compile to execute TypeScript after transpiling with esbuild\n */\nconst 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\n/**\n * Load and validate configuration file\n * Supports: openapi-to-zod.config.{ts,json}, package.json under \"openapi-to-zod\" key\n *\n * @param configPath - Optional explicit path to config file. If not provided, searches automatically\n * @returns Validated ConfigFile object\n * @throws Error if config file not found, invalid, or contains unknown properties\n */\nexport async function loadConfig(configPath?: string): Promise<ConfigFile> {\n\tconst explorer = cosmiconfig(\"openapi-to-zod\", {\n\t\tsearchPlaces: [\"openapi-to-zod.config.ts\", \"openapi-to-zod.config.json\", \"package.json\"],\n\t\tloaders: {\n\t\t\t\".ts\": createTypeScriptLoader(),\n\t\t},\n\t});\n\n\tlet result: Awaited<ReturnType<typeof explorer.load>> | Awaited<ReturnType<typeof explorer.search>>;\n\n\tif (configPath) {\n\t\t// Load from explicit path (overrides auto-discovery)\n\t\tresult = await explorer.load(configPath);\n\t} else {\n\t\t// Auto-discover config file starting from cwd\n\t\tresult = await explorer.search();\n\t}\n\n\tif (!result || !result.config) {\n\t\tthrow new Error(\n\t\t\tconfigPath\n\t\t\t\t? `Config file not found at: ${configPath}`\n\t\t\t\t: \"No config file found. Searched for: openapi-to-zod.config.ts, openapi-to-zod.config.json, package.json (openapi-to-zod key)\"\n\t\t);\n\t}\n\n\t// Strict validation using Zod schema\n\ttry {\n\t\tconst validatedConfig = ConfigFileSchema.parse(result.config);\n\t\treturn validatedConfig;\n\t} catch (error) {\n\t\tif (error instanceof z.ZodError) {\n\t\t\tconst formattedErrors =\n\t\t\t\terror.issues\n\t\t\t\t\t?.map(err => {\n\t\t\t\t\t\tconst path = err.path.length > 0 ? err.path.join(\".\") : \"root\";\n\t\t\t\t\t\treturn ` - ${path}: ${err.message}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\") || \"Unknown validation error\";\n\n\t\t\tconst configSource = result.filepath || configPath || \"config file\";\n\t\t\tconst errorMessage = [\n\t\t\t\t`Invalid configuration file at: ${configSource}`,\n\t\t\t\t\"\",\n\t\t\t\t\"Validation errors:\",\n\t\t\t\tformattedErrors,\n\t\t\t\t\"\",\n\t\t\t\t\"Please check your configuration file and ensure:\",\n\t\t\t\t\" - All required fields are present (specs array with input/output)\",\n\t\t\t\t\" - Field names are spelled correctly (no typos)\",\n\t\t\t\t\" - Values match the expected types (e.g., mode: 'strict' | 'normal' | 'loose')\",\n\t\t\t\t\" - No unknown/extra properties are included\",\n\t\t\t].join(\"\\n\");\n\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Merge global defaults with per-spec configuration\n * CLI arguments have highest precedence and are merged separately in CLI layer\n *\n * @param config - Validated configuration file\n * @returns Array of fully resolved SpecConfig objects\n */\nexport function mergeConfigWithDefaults(config: ConfigFile): SpecConfig[] {\n\tif (!config?.specs || !Array.isArray(config.specs)) {\n\t\tthrow new Error(\"Invalid config: specs array is required\");\n\t}\n\n\tconst defaults = config.defaults || {};\n\n\treturn config.specs.map(spec => {\n\t\t// Deep merge: spec options override defaults\n\t\tconst merged: SpecConfig = {\n\t\t\t// Apply defaults first\n\t\t\tmode: defaults.mode,\n\t\t\tincludeDescriptions: defaults.includeDescriptions,\n\t\t\tenumType: defaults.enumType,\n\t\t\tuseDescribe: defaults.useDescribe,\n\t\t\tschemaType: defaults.schemaType,\n\t\t\tprefix: defaults.prefix,\n\t\t\tsuffix: defaults.suffix,\n\t\t\tshowStats: defaults.showStats,\n\n\t\t\t// Override with spec-specific values (including required input/output)\n\t\t\t...spec,\n\t\t};\n\n\t\treturn merged;\n\t});\n}\n\n/**\n * Merge CLI options with config options\n * CLI options have highest precedence and override both spec and default config\n *\n * @param specConfig - Configuration from config file (with defaults already applied)\n * @param cliOptions - Options provided via CLI arguments\n * @returns Merged GeneratorOptions with CLI taking precedence\n */\nexport function mergeCliWithConfig(specConfig: SpecConfig, cliOptions: Partial<GeneratorOptions>): GeneratorOptions {\n\t// CLI options override everything\n\treturn {\n\t\t...specConfig,\n\t\t...Object.fromEntries(Object.entries(cliOptions).filter(([_, v]) => v !== undefined)),\n\t} as GeneratorOptions;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uBAAwB;AACxB,IAAAA,cAAkB;;;ACKX,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;AAKO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACvD,YAAY,SAAiB,SAAmC;AAC/D,UAAM,SAAS,yBAAyB,OAAO;AAC/C,SAAK,OAAO;AAAA,EACb;AACD;AAKO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACtD,YACC,SACgB,UAChB,SACC;AACD,UAAM,SAAS,wBAAwB,EAAE,GAAG,SAAS,SAAS,CAAC;AAH/C;AAIhB,SAAK,OAAO;AAAA,EACb;AACD;AAmBO,IAAM,wBAAN,cAAoC,eAAe;AAAA,E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RequiredProps","generatePropertyAccess","definedProps","_a","isNullable","wrapNullable","module"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/errors.ts","../src/generator.ts","../src/utils/name-utils.ts","../src/generators/enum-generator.ts","../src/utils/string-utils.ts","../src/generators/jsdoc-generator.ts","../src/utils/lru-cache.ts","../src/validators/array-validator.ts","../src/validators/composition-validator.ts","../src/validators/number-validator.ts","../src/validators/conditional-validator.ts","../src/validators/object-validator.ts","../src/validators/string-validator.ts","../src/generators/property-generator.ts","../src/batch-executor.ts","../src/utils/config-loader.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport { z } from \"zod\";\nimport { executeBatch, getBatchExitCode } from \"./batch-executor\";\nimport { CliOptionsError } from \"./errors\";\nimport { ZodSchemaGenerator } from \"./generator\";\nimport type { ExecutionMode, GeneratorOptions } from \"./types\";\nimport { loadConfig, mergeCliWithConfig, mergeConfigWithDefaults } from \"./utils/config-loader\";\n\n/**\n * Zod schema for CLI options validation\n */\nconst CliOptionsSchema = z.object({\n\tconfig: z.string().optional(),\n\tinput: z.string().optional(),\n\toutput: z.string().optional(),\n\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tdescriptions: z.boolean().optional(),\n\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tuseDescribe: z.boolean().optional(),\n\tschemaType: z.enum([\"all\", \"request\", \"response\"]).optional(),\n\tprefix: z.string().optional(),\n\tsuffix: z.string().optional(),\n\tstats: z.boolean().optional(),\n\tnativeEnumType: z.enum([\"union\", \"enum\"]).optional(),\n\trequestMode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\trequestTypeMode: z.enum([\"inferred\", \"native\"]).optional(),\n\trequestEnumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\trequestNativeEnumType: z.enum([\"union\", \"enum\"]).optional(),\n\trequestUseDescribe: z.boolean().optional(),\n\trequestDescriptions: z.boolean().optional(),\n\tresponseMode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tresponseEnumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tresponseNativeEnumType: z.enum([\"union\", \"enum\"]).optional(),\n\tresponseUseDescribe: z.boolean().optional(),\n\tresponseDescriptions: z.boolean().optional(),\n\texecutionMode: z.enum([\"parallel\", \"sequential\"]).optional(),\n});\n\n/**\n * Validate CLI options using Zod schema\n */\nfunction validateCliOptions(options: unknown): asserts options is z.infer<typeof CliOptionsSchema> {\n\ttry {\n\t\tCliOptionsSchema.parse(options);\n\t} catch (error) {\n\t\tif (error instanceof z.ZodError) {\n\t\t\tconst formattedErrors = error.issues.map(err => ` --${err.path.join(\".\")}: ${err.message}`).join(\"\\n\");\n\t\t\tthrow new CliOptionsError(`Invalid CLI options:\\n${formattedErrors}`, { zodError: error });\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nconst program = new Command();\n\nprogram\n\t.name(\"openapi-to-zod\")\n\t.description(\"Generate Zod v4 schemas from OpenAPI specifications\")\n\t.version(\"1.0.0\")\n\t.option(\"-c, --config <path>\", \"Path to config file (openapi-to-zod.config.{ts,json})\")\n\t.option(\"-i, --input <path>\", \"Input OpenAPI YAML file path (single-spec mode)\")\n\t.option(\"-o, --output <path>\", \"Output TypeScript file path (single-spec mode)\")\n\t.option(\"-m, --mode <mode>\", \"Validation mode: strict, normal, or loose\", \"normal\")\n\t.option(\"--no-descriptions\", \"Exclude JSDoc descriptions from generated schemas\")\n\t.option(\"-e, --enum-type <type>\", \"Enum type: zod or typescript\", \"zod\")\n\t.option(\"--use-describe\", \"Add .describe() calls for better runtime error messages\")\n\t.option(\"-s, --schema-type <type>\", \"Schema type: all, request, or response\", \"all\")\n\t.option(\"-p, --prefix <prefix>\", \"Add prefix to all generated schema names\")\n\t.option(\"--suffix <suffix>\", \"Add suffix before 'Schema' in generated names\")\n\t.option(\"--no-stats\", \"Exclude generation statistics from output file\")\n\t.option(\"--native-enum-type <type>\", \"Native enum type: union or enum\", \"union\")\n\t.option(\"--request-mode <mode>\", \"Request validation mode: strict, normal, or loose\")\n\t.option(\"--request-type-mode <mode>\", \"Request type generation: inferred or native\")\n\t.option(\"--request-enum-type <type>\", \"Request enum type: zod or typescript\")\n\t.option(\"--request-native-enum-type <type>\", \"Request native enum type: union or enum\")\n\t.option(\"--request-use-describe\", \"Add .describe() calls for request schemas\")\n\t.option(\"--request-descriptions\", \"Include descriptions for request schemas\")\n\t.option(\"--no-request-descriptions\", \"Exclude descriptions for request schemas\")\n\t.option(\"--response-mode <mode>\", \"Response validation mode: strict, normal, or loose\")\n\t.option(\"--response-enum-type <type>\", \"Response enum type: zod or typescript\")\n\t.option(\"--response-native-enum-type <type>\", \"Response native enum type: union or enum\")\n\t.option(\"--response-use-describe\", \"Add .describe() calls for response schemas\")\n\t.option(\"--response-descriptions\", \"Include descriptions for response schemas\")\n\t.option(\"--no-response-descriptions\", \"Exclude descriptions for response schemas\")\n\t.option(\"--execution-mode <mode>\", \"Batch execution mode: parallel (default) or sequential\")\n\t.addHelpText(\n\t\t\"after\",\n\t\t`\nExamples:\n # Generate Zod schemas (default - always generates response schemas)\n $ openapi-to-zod -i openapi.yaml -o schemas.ts\n\n # Generate native TypeScript types for requests, Zod schemas for responses\n $ openapi-to-zod -i openapi.yaml -o types.ts --request-type-mode native\n\n # Generate with config file\n $ openapi-to-zod -c openapi-to-zod.config.ts\n`\n\t)\n\t.action(async options => {\n\t\ttry {\n\t\t\t// Validate CLI options\n\t\t\tvalidateCliOptions(options);\n\n\t\t\t// Check if config file mode or single-spec mode\n\t\t\tif (options.config || (!options.input && !options.output)) {\n\t\t\t\t// Config file mode (batch processing)\n\t\t\t\tawait executeBatchMode(options);\n\t\t\t} else {\n\t\t\t\t// Single-spec mode (original behavior)\n\t\t\t\tawait executeSingleSpecMode(options);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof CliOptionsError) {\n\t\t\t\tconsole.error(error.message);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tconsole.error(\"Error:\", error instanceof Error ? error.message : String(error));\n\t\t\tif (error instanceof Error && error.stack) {\n\t\t\t\tconsole.error(\"\\nStack trace:\", error.stack);\n\t\t\t}\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n\nprogram.parse();\n\n/**\n * Execute single-spec mode (original CLI behavior)\n */\nasync function executeSingleSpecMode(options: z.infer<typeof CliOptionsSchema>): Promise<void> {\n\tif (!options.input || !options.output) {\n\t\tthrow new CliOptionsError(\"Both --input and --output are required in single-spec mode\", {\n\t\t\tinput: options.input,\n\t\t\toutput: options.output,\n\t\t});\n\t}\n\n\tconst generatorOptions: GeneratorOptions = {\n\t\tinput: options.input,\n\t\toutput: options.output,\n\t\tmode: options.mode,\n\t\tincludeDescriptions: options.descriptions,\n\t\tenumType: options.enumType,\n\t\tuseDescribe: options.useDescribe || false,\n\t\tschemaType: options.schemaType || \"all\",\n\t\tprefix: options.prefix,\n\t\tsuffix: options.suffix,\n\t\tshowStats: options.stats ?? true,\n\t\tnativeEnumType: options.nativeEnumType,\n\t};\n\n\t// Build request options if any request-specific flags are set\n\tif (\n\t\toptions.requestMode ||\n\t\toptions.requestTypeMode ||\n\t\toptions.requestEnumType ||\n\t\toptions.requestNativeEnumType ||\n\t\toptions.requestUseDescribe ||\n\t\toptions.requestDescriptions !== undefined\n\t) {\n\t\tgeneratorOptions.request = {\n\t\t\tmode: options.requestMode,\n\t\t\ttypeMode: options.requestTypeMode,\n\t\t\tenumType: options.requestEnumType,\n\t\t\tnativeEnumType: options.requestNativeEnumType,\n\t\t\tuseDescribe: options.requestUseDescribe || undefined,\n\t\t\tincludeDescriptions: options.requestDescriptions,\n\t\t};\n\t}\n\n\t// Build response options if any response-specific flags are set\n\tif (\n\t\toptions.responseMode ||\n\t\toptions.responseEnumType ||\n\t\toptions.responseNativeEnumType ||\n\t\toptions.responseUseDescribe ||\n\t\toptions.responseDescriptions !== undefined\n\t) {\n\t\tgeneratorOptions.response = {\n\t\t\tmode: options.responseMode,\n\t\t\tenumType: options.responseEnumType,\n\t\t\tnativeEnumType: options.responseNativeEnumType,\n\t\t\tuseDescribe: options.responseUseDescribe || undefined,\n\t\t\tincludeDescriptions: options.responseDescriptions,\n\t\t};\n\t}\n\n\tconst generator = new ZodSchemaGenerator(generatorOptions);\n\tgenerator.generate();\n\tconsole.log(`✓ Successfully generated schemas at ${options.output}`);\n}\n\n/**\n * Execute batch mode from config file\n */\nasync function executeBatchMode(options: z.infer<typeof CliOptionsSchema>): Promise<void> {\n\t// Load config file\n\tconst config = await loadConfig(options.config);\n\n\t// Merge defaults with specs\n\tlet specs = mergeConfigWithDefaults(config);\n\n\t// Extract CLI options that can override config\n\tconst cliOverrides: Partial<GeneratorOptions> = {};\n\tif (options.mode && options.mode !== \"normal\") cliOverrides.mode = options.mode;\n\tif (options.descriptions !== undefined) cliOverrides.includeDescriptions = options.descriptions;\n\tif (options.enumType && options.enumType !== \"zod\") cliOverrides.enumType = options.enumType;\n\tif (options.useDescribe) cliOverrides.useDescribe = true;\n\tif (options.schemaType && options.schemaType !== \"all\") cliOverrides.schemaType = options.schemaType;\n\tif (options.prefix) cliOverrides.prefix = options.prefix;\n\tif (options.suffix) cliOverrides.suffix = options.suffix;\n\tif (options.stats !== undefined) cliOverrides.showStats = options.stats;\n\tif (options.nativeEnumType) cliOverrides.nativeEnumType = options.nativeEnumType;\n\n\t// Build request/response overrides from CLI\n\tif (\n\t\toptions.requestMode ||\n\t\toptions.requestTypeMode ||\n\t\toptions.requestEnumType ||\n\t\toptions.requestNativeEnumType ||\n\t\toptions.requestUseDescribe ||\n\t\toptions.requestDescriptions !== undefined\n\t) {\n\t\tcliOverrides.request = {\n\t\t\tmode: options.requestMode,\n\t\t\ttypeMode: options.requestTypeMode,\n\t\t\tenumType: options.requestEnumType,\n\t\t\tnativeEnumType: options.requestNativeEnumType,\n\t\t\tuseDescribe: options.requestUseDescribe,\n\t\t\tincludeDescriptions: options.requestDescriptions,\n\t\t};\n\t}\n\n\tif (\n\t\toptions.responseMode ||\n\t\toptions.responseEnumType ||\n\t\toptions.responseNativeEnumType ||\n\t\toptions.responseUseDescribe ||\n\t\toptions.responseDescriptions !== undefined\n\t) {\n\t\tcliOverrides.response = {\n\t\t\tmode: options.responseMode,\n\t\t\tenumType: options.responseEnumType,\n\t\t\tnativeEnumType: options.responseNativeEnumType,\n\t\t\tuseDescribe: options.responseUseDescribe,\n\t\t\tincludeDescriptions: options.responseDescriptions,\n\t\t};\n\t}\n\n\t// Apply CLI overrides to all specs if any CLI options were provided\n\tif (Object.keys(cliOverrides).length > 0) {\n\t\tspecs = specs.map(spec => mergeCliWithConfig(spec, cliOverrides));\n\t}\n\n\t// Determine execution mode\n\tconst executionMode: ExecutionMode = (options.executionMode as ExecutionMode) || config.executionMode || \"parallel\";\n\n\t// Execute batch\n\tconst summary = await executeBatch(specs, executionMode);\n\n\t// Exit with appropriate code\n\tconst exitCode = getBatchExitCode(summary);\n\tif (exitCode !== 0) {\n\t\tprocess.exit(exitCode);\n\t}\n}\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 { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { parse } from \"yaml\";\nimport { ConfigurationError, FileOperationError, SchemaGenerationError, SpecValidationError } from \"./errors\";\nimport { generateEnum } from \"./generators/enum-generator\";\nimport { generateJSDoc } from \"./generators/jsdoc-generator\";\nimport { PropertyGenerator } from \"./generators/property-generator\";\nimport type { GeneratorOptions, OpenAPISchema, OpenAPISpec, ResolvedOptions, TypeMode } from \"./types\";\nimport { resolveRef, toCamelCase, toPascalCase } from \"./utils/name-utils\";\n\ntype SchemaContext = \"request\" | \"response\" | \"both\";\n\nexport class ZodSchemaGenerator {\n\tprivate schemas: Map<string, string> = new Map();\n\tprivate types: Map<string, string> = new Map();\n\tprivate enums: Map<string, string> = new Map();\n\tprivate nativeEnums: Map<string, string> = new Map();\n\tprivate schemaDependencies: Map<string, Set<string>> = new Map();\n\tprivate options: GeneratorOptions;\n\tprivate spec: OpenAPISpec;\n\tprivate propertyGenerator: PropertyGenerator;\n\tprivate schemaUsageMap: Map<string, SchemaContext> = new Map();\n\tprivate schemaTypeModeMap: Map<string, TypeMode> = new Map();\n\tprivate requestOptions: ResolvedOptions;\n\tprivate responseOptions: ResolvedOptions;\n\tprivate needsZodImport = false;\n\n\tconstructor(options: GeneratorOptions) {\n\t\t// Validate input path early\n\t\tif (!options.input) {\n\t\t\tthrow new ConfigurationError(\"Input path is required\", { providedOptions: options });\n\t\t}\n\n\t\tthis.options = {\n\t\t\tmode: options.mode || \"normal\",\n\t\t\tinput: options.input,\n\t\t\toutput: options.output,\n\t\t\tincludeDescriptions: options.includeDescriptions ?? true,\n\t\t\tenumType: options.enumType || \"zod\",\n\t\t\tuseDescribe: options.useDescribe ?? false,\n\t\t\tschemaType: options.schemaType || \"all\",\n\t\t\tprefix: options.prefix,\n\t\t\tsuffix: options.suffix,\n\t\t\tshowStats: options.showStats ?? true,\n\t\t\tnativeEnumType: options.nativeEnumType || \"union\",\n\t\t\trequest: options.request,\n\t\t\tresponse: options.response,\n\t\t};\n\n\t\t// Validate input file exists\n\t\ttry {\n\t\t\tconst fs = require(\"node:fs\");\n\t\t\tif (!fs.existsSync(this.options.input)) {\n\t\t\t\tthrow new FileOperationError(`Input file not found: ${this.options.input}`, this.options.input);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FileOperationError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// If fs.existsSync fails for another reason, continue and let readFileSync throw\n\t\t}\n\n\t\ttry {\n\t\t\tconst yamlContent = readFileSync(this.options.input, \"utf-8\");\n\t\t\tthis.spec = parse(yamlContent);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tconst errorMessage = [\n\t\t\t\t\t`Failed to parse OpenAPI specification from: ${this.options.input}`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t`Error: ${error.message}`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Please ensure:\",\n\t\t\t\t\t\" - The file exists and is readable\",\n\t\t\t\t\t\" - The file contains valid YAML syntax\",\n\t\t\t\t\t\" - The file is a valid OpenAPI 3.x specification\",\n\t\t\t\t].join(\"\\n\");\n\t\t\t\tthrow new SpecValidationError(errorMessage, { filePath: this.options.input, originalError: error.message });\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tthis.validateSpec();\n\n\t\t// Resolve options for request and response contexts\n\t\tthis.requestOptions = this.resolveOptionsForContext(\"request\");\n\t\tthis.responseOptions = this.resolveOptionsForContext(\"response\");\n\n\t\t// Analyze schema usage to determine context (request/response/both)\n\t\tthis.analyzeSchemaUsage();\n\n\t\t// Determine typeMode for each schema based on usage context\n\t\tthis.determineSchemaTypeModes();\n\n\t\t// Initialize property generator with context\n\t\t// We'll update this dynamically based on schema context during generation\n\t\tthis.propertyGenerator = new PropertyGenerator({\n\t\t\tspec: this.spec,\n\t\t\tschemaDependencies: this.schemaDependencies,\n\t\t\tschemaType: this.options.schemaType || \"all\",\n\t\t\tmode: this.requestOptions.mode,\n\t\t\tincludeDescriptions: this.requestOptions.includeDescriptions,\n\t\t\tuseDescribe: this.requestOptions.useDescribe,\n\t\t\ttypeMode: this.requestOptions.typeMode,\n\t\t\tnativeEnumType: this.requestOptions.nativeEnumType,\n\t\t\tnamingOptions: {\n\t\t\t\tprefix: this.options.prefix,\n\t\t\t\tsuffix: this.options.suffix,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Generate schemas as a string (without writing to file)\n\t * @returns The generated TypeScript code as a string\n\t */\n\tgenerateString(): string {\n\t\tif (!this.spec.components?.schemas) {\n\t\t\tthrow new SpecValidationError(\"No schemas found in OpenAPI spec\", { filePath: this.options.input });\n\t\t}\n\n\t\t// First pass: generate enums\n\t\tfor (const [name, schema] of Object.entries(this.spec.components.schemas)) {\n\t\t\tif (schema.enum) {\n\t\t\t\tconst context = this.schemaUsageMap.get(name);\n\t\t\t\tconst resolvedOptions = context === \"response\" ? this.responseOptions : this.requestOptions;\n\n\t\t\t\t// For enums, use enumType option to determine generation strategy\n\t\t\t\tif (resolvedOptions.enumType === \"typescript\") {\n\t\t\t\t\t// Generate native TypeScript enum\n\t\t\t\t\tthis.generateNativeEnum(name, schema);\n\t\t\t\t} else {\n\t\t\t\t\t// Generate Zod enum - will create schema in second pass\n\t\t\t\t\tconst { enumCode } = generateEnum(name, schema.enum, {\n\t\t\t\t\t\tenumType: \"zod\",\n\t\t\t\t\t\tprefix: this.options.prefix,\n\t\t\t\t\t\tsuffix: this.options.suffix,\n\t\t\t\t\t});\n\t\t\t\t\tif (enumCode) {\n\t\t\t\t\t\tthis.enums.set(name, enumCode);\n\t\t\t\t\t\t// Mark that we need Zod import for enum schemas\n\t\t\t\t\t\tthis.needsZodImport = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Second pass: generate schemas/types and track dependencies\n\t\tfor (const [name, schema] of Object.entries(this.spec.components.schemas)) {\n\t\t\tthis.generateComponentSchema(name, schema);\n\t\t}\n\n\t\t// Third pass: generate query parameter schemas from path operations\n\t\tthis.generateQueryParameterSchemas();\n\n\t\t// Sort schemas by dependencies\n\t\tconst orderedSchemaNames = this.topologicalSort();\n\n\t\t// Build output\n\t\tconst output: string[] = [\"// Auto-generated by @cerios/openapi-to-zod\", \"// Do not edit this file manually\", \"\"];\n\n\t\t// Add statistics if enabled (must be explicitly true)\n\t\tif (this.options.showStats === true) {\n\t\t\toutput.push(...this.generateStats());\n\t\t\toutput.push(\"\");\n\t\t}\n\n\t\t// Conditionally import Zod only if needed\n\t\tif (this.needsZodImport) {\n\t\t\toutput.push('import { z } from \"zod\";');\n\t\t\toutput.push(\"\");\n\t\t}\n\n\t\t// Add native enums first (they have no dependencies and are referenced by value)\n\t\tif (this.nativeEnums.size > 0) {\n\t\t\toutput.push(\"// Native Enums\");\n\t\t\tfor (const enumCode of this.nativeEnums.values()) {\n\t\t\t\toutput.push(enumCode);\n\t\t\t\toutput.push(\"\");\n\t\t\t}\n\t\t}\n\n\t\t// Add schemas, types, and zod enums in dependency order (grouped by schema)\n\t\toutput.push(\"// Schemas and Types\");\n\t\tfor (const name of orderedSchemaNames) {\n\t\t\tconst enumCode = this.enums.get(name);\n\t\t\tconst schemaCode = this.schemas.get(name);\n\t\t\tconst typeCode = this.types.get(name);\n\n\t\t\tif (enumCode) {\n\t\t\t\t// Zod enum schema\n\t\t\t\toutput.push(enumCode);\n\t\t\t\toutput.push(\"\");\n\t\t\t} else if (schemaCode) {\n\t\t\t\t// Zod schema with inferred type\n\t\t\t\toutput.push(schemaCode);\n\n\t\t\t\t// Add type immediately after schema (if not already included)\n\t\t\t\tif (!schemaCode.includes(`export type ${name}`)) {\n\t\t\t\t\tconst schemaName = `${toCamelCase(name, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;\n\t\t\t\t\toutput.push(`export type ${name} = z.infer<typeof ${schemaName}>;`);\n\t\t\t\t}\n\n\t\t\t\toutput.push(\"\");\n\t\t\t} else if (typeCode) {\n\t\t\t\t// Native TypeScript type\n\t\t\t\toutput.push(typeCode);\n\t\t\t\toutput.push(\"\");\n\t\t\t}\n\t\t}\n\n\t\treturn output.join(\"\\n\");\n\t}\n\n\t/**\n\t * Ensure directory exists for a file path\n\t */\n\tprivate ensureDirectoryExists(filePath: string): void {\n\t\tconst dir = dirname(filePath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true });\n\t\t}\n\t}\n\n\t/**\n\t * Generate the complete output file\n\t */\n\tgenerate(): void {\n\t\tif (!this.options.output) {\n\t\t\tthrow new ConfigurationError(\n\t\t\t\t\"Output path is required when calling generate(). \" +\n\t\t\t\t\t\"Either provide an 'output' option or use generateString() to get the result as a string.\",\n\t\t\t\t{ hasOutput: false }\n\t\t\t);\n\t\t}\n\t\tconst output = this.generateString();\n\t\tthis.ensureDirectoryExists(this.options.output);\n\t\twriteFileSync(this.options.output, output);\n\t}\n\n\t/**\n\t * Resolve options for a specific context (request or response)\n\t * Nested options silently override root-level options\n\t * Response schemas always use 'inferred' mode (Zod schemas)\n\t */\n\tprivate resolveOptionsForContext(context: \"request\" | \"response\"): ResolvedOptions {\n\t\tconst contextOptions = context === \"request\" ? this.options.request : this.options.response;\n\n\t\treturn {\n\t\t\tmode: contextOptions?.mode ?? this.options.mode ?? \"normal\",\n\t\t\tenumType: contextOptions?.enumType ?? this.options.enumType ?? \"zod\",\n\t\t\tuseDescribe: contextOptions?.useDescribe ?? this.options.useDescribe ?? false,\n\t\t\tincludeDescriptions: contextOptions?.includeDescriptions ?? this.options.includeDescriptions ?? true,\n\t\t\t// Response schemas always use 'inferred' mode (Zod schemas are required)\n\t\t\t// Request schemas can optionally use 'native' mode\n\t\t\ttypeMode: context === \"response\" ? \"inferred\" : (contextOptions?.typeMode ?? \"inferred\"),\n\t\t\tnativeEnumType: contextOptions?.nativeEnumType ?? this.options.nativeEnumType ?? \"union\",\n\t\t};\n\t}\n\n\t/**\n\t * Analyze schema usage across the OpenAPI spec to determine if schemas\n\t * are used in request, response, or both contexts\n\t */\n\tprivate analyzeSchemaUsage(): void {\n\t\tconst requestSchemas = new Set<string>();\n\t\tconst responseSchemas = new Set<string>();\n\n\t\t// Analyze paths section if available\n\t\tif (this.spec.paths) {\n\t\t\tfor (const [, pathItem] of Object.entries(this.spec.paths)) {\n\t\t\t\tfor (const [, operation] of Object.entries(pathItem)) {\n\t\t\t\t\tif (typeof operation !== \"object\" || !operation) continue;\n\n\t\t\t\t\t// Check request bodies\n\t\t\t\t\tif (\n\t\t\t\t\t\t\"requestBody\" in operation &&\n\t\t\t\t\t\toperation.requestBody &&\n\t\t\t\t\t\ttypeof operation.requestBody === \"object\" &&\n\t\t\t\t\t\t\"content\" in operation.requestBody &&\n\t\t\t\t\t\toperation.requestBody.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tfor (const mediaType of Object.values(operation.requestBody.content)) {\n\t\t\t\t\t\t\tif (mediaType && typeof mediaType === \"object\" && \"schema\" in mediaType && mediaType.schema) {\n\t\t\t\t\t\t\t\tthis.extractSchemaRefs(mediaType.schema, requestSchemas);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check responses\n\t\t\t\t\tif (\"responses\" in operation && operation.responses && typeof operation.responses === \"object\") {\n\t\t\t\t\t\tfor (const response of Object.values(operation.responses)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tresponse &&\n\t\t\t\t\t\t\t\ttypeof response === \"object\" &&\n\t\t\t\t\t\t\t\t\"content\" in response &&\n\t\t\t\t\t\t\t\tresponse.content &&\n\t\t\t\t\t\t\t\ttypeof response.content === \"object\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfor (const mediaType of Object.values(response.content)) {\n\t\t\t\t\t\t\t\t\tif (mediaType && typeof mediaType === \"object\" && \"schema\" in mediaType && mediaType.schema) {\n\t\t\t\t\t\t\t\t\t\tthis.extractSchemaRefs(mediaType.schema, responseSchemas);\n\t\t\t\t\t\t\t\t\t}\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}\n\n\t\t\t\t\t// Check parameters\n\t\t\t\t\tif (\"parameters\" in operation && Array.isArray(operation.parameters)) {\n\t\t\t\t\t\tfor (const param of operation.parameters) {\n\t\t\t\t\t\t\tif (param && typeof param === \"object\" && \"schema\" in param && param.schema) {\n\t\t\t\t\t\t\t\tthis.extractSchemaRefs(param.schema, requestSchemas);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Expand to include all transitively referenced schemas\n\t\t\tthis.expandTransitiveReferences(requestSchemas);\n\t\t\tthis.expandTransitiveReferences(responseSchemas);\n\t\t}\n\n\t\t// Fallback: analyze readOnly/writeOnly properties if paths not available\n\t\tif (!this.spec.paths || (requestSchemas.size === 0 && responseSchemas.size === 0)) {\n\t\t\tfor (const [name, schema] of Object.entries(this.spec.components?.schemas || {})) {\n\t\t\t\tconst hasReadOnly = this.hasReadOnlyProperties(schema);\n\t\t\t\tconst hasWriteOnly = this.hasWriteOnlyProperties(schema);\n\n\t\t\t\tif (hasWriteOnly && !hasReadOnly) {\n\t\t\t\t\trequestSchemas.add(name);\n\t\t\t\t} else if (hasReadOnly && !hasWriteOnly) {\n\t\t\t\t\tresponseSchemas.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Build usage map with circular reference detection\n\t\tfor (const [name] of Object.entries(this.spec.components?.schemas || {})) {\n\t\t\tif (requestSchemas.has(name) && responseSchemas.has(name)) {\n\t\t\t\tthis.schemaUsageMap.set(name, \"both\");\n\t\t\t} else if (requestSchemas.has(name)) {\n\t\t\t\tthis.schemaUsageMap.set(name, \"request\");\n\t\t\t} else if (responseSchemas.has(name)) {\n\t\t\t\tthis.schemaUsageMap.set(name, \"response\");\n\t\t\t}\n\t\t\t// Unreferenced schemas are not added to map (will use root typeMode)\n\t\t}\n\n\t\t// Detect circular references and mark entire chain as \"both\"\n\t\tthis.detectCircularReferences();\n\t}\n\n\t/**\n\t * Expand a set of schemas to include all transitively referenced schemas\n\t */\n\tprivate expandTransitiveReferences(schemas: Set<string>): void {\n\t\tconst toProcess = Array.from(schemas);\n\t\tconst processed = new Set<string>();\n\n\t\twhile (toProcess.length > 0) {\n\t\t\tconst schemaName = toProcess.pop();\n\t\t\tif (!schemaName || processed.has(schemaName)) continue;\n\n\t\t\tprocessed.add(schemaName);\n\n\t\t\tconst schema = this.spec.components?.schemas?.[schemaName];\n\t\t\tif (schema) {\n\t\t\t\tconst refs = new Set<string>();\n\t\t\t\tthis.extractSchemaRefs(schema, refs);\n\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\tif (!schemas.has(ref)) {\n\t\t\t\t\t\tschemas.add(ref);\n\t\t\t\t\t\ttoProcess.push(ref);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Extract schema names from $ref and nested structures\n\t */\n\tprivate extractSchemaRefs(schema: any, refs: Set<string>): void {\n\t\tif (!schema) return;\n\n\t\tif (schema.$ref) {\n\t\t\tconst refName = resolveRef(schema.$ref);\n\t\t\trefs.add(refName);\n\t\t}\n\n\t\tif (schema.allOf) {\n\t\t\tfor (const subSchema of schema.allOf) {\n\t\t\t\tthis.extractSchemaRefs(subSchema, refs);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.oneOf) {\n\t\t\tfor (const subSchema of schema.oneOf) {\n\t\t\t\tthis.extractSchemaRefs(subSchema, refs);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.anyOf) {\n\t\t\tfor (const subSchema of schema.anyOf) {\n\t\t\t\tthis.extractSchemaRefs(subSchema, refs);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.items) {\n\t\t\tthis.extractSchemaRefs(schema.items, refs);\n\t\t}\n\n\t\tif (schema.properties) {\n\t\t\tfor (const prop of Object.values(schema.properties)) {\n\t\t\t\tthis.extractSchemaRefs(prop, refs);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Check if schema has readOnly properties\n\t */\n\tprivate hasReadOnlyProperties(schema: OpenAPISchema): boolean {\n\t\tif (schema.readOnly) return true;\n\t\tif (schema.properties) {\n\t\t\tfor (const prop of Object.values(schema.properties)) {\n\t\t\t\tif (this.hasReadOnlyProperties(prop)) return true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if schema has writeOnly properties\n\t */\n\tprivate hasWriteOnlyProperties(schema: OpenAPISchema): boolean {\n\t\tif (schema.writeOnly) return true;\n\t\tif (schema.properties) {\n\t\t\tfor (const prop of Object.values(schema.properties)) {\n\t\t\t\tif (this.hasWriteOnlyProperties(prop)) return true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Detect circular references and mark them as \"both\" context for safety\n\t */\n\tprivate detectCircularReferences(): void {\n\t\tconst visited = new Set<string>();\n\t\tconst recursionStack = new Set<string>();\n\n\t\tconst detectCycle = (name: string): boolean => {\n\t\t\tif (recursionStack.has(name)) {\n\t\t\t\t// Found a cycle - mark all schemas in the cycle as \"both\"\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (visited.has(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tvisited.add(name);\n\t\t\trecursionStack.add(name);\n\n\t\t\tconst schema = this.spec.components?.schemas?.[name];\n\t\t\tif (schema) {\n\t\t\t\tconst refs = new Set<string>();\n\t\t\t\tthis.extractSchemaRefs(schema, refs);\n\n\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\tif (detectCycle(ref)) {\n\t\t\t\t\t\t// Mark this schema as \"both\" since it's part of a circular chain\n\t\t\t\t\t\tthis.schemaUsageMap.set(name, \"both\");\n\t\t\t\t\t\trecursionStack.delete(name);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trecursionStack.delete(name);\n\t\t\treturn false;\n\t\t};\n\n\t\tfor (const name of Object.keys(this.spec.components?.schemas || {})) {\n\t\t\tdetectCycle(name);\n\t\t}\n\t}\n\n\t/**\n\t * Determine the typeMode for each schema based on its usage context\n\t * Response schemas always use 'inferred' mode\n\t */\n\tprivate determineSchemaTypeModes(): void {\n\t\tfor (const [name] of Object.entries(this.spec.components?.schemas || {})) {\n\t\t\tconst context = this.schemaUsageMap.get(name);\n\n\t\t\tif (context === \"request\") {\n\t\t\t\tthis.schemaTypeModeMap.set(name, this.requestOptions.typeMode);\n\t\t\t} else if (context === \"response\") {\n\t\t\t\t// Response schemas always use 'inferred' mode (Zod schemas are required)\n\t\t\t\tthis.schemaTypeModeMap.set(name, \"inferred\");\n\t\t\t} else if (context === \"both\") {\n\t\t\t\t// Safety: always use inferred for schemas used in both contexts\n\t\t\t\tthis.schemaTypeModeMap.set(name, \"inferred\");\n\t\t\t} else {\n\t\t\t\t// Unreferenced schemas default to inferred\n\t\t\t\tthis.schemaTypeModeMap.set(name, \"inferred\");\n\t\t\t}\n\n\t\t\t// Track if we need Zod import\n\t\t\tif (this.schemaTypeModeMap.get(name) === \"inferred\") {\n\t\t\t\tthis.needsZodImport = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Validate the OpenAPI specification\n\t */\n\tprivate validateSpec(): void {\n\t\tif (!this.spec.components?.schemas) {\n\t\t\tthrow new SpecValidationError(\n\t\t\t\t`No schemas found in OpenAPI spec at ${this.options.input}. Expected to find schemas at components.schemas`,\n\t\t\t\t{ filePath: this.options.input }\n\t\t\t);\n\t\t}\n\n\t\t// Validate all $refs can be resolved\n\t\tconst allSchemas = Object.keys(this.spec.components.schemas);\n\t\tfor (const [name, schema] of Object.entries(this.spec.components.schemas)) {\n\t\t\ttry {\n\t\t\t\tthis.validateSchemaRefs(name, schema, allSchemas);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\tthrow new SchemaGenerationError(`Invalid schema '${name}': ${error.message}`, name, {\n\t\t\t\t\t\toriginalError: error.message,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Validate all $ref references in a schema\n\t */\n\tprivate validateSchemaRefs(schemaName: string, schema: OpenAPISchema, allSchemas: string[], path = \"\"): void {\n\t\tif (schema.$ref) {\n\t\t\tconst refName = resolveRef(schema.$ref);\n\t\t\tif (!allSchemas.includes(refName)) {\n\t\t\t\tthrow new SpecValidationError(\n\t\t\t\t\t`Invalid reference${path ? ` at '${path}'` : \"\"}: ` +\n\t\t\t\t\t\t`'${schema.$ref}' points to non-existent schema '${refName}'`,\n\t\t\t\t\t{ schemaName, path, ref: schema.$ref, refName }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Recursively validate nested schemas\n\t\tif (schema.properties) {\n\t\t\tfor (const [propName, propSchema] of Object.entries(schema.properties)) {\n\t\t\t\tthis.validateSchemaRefs(schemaName, propSchema, allSchemas, path ? `${path}.${propName}` : propName);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.items) {\n\t\t\tthis.validateSchemaRefs(schemaName, schema.items, allSchemas, `${path}[]`);\n\t\t}\n\n\t\tif (schema.prefixItems) {\n\t\t\tschema.prefixItems.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.prefixItems[${i}]`);\n\t\t\t});\n\t\t}\n\n\t\tif (schema.allOf) {\n\t\t\tschema.allOf.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.allOf[${i}]`);\n\t\t\t});\n\t\t}\n\n\t\tif (schema.oneOf) {\n\t\t\tschema.oneOf.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.oneOf[${i}]`);\n\t\t\t});\n\t\t}\n\n\t\tif (schema.anyOf) {\n\t\t\tschema.anyOf.forEach((s, i) => {\n\t\t\t\tthis.validateSchemaRefs(schemaName, s, allSchemas, `${path}.anyOf[${i}]`);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Generate schema for a component\n\t */\n\tprivate generateComponentSchema(name: string, schema: OpenAPISchema): void {\n\t\t// Initialize dependencies for this schema\n\t\tif (!this.schemaDependencies.has(name)) {\n\t\t\tthis.schemaDependencies.set(name, new Set());\n\t\t}\n\n\t\t// Get the typeMode for this schema\n\t\tconst typeMode = this.schemaTypeModeMap.get(name) || \"inferred\";\n\t\tconst context = this.schemaUsageMap.get(name);\n\t\tconst resolvedOptions = context === \"response\" ? this.responseOptions : this.requestOptions;\n\n\t\t// Handle enums at the top level\n\t\tif (schema.enum) {\n\t\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\n\t\t\t// Use enumType to determine generation strategy\n\t\t\tif (resolvedOptions.enumType === \"typescript\") {\n\t\t\t\t// TypeScript enum - native enum was generated in first pass, now generate schema\n\t\t\t\tconst { schemaCode, typeCode } = generateEnum(name, schema.enum, {\n\t\t\t\t\tenumType: \"typescript\",\n\t\t\t\t\tprefix: this.options.prefix,\n\t\t\t\t\tsuffix: this.options.suffix,\n\t\t\t\t});\n\n\t\t\t\tconst enumSchemaCode = `${jsdoc}${schemaCode}\\n${typeCode}`;\n\t\t\t\tthis.schemas.set(name, enumSchemaCode);\n\t\t\t} else {\n\t\t\t\t// Zod enum\n\t\t\t\tconst { enumCode, schemaCode, typeCode } = generateEnum(name, schema.enum, {\n\t\t\t\t\tenumType: \"zod\",\n\t\t\t\t\tprefix: this.options.prefix,\n\t\t\t\t\tsuffix: this.options.suffix,\n\t\t\t\t});\n\n\t\t\t\tif (enumCode) {\n\t\t\t\t\tthis.enums.set(name, enumCode);\n\t\t\t\t}\n\n\t\t\t\tconst enumSchemaCode = `${jsdoc}${schemaCode}\\n${typeCode}`;\n\t\t\t\tthis.schemas.set(name, enumSchemaCode);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeMode === \"native\") {\n\t\t\t// Generate native TypeScript type\n\t\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\t\t\tconst jsdocWithConstraints = this.addConstraintsToJSDoc(jsdoc, schema, resolvedOptions.includeDescriptions);\n\t\t\tconst typeDefinition = this.generateNativeTypeDefinition(schema, name);\n\t\t\tconst typeCode = `${jsdocWithConstraints}export type ${name} = ${typeDefinition};`;\n\t\t\tthis.types.set(name, typeCode);\n\t\t} else {\n\t\t\t// Generate Zod schema\n\t\t\tconst schemaName = `${toCamelCase(name, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;\n\t\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\n\t\t\t// For allOf with single $ref, track dependency manually since we simplify it\n\t\t\tif (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref) {\n\t\t\t\tconst refName = resolveRef(schema.allOf[0].$ref);\n\t\t\t\tthis.schemaDependencies.get(name)?.add(refName);\n\t\t\t}\n\n\t\t\t// Update property generator context for this schema\n\t\t\tthis.propertyGenerator = new PropertyGenerator({\n\t\t\t\tspec: this.spec,\n\t\t\t\tschemaDependencies: this.schemaDependencies,\n\t\t\t\tschemaType: this.options.schemaType || \"all\",\n\t\t\t\tmode: resolvedOptions.mode,\n\t\t\t\tincludeDescriptions: resolvedOptions.includeDescriptions,\n\t\t\t\tuseDescribe: resolvedOptions.useDescribe,\n\t\t\t\ttypeMode: resolvedOptions.typeMode,\n\t\t\t\tnativeEnumType: resolvedOptions.nativeEnumType,\n\t\t\t\tnamingOptions: {\n\t\t\t\t\tprefix: this.options.prefix,\n\t\t\t\t\tsuffix: this.options.suffix,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Check if this is just a simple $ref (alias)\n\t\t\tconst isAlias = !!(schema.$ref && !schema.properties && !schema.allOf && !schema.oneOf && !schema.anyOf);\n\t\t\tconst zodSchema = this.propertyGenerator.generatePropertySchema(schema, name, isAlias);\n\t\t\tconst zodSchemaCode = `${jsdoc}export const ${schemaName} = ${zodSchema};`;\n\n\t\t\t// Track dependencies from discriminated unions\n\t\t\t// Extract schema references like \"carSchema, truckSchema\" from discriminatedUnion calls\n\t\t\tif (zodSchema.includes(\"z.discriminatedUnion(\")) {\n\t\t\t\tconst match = zodSchema.match(/z\\.discriminatedUnion\\([^,]+,\\s*\\[([^\\]]+)\\]/);\n\t\t\t\tif (match) {\n\t\t\t\t\tconst refs = match[1].split(\",\").map(ref => ref.trim());\n\t\t\t\t\tfor (const ref of refs) {\n\t\t\t\t\t\t// Extract schema name from camelCase reference (e.g., \"carSchema\" -> \"Car\")\n\t\t\t\t\t\tconst depMatch = ref.match(/^([a-z][a-zA-Z0-9]*?)Schema$/);\n\t\t\t\t\t\tif (depMatch) {\n\t\t\t\t\t\t\t// Convert camelCase to PascalCase (carSchema -> Car)\n\t\t\t\t\t\t\tconst depName = depMatch[1].charAt(0).toUpperCase() + depMatch[1].slice(1);\n\t\t\t\t\t\t\tthis.schemaDependencies.get(name)?.add(depName);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.schemas.set(name, zodSchemaCode);\n\t\t}\n\t}\n\n\t/**\n\t * Generate query parameter schemas for each operation\n\t */\n\tprivate generateQueryParameterSchemas(): void {\n\t\tif (!this.spec.paths) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const [_path, pathItem] of Object.entries(this.spec.paths)) {\n\t\t\tif (!pathItem || typeof pathItem !== \"object\") continue;\n\n\t\t\tconst methods = [\"get\", \"post\", \"put\", \"patch\", \"delete\", \"head\", \"options\"];\n\n\t\t\tfor (const method of methods) {\n\t\t\t\tconst operation = (pathItem as any)[method];\n\t\t\t\tif (!operation) continue;\n\n\t\t\t\t// Skip operations without operationId or parameters\n\t\t\t\tif (!operation.operationId || !operation.parameters || !Array.isArray(operation.parameters)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Filter for query parameters only\n\t\t\t\tconst queryParams = operation.parameters.filter(\n\t\t\t\t\t(param: any) => param && typeof param === \"object\" && param.in === \"query\"\n\t\t\t\t);\n\n\t\t\t\tif (queryParams.length === 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Generate schema name from operationId\n\t\t\t\t// Use toPascalCase only for kebab-case IDs, simple capitalization for camelCase\n\t\t\t\tconst pascalOperationId = operation.operationId.includes(\"-\")\n\t\t\t\t\t? toPascalCase(operation.operationId)\n\t\t\t\t\t: operation.operationId.charAt(0).toUpperCase() + operation.operationId.slice(1);\n\t\t\t\tconst schemaName = `${pascalOperationId}QueryParams`; // Initialize dependencies for this schema\n\t\t\t\tif (!this.schemaDependencies.has(schemaName)) {\n\t\t\t\t\tthis.schemaDependencies.set(schemaName, new Set());\n\t\t\t\t}\n\n\t\t\t\t// Build object schema properties\n\t\t\t\tconst properties: Record<string, string> = {};\n\t\t\t\tconst required: string[] = [];\n\n\t\t\t\tfor (const param of queryParams) {\n\t\t\t\t\tconst paramName = param.name;\n\t\t\t\t\tconst isRequired = param.required === true;\n\t\t\t\t\tconst paramSchema = param.schema;\n\n\t\t\t\t\tif (!paramSchema) continue;\n\n\t\t\t\t\t// Generate Zod schema for this parameter\n\t\t\t\t\tlet zodType = this.generateQueryParamType(paramSchema, param);\n\n\t\t\t\t\t// Handle arrays with serialization styles\n\t\t\t\t\tif (paramSchema.type === \"array\" && paramSchema.items) {\n\t\t\t\t\t\tconst itemType = this.generateQueryParamType(paramSchema.items, param);\n\n\t\t\t\t\t\t// Note: Query param arrays are sent as strings and need to be split on the client side\n\t\t\t\t\t\t// The style is documented but validation is for the array type\n\t\t\t\t\t\tzodType = `z.array(${itemType})`;\n\n\t\t\t\t\t\t// Description is handled by addDescription below\n\t\t\t\t\t} // Add description if available (before .optional())\n\t\t\t\t\tif (param.description && this.requestOptions.includeDescriptions) {\n\t\t\t\t\t\tif (this.requestOptions.useDescribe) {\n\t\t\t\t\t\t\tzodType = `${zodType}.describe(${JSON.stringify(param.description)})`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Make optional if not required (don't add defaults)\n\t\t\t\t\tif (!isRequired) {\n\t\t\t\t\t\tzodType = `${zodType}.optional()`;\n\t\t\t\t\t}\n\n\t\t\t\t\tproperties[paramName] = zodType;\n\t\t\t\t\tif (isRequired) {\n\t\t\t\t\t\trequired.push(paramName);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Track dependencies from schema references\n\t\t\t\t\tif (paramSchema.$ref) {\n\t\t\t\t\t\tconst refName = resolveRef(paramSchema.$ref);\n\t\t\t\t\t\tthis.schemaDependencies.get(schemaName)?.add(refName);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Generate the object schema code\n\t\t\t\tconst objectMode = this.requestOptions.mode;\n\t\t\t\tconst zodMethod = objectMode === \"strict\" ? \"strictObject\" : objectMode === \"loose\" ? \"looseObject\" : \"object\";\n\n\t\t\t\tconst propsCode = Object.entries(properties)\n\t\t\t\t\t.map(([key, value]) => {\n\t\t\t\t\t\t// Quote property names that contain special characters or are not valid identifiers\n\t\t\t\t\t\tconst needsQuotes = !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);\n\t\t\t\t\t\tconst quotedKey = needsQuotes ? `\"${key}\"` : key;\n\t\t\t\t\t\treturn ` ${quotedKey}: ${value}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\",\\n\");\n\n\t\t\t\tconst schemaCode = `z.${zodMethod}({\\n${propsCode}\\n})`; // Apply prefix/suffix to the operation name only, then add QueryParams and Schema\n\t\t\t\tconst operationName = pascalOperationId; // Already PascalCase\n\t\t\t\tconst prefixedName = this.options.prefix\n\t\t\t\t\t? `${toPascalCase(this.options.prefix)}${operationName}`\n\t\t\t\t\t: operationName;\n\t\t\t\tconst suffixedName = this.options.suffix ? `${prefixedName}${toPascalCase(this.options.suffix)}` : prefixedName;\n\t\t\t\tconst camelCaseSchemaName = `${suffixedName.charAt(0).toLowerCase() + suffixedName.slice(1)}QueryParamsSchema`;\n\n\t\t\t\t// Generate JSDoc\n\t\t\t\tconst jsdoc = `/**\\n * Query parameters for ${operation.operationId}\\n */\\n`;\n\t\t\t\tconst fullSchemaCode = `${jsdoc}export const ${camelCaseSchemaName} = ${schemaCode};`;\n\n\t\t\t\tthis.schemas.set(schemaName, fullSchemaCode);\n\t\t\t\tthis.needsZodImport = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Generate Zod type for a query parameter schema\n\t */\n\tprivate generateQueryParamType(schema: OpenAPISchema, param: any): string {\n\t\t// Handle references\n\t\tif (schema.$ref) {\n\t\t\tconst refName = resolveRef(schema.$ref);\n\t\t\tconst schemaName = toCamelCase(refName, { prefix: this.options.prefix, suffix: this.options.suffix });\n\t\t\treturn `${schemaName}Schema`;\n\t\t}\n\n\t\t// Handle enums\n\t\tif (schema.enum) {\n\t\t\tconst enumValues = schema.enum.map(v => (typeof v === \"string\" ? `\"${v}\"` : v)).join(\", \");\n\t\t\treturn `z.enum([${enumValues}])`;\n\t\t}\n\n\t\t// Handle primitive types\n\t\tconst type = schema.type;\n\n\t\tif (type === \"string\") {\n\t\t\tlet zodType = \"z.string()\";\n\t\t\t// Add string validations\n\t\t\tif (schema.minLength !== undefined) zodType = `${zodType}.min(${schema.minLength})`;\n\t\t\tif (schema.maxLength !== undefined) zodType = `${zodType}.max(${schema.maxLength})`;\n\t\t\tif (schema.pattern) zodType = `${zodType}.regex(/${schema.pattern}/)`;\n\t\t\tif (schema.format === \"email\") zodType = `${zodType}.email()`;\n\t\t\tif (schema.format === \"uri\" || schema.format === \"url\") zodType = `${zodType}.url()`;\n\t\t\tif (schema.format === \"uuid\") zodType = `${zodType}.uuid()`;\n\t\t\treturn zodType;\n\t\t}\n\n\t\tif (type === \"number\" || type === \"integer\") {\n\t\t\tlet zodType = type === \"integer\" ? \"z.number().int()\" : \"z.number()\";\n\t\t\t// Add number validations\n\t\t\tif (schema.minimum !== undefined) {\n\t\t\t\tzodType = schema.exclusiveMinimum ? `${zodType}.gt(${schema.minimum})` : `${zodType}.gte(${schema.minimum})`;\n\t\t\t}\n\t\t\tif (schema.maximum !== undefined) {\n\t\t\t\tzodType = schema.exclusiveMaximum ? `${zodType}.lt(${schema.maximum})` : `${zodType}.lte(${schema.maximum})`;\n\t\t\t}\n\t\t\treturn zodType;\n\t\t}\n\n\t\tif (type === \"boolean\") {\n\t\t\treturn \"z.boolean()\";\n\t\t}\n\n\t\tif (type === \"array\" && schema.items) {\n\t\t\tconst itemType = this.generateQueryParamType(schema.items, param);\n\t\t\tlet arrayType = `z.array(${itemType})`;\n\t\t\t// Add array validations\n\t\t\tif (schema.minItems !== undefined) arrayType = `${arrayType}.min(${schema.minItems})`;\n\t\t\tif (schema.maxItems !== undefined) arrayType = `${arrayType}.max(${schema.maxItems})`;\n\t\t\treturn arrayType;\n\t\t}\n\n\t\t// Fallback to z.unknown() for unhandled types\n\t\treturn \"z.unknown()\";\n\t}\n\n\t/**\n\t * Generate native TypeScript enum\n\t */\n\tprivate generateNativeEnum(name: string, schema: OpenAPISchema): void {\n\t\tif (!schema.enum) return;\n\n\t\tconst context = this.schemaUsageMap.get(name);\n\t\tconst resolvedOptions = context === \"response\" ? this.responseOptions : this.requestOptions;\n\t\tconst jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });\n\n\t\tif (resolvedOptions.nativeEnumType === \"enum\") {\n\t\t\t// Generate TypeScript enum with Enum suffix (no prefix/suffix)\n\t\t\tconst enumName = `${name}Enum`;\n\t\t\tconst members = schema.enum\n\t\t\t\t.map(value => {\n\t\t\t\t\tconst key = typeof value === \"string\" ? this.toEnumKey(value) : `N${value}`;\n\t\t\t\t\tconst val = typeof value === \"string\" ? `\"${value}\"` : value;\n\t\t\t\t\treturn ` ${key} = ${val}`;\n\t\t\t\t})\n\t\t\t\t.join(\",\\n\");\n\n\t\t\tconst enumCode = `${jsdoc}export enum ${enumName} {\\n${members}\\n}`;\n\t\t\tthis.nativeEnums.set(name, enumCode);\n\n\t\t\t// Also create a type alias for convenience\n\t\t\tconst typeCode = `export type ${name} = ${enumName};`;\n\t\t\tthis.types.set(name, typeCode);\n\t\t} else {\n\t\t\t// Generate union type\n\t\t\tconst unionType = schema.enum.map(v => (typeof v === \"string\" ? `\"${v}\"` : v)).join(\" | \");\n\t\t\tconst typeCode = `${jsdoc}export type ${name} = ${unionType};`;\n\t\t\tthis.types.set(name, typeCode);\n\t\t}\n\t}\n\n\t/**\n\t * Convert string to valid enum key\n\t */\n\tprivate toEnumKey(value: string): string {\n\t\t// Convert to PascalCase and ensure it starts with a letter\n\t\tconst cleaned = value.replace(/[^a-zA-Z0-9]/g, \"_\");\n\t\tconst pascalCase = cleaned\n\t\t\t.split(\"_\")\n\t\t\t.map(part => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())\n\t\t\t.join(\"\");\n\t\treturn pascalCase || \"Value\";\n\t}\n\n\t/**\n\t * Add constraint annotations to JSDoc for native types\n\t */\n\tprivate addConstraintsToJSDoc(jsdoc: string, schema: OpenAPISchema, includeDescriptions: boolean): string {\n\t\tif (!includeDescriptions) return jsdoc;\n\n\t\tconst constraints: string[] = [];\n\n\t\tif (schema.minLength !== undefined) constraints.push(`@minLength ${schema.minLength}`);\n\t\tif (schema.maxLength !== undefined) constraints.push(`@maxLength ${schema.maxLength}`);\n\t\tif (schema.pattern) constraints.push(`@pattern ${schema.pattern}`);\n\t\tif (schema.minimum !== undefined) constraints.push(`@minimum ${schema.minimum}`);\n\t\tif (schema.maximum !== undefined) constraints.push(`@maximum ${schema.maximum}`);\n\t\tif (schema.minItems !== undefined) constraints.push(`@minItems ${schema.minItems}`);\n\t\tif (schema.maxItems !== undefined) constraints.push(`@maxItems ${schema.maxItems}`);\n\t\tif (schema.minProperties !== undefined) constraints.push(`@minProperties ${schema.minProperties}`);\n\t\tif (schema.maxProperties !== undefined) constraints.push(`@maxProperties ${schema.maxProperties}`);\n\t\tif (schema.multipleOf !== undefined) constraints.push(`@multipleOf ${schema.multipleOf}`);\n\t\tif (schema.format) constraints.push(`@format ${schema.format}`);\n\n\t\tif (constraints.length === 0) return jsdoc;\n\n\t\t// If there's already a JSDoc, add constraints to it\n\t\tif (jsdoc) {\n\t\t\tconst lines = jsdoc.trim().split(\"\\n\");\n\t\t\tif (lines[0] === \"/**\" && lines[lines.length - 1] === \" */\") {\n\t\t\t\t// Multi-line JSDoc\n\t\t\t\tconst newLines = [...lines.slice(0, -1), ...constraints.map(c => ` * ${c}`), \" */\\n\"];\n\t\t\t\treturn newLines.join(\"\\n\");\n\t\t\t}\n\t\t\t// Single-line JSDoc\n\t\t\tconst content = jsdoc.replace(\"/** \", \"\").replace(\" */\\n\", \"\");\n\t\t\treturn `/**\\n * ${content}\\n${constraints.map(c => ` * ${c}`).join(\"\\n\")}\\n */\\n`;\n\t\t}\n\n\t\t// No existing JSDoc, create new one with just constraints\n\t\treturn `/**\\n${constraints.map(c => ` * ${c}`).join(\"\\n\")}\\n */\\n`;\n\t}\n\n\t/**\n\t * Generate native TypeScript type definition from OpenAPI schema\n\t */\n\tprivate generateNativeTypeDefinition(schema: OpenAPISchema, _schemaName?: string): string {\n\t\t// Handle $ref\n\t\tif (schema.$ref) {\n\t\t\treturn resolveRef(schema.$ref);\n\t\t}\n\n\t\t// Handle const\n\t\tif (schema.const !== undefined) {\n\t\t\treturn typeof schema.const === \"string\" ? `\"${schema.const}\"` : String(schema.const);\n\t\t}\n\n\t\t// Handle nullable\n\t\tconst isNullable = schema.nullable || (Array.isArray(schema.type) && schema.type.includes(\"null\"));\n\t\tconst wrapNullable = (type: string) => (isNullable ? `(${type}) | null` : type);\n\n\t\t// Get primary type\n\t\tconst primaryType = Array.isArray(schema.type) ? schema.type.find(t => t !== \"null\") : schema.type;\n\n\t\t// Handle different types\n\t\tswitch (primaryType) {\n\t\t\tcase \"string\":\n\t\t\t\treturn wrapNullable(\"string\");\n\t\t\tcase \"number\":\n\t\t\tcase \"integer\":\n\t\t\t\treturn wrapNullable(\"number\");\n\t\t\tcase \"boolean\":\n\t\t\t\treturn wrapNullable(\"boolean\");\n\t\t\tcase \"array\":\n\t\t\t\tif (schema.items) {\n\t\t\t\t\tconst itemType = this.generateNativeTypeDefinition(schema.items);\n\t\t\t\t\treturn wrapNullable(`${itemType}[]`);\n\t\t\t\t}\n\t\t\t\treturn wrapNullable(\"unknown[]\");\n\t\t\tcase \"object\":\n\t\t\t\treturn wrapNullable(this.generateObjectType(schema));\n\t\t\tdefault:\n\t\t\t\t// Handle composition schemas\n\t\t\t\tif (schema.allOf) {\n\t\t\t\t\tconst types = schema.allOf.map(s => this.generateNativeTypeDefinition(s));\n\t\t\t\t\treturn wrapNullable(types.join(\" & \"));\n\t\t\t\t}\n\t\t\t\tif (schema.oneOf || schema.anyOf) {\n\t\t\t\t\tconst schemas = schema.oneOf || schema.anyOf || [];\n\t\t\t\t\tconst types = schemas.map(s => this.generateNativeTypeDefinition(s));\n\t\t\t\t\treturn wrapNullable(types.join(\" | \"));\n\t\t\t\t}\n\t\t\t\treturn wrapNullable(\"unknown\");\n\t\t}\n\t}\n\n\t/**\n\t * Generate TypeScript object type definition\n\t */\n\tprivate generateObjectType(schema: OpenAPISchema): string {\n\t\tif (!schema.properties || Object.keys(schema.properties).length === 0) {\n\t\t\treturn \"Record<string, unknown>\";\n\t\t}\n\n\t\tconst context = this.schemaUsageMap.get(schema.$ref ? resolveRef(schema.$ref) : \"\");\n\t\tconst resolvedOptions = context === \"response\" ? this.responseOptions : this.requestOptions;\n\t\tconst required = new Set(schema.required || []);\n\t\tconst props: string[] = [];\n\n\t\tfor (const [propName, propSchema] of Object.entries(schema.properties)) {\n\t\t\tconst propType = this.generateNativeTypeDefinition(propSchema);\n\t\t\tconst optional = !required.has(propName) ? \"?\" : \"\";\n\n\t\t\t// Generate JSDoc with constraints\n\t\t\tlet propJsdoc = generateJSDoc(propSchema, propName, { includeDescriptions: resolvedOptions.includeDescriptions });\n\t\t\tif (resolvedOptions.includeDescriptions && !propJsdoc) {\n\t\t\t\t// Add constraint-only JSDoc if no description exists\n\t\t\t\tpropJsdoc = this.addConstraintsToJSDoc(\"\", propSchema, resolvedOptions.includeDescriptions);\n\t\t\t} else if (propJsdoc && resolvedOptions.includeDescriptions) {\n\t\t\t\t// Add constraints to existing JSDoc\n\t\t\t\tpropJsdoc = this.addConstraintsToJSDoc(propJsdoc, propSchema, resolvedOptions.includeDescriptions);\n\t\t\t}\n\n\t\t\tif (propJsdoc) {\n\t\t\t\t// Remove trailing newline for inline property JSDoc\n\t\t\t\tconst cleanJsdoc = propJsdoc.trimEnd();\n\t\t\t\tprops.push(` ${cleanJsdoc}\\n ${propName}${optional}: ${propType};`);\n\t\t\t} else {\n\t\t\t\tprops.push(` ${propName}${optional}: ${propType};`);\n\t\t\t}\n\t\t}\n\n\t\treturn `{\\n${props.join(\"\\n\")}\\n}`;\n\t}\n\n\t/**\n\t * Topological sort for schema dependencies\n\t * Returns schemas in the order they should be declared\n\t */\n\tprivate topologicalSort(): string[] {\n\t\tconst sorted: string[] = [];\n\t\tconst visited = new Set<string>();\n\t\tconst visiting = new Set<string>();\n\t\tconst aliases: string[] = [];\n\t\tconst circularDeps = new Set<string>(); // Track schemas involved in circular dependencies\n\n\t\t// Performance optimization: Cache schema and type code lookups\n\t\tconst codeCache = new Map<string, string>();\n\t\tfor (const [name, code] of this.enums) {\n\t\t\tcodeCache.set(name, code);\n\t\t}\n\t\tfor (const [name, code] of this.schemas) {\n\t\t\tcodeCache.set(name, code);\n\t\t}\n\t\tfor (const [name, code] of this.types) {\n\t\t\tcodeCache.set(name, code);\n\t\t}\n\n\t\tconst visit = (name: string): void => {\n\t\t\tif (visited.has(name)) return;\n\n\t\t\t// Detect circular dependencies\n\t\t\tif (visiting.has(name)) {\n\t\t\t\t// Mark this as a circular dependency but don't add it yet\n\t\t\t\tcircularDeps.add(name);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvisiting.add(name);\n\n\t\t\t// Check if this is a simple alias (just assigns another schema directly)\n\t\t\tconst code = codeCache.get(name) || \"\";\n\t\t\tconst isSimpleAlias =\n\t\t\t\tcode.match(/= (\\w+Schema);$/) !== null &&\n\t\t\t\t!code.includes(\"z.object\") &&\n\t\t\t\t!code.includes(\"z.enum\") &&\n\t\t\t\t!code.includes(\"z.union\") &&\n\t\t\t\t!code.includes(\"z.array\") &&\n\t\t\t\t!code.includes(\".and(\");\n\n\t\t\tif (isSimpleAlias) {\n\t\t\t\t// For simple aliases, just mark as visited and add to aliases list\n\t\t\t\tvisiting.delete(name);\n\t\t\t\tvisited.add(name);\n\t\t\t\taliases.push(name);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Visit dependencies first for non-alias schemas\n\t\t\tconst deps = this.schemaDependencies.get(name);\n\t\t\tif (deps && deps.size > 0) {\n\t\t\t\tfor (const dep of deps) {\n\t\t\t\t\tif (this.enums.has(dep) || this.schemas.has(dep) || this.types.has(dep)) {\n\t\t\t\t\t\tvisit(dep);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvisiting.delete(name);\n\t\t\tvisited.add(name);\n\n\t\t\t// Don't add circular dependencies yet - they need special handling\n\t\t\tif (!circularDeps.has(name)) {\n\t\t\t\tsorted.push(name);\n\t\t\t}\n\t\t};\n\n\t\t// Visit all enums, schemas and types\n\t\tconst allNames = new Set([...this.enums.keys(), ...this.schemas.keys(), ...this.types.keys()]);\n\t\tfor (const name of allNames) {\n\t\t\tvisit(name);\n\t\t}\n\n\t\t// Add circular dependencies at the end (before aliases)\n\t\t// This ensures they come after their non-circular dependencies\n\t\tfor (const name of circularDeps) {\n\t\t\tif (!visited.has(name)) {\n\t\t\t\tsorted.push(name);\n\t\t\t\tvisited.add(name);\n\t\t\t}\n\t\t}\n\n\t\t// Add aliases at the end\n\t\treturn [...sorted, ...aliases];\n\t}\n\n\t/**\n\t * Generate statistics about the generated schemas\n\t */\n\tprivate generateStats(): string[] {\n\t\tconst stats = {\n\t\t\ttotalSchemas: this.schemas.size,\n\t\t\tenums: this.enums.size,\n\t\t\twithCircularRefs: 0,\n\t\t\twithDiscriminators: 0,\n\t\t\twithConstraints: 0,\n\t\t};\n\n\t\t// Count schemas with special features\n\t\tfor (const code of this.schemas.values()) {\n\t\t\tif (code.includes(\"z.lazy(\")) stats.withCircularRefs++;\n\t\t\tif (code.includes(\"z.discriminatedUnion\")) stats.withDiscriminators++;\n\t\t\tif (code.includes(\".min(\") || code.includes(\".max(\") || code.includes(\".gte(\")) {\n\t\t\t\tstats.withConstraints++;\n\t\t\t}\n\t\t}\n\n\t\treturn [\n\t\t\t\"// Generation Statistics:\",\n\t\t\t`// Total schemas: ${stats.totalSchemas}`,\n\t\t\t`// Enums: ${stats.enums}`,\n\t\t\t`// Circular references: ${stats.withCircularRefs}`,\n\t\t\t`// Discriminated unions: ${stats.withDiscriminators}`,\n\t\t\t`// With constraints: ${stats.withConstraints}`,\n\t\t\t`// Generated at: ${new Date().toISOString()}`,\n\t\t];\n\t}\n}\n","/**\n * Name conversion utilities\n */\n\nexport interface NamingOptions {\n\tprefix?: string;\n\tsuffix?: string;\n}\n\n/**\n * Convert schema name to camelCase with optional prefix/suffix\n */\nexport function toCamelCase(str: string, options?: NamingOptions): string {\n\tlet name = str.charAt(0).toLowerCase() + str.slice(1);\n\n\t// Add prefix\n\tif (options?.prefix) {\n\t\tconst prefix = options.prefix.toLowerCase();\n\t\tname = prefix + name.charAt(0).toUpperCase() + name.slice(1);\n\t}\n\n\t// Add suffix before \"Schema\"\n\tif (options?.suffix) {\n\t\tconst suffix = options.suffix;\n\t\tname = name + suffix.charAt(0).toUpperCase() + suffix.slice(1).toLowerCase();\n\t}\n\n\treturn name;\n}\n\n/**\n * Convert enum value to PascalCase and sanitize for TypeScript enum keys\n */\nexport function toPascalCase(str: string | number): string {\n\tconst stringValue = String(str);\n\t// Replace ALL special characters (not just dots/spaces) with underscores, then convert to PascalCase\n\t// Valid identifier chars: letters, digits, underscore. Everything else becomes underscore.\n\tlet result = stringValue\n\t\t.replace(/[^a-zA-Z0-9_]+/g, \"_\") // Replace all non-identifier chars with underscore\n\t\t.split(/[-_]+/)\n\t\t.filter(word => word.length > 0) // Remove empty parts\n\t\t.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\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\tresult = \"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 type { NamingOptions } from \"../utils/name-utils\";\nimport { toCamelCase, toPascalCase } from \"../utils/name-utils\";\n\nexport type EnumType = \"zod\" | \"typescript\";\n\nexport interface EnumGeneratorOptions extends NamingOptions {\n\tenumType: EnumType;\n}\n\nexport interface EnumResult {\n\tenumCode: string | null;\n\tschemaCode: string;\n\ttypeCode: string;\n}\n\n/**\n * Generate enum as TypeScript enum or Zod enum\n */\nexport function generateEnum(name: string, values: (string | number)[], options: EnumGeneratorOptions): EnumResult {\n\tconst enumName = name.endsWith(\"EnumOptions\") ? name.replace(\"EnumOptions\", \"Enum\") : `${name}Enum`;\n\tconst schemaName = `${toCamelCase(name, options)}Schema`;\n\n\tif (options.enumType === \"typescript\") {\n\t\t// Generate TypeScript enum\n\t\tconst usedKeys = new Set<string>();\n\t\tconst enumEntries = values\n\t\t\t.map(value => {\n\t\t\t\tlet key = toPascalCase(value);\n\n\t\t\t\t// Handle duplicate keys by appending a suffix\n\t\t\t\tif (usedKeys.has(key)) {\n\t\t\t\t\tlet counter = 2;\n\t\t\t\t\twhile (usedKeys.has(`${key}${counter}`)) {\n\t\t\t\t\t\tcounter++;\n\t\t\t\t\t}\n\t\t\t\t\tkey = `${key}${counter}`;\n\t\t\t\t}\n\t\t\t\tusedKeys.add(key);\n\n\t\t\t\tconst stringValue = typeof value === \"string\" ? `\"${value}\"` : value;\n\t\t\t\treturn ` ${key} = ${stringValue},`;\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\n\t\tconst enumCode = `export enum ${enumName} {\\n${enumEntries}\\n}`;\n\t\tconst schemaCode = `export const ${schemaName} = z.nativeEnum(${enumName});`;\n\t\tconst typeCode = `export type ${name} = z.infer<typeof ${schemaName}>;`;\n\n\t\treturn { enumCode, schemaCode, typeCode };\n\t}\n\n\t// Generate Zod enum (default)\n\t// Note: z.enum only accepts string values, so convert numbers to strings\n\tconst enumValues = values.map(v => `\"${v}\"`).join(\", \");\n\tconst schemaCode = `export const ${schemaName} = z.enum([${enumValues}]);`;\n\tconst typeCode = `export type ${name} = z.infer<typeof ${schemaName}>;`;\n\n\treturn { enumCode: null, schemaCode, typeCode };\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 */\nexport function escapePattern(str: string): string {\n\treturn str.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\");\n}\n\n/**\n * Escape JSDoc comment content\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 */\nexport function isNullable(schema: OpenAPISchema): boolean {\n\t// OpenAPI 3.0 style: nullable: true\n\tif (schema.nullable === true) {\n\t\treturn true;\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\treturn false;\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 { 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","/**\n * Simple LRU Cache implementation for performance optimization\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(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","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: (schema: OpenAPISchema, currentSchema?: string, isTopLevel?: boolean) => string;\n\tresolveDiscriminatorMapping?: (mapping: Record<string, string>, schemas: OpenAPISchema[]) => OpenAPISchema[];\n}\n\nexport interface UnionOptions {\n\tpassthrough?: boolean;\n\tdiscriminatorMapping?: Record<string, string>;\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\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// Use discriminated union for better type inference\n\t\tlet schemaStrings = resolvedSchemas.map(s => context.generatePropertySchema(s, currentSchema));\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\tlet schemaStrings = schemas.map(s => context.generatePropertySchema(s, currentSchema));\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 * Generate allOf validation\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\tconst singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false);\n\t\treturn wrapNullable(singleSchema, isNullable);\n\t}\n\n\t// Check if all schemas are objects (for .merge() support)\n\tconst allObjects = schemas.every(s => s.type === \"object\" || s.properties || s.$ref || s.allOf);\n\n\tconst schemaStrings = schemas.map(s => context.generatePropertySchema(s, currentSchema, false));\n\n\tif (allObjects) {\n\t\t// Use .merge() for object schemas (better type inference)\n\t\tlet merged = schemaStrings[0];\n\t\tfor (let i = 1; i < schemaStrings.length; i++) {\n\t\t\tmerged = `${merged}.merge(${schemaStrings[i]})`;\n\t\t}\n\t\treturn wrapNullable(merged, isNullable);\n\t}\n\n\t// Use .and() for non-object schemas (intersection)\n\tlet merged = schemaStrings[0];\n\tfor (let i = 1; i < schemaStrings.length; i++) {\n\t\tmerged = `${merged}.and(${schemaStrings[i]})`;\n\t}\n\treturn wrapNullable(merged, 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\";\r\n\r\n/**\r\n * Generate property access expression (use dot notation for valid identifiers, bracket notation otherwise)\r\n */\r\nfunction generatePropertyAccess(propName: string): string {\r\n\t// Valid identifier: starts with letter/underscore/$, followed by letters/digits/underscores/$\r\n\tconst validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\r\n\treturn validIdentifier.test(propName) ? `obj.${propName}` : `obj[\"${propName}\"]`;\r\n}\r\n\r\n/**\r\n * Generate validation for dependencies (OpenAPI 3.0)\r\n * Generates detailed error messages showing which specific fields are missing\r\n */\r\nexport function generateDependencies(\r\n\tschema: OpenAPISchema,\r\n\tgeneratePropertySchema?: (schema: OpenAPISchema, currentSchema?: string) => string,\r\n\tcurrentSchema?: string\r\n): string {\r\n\tif (!schema.dependencies) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tlet result = \"\";\r\n\tfor (const [prop, dependency] of Object.entries(schema.dependencies)) {\r\n\t\tif (Array.isArray(dependency)) {\r\n\t\t\t// Skip empty dependency arrays (no dependencies to enforce)\r\n\t\t\tif (dependency.length === 0) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\t// Property dependency - show specific missing properties in error message\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\t\tconst checkLogic = dependency\r\n\t\t\t\t.map(p => {\r\n\t\t\t\t\tconst pAccess = generatePropertyAccess(p);\r\n\t\t\t\t\treturn `if (${pAccess} === undefined) missing.push('${p}');`;\r\n\t\t\t\t})\r\n\t\t\t\t.join(\"\\n\\t\\t\");\r\n\r\n\t\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\t\tconst missing: string[] = [];\r\n\t\t\t\t${checkLogic}\r\n\t\t\t\tif (missing.length > 0) {\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: \\`When '${prop}' is present, the following properties are required: \\${missing.join(', ')}\\`,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t})`;\r\n\t\t} else if (generatePropertySchema) {\r\n\t\t\t// Schema dependency - show detailed validation errors\r\n\t\t\tconst depSchema: OpenAPISchema = { ...dependency, type: dependency.type || \"object\" };\r\n\t\t\tconst depSchemaValidation = generatePropertySchema(depSchema, currentSchema);\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\r\n\t\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\t\tconst validation = ${depSchemaValidation}.safeParse(obj);\r\n\t\t\t\tif (!validation.success) {\r\n\t\t\t\t\tconst errors = validation.error.issues.map(i => \\` - \\${i.path.join('.')}: \\${i.message}\\`).join('\\\\n');\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: \\`When '${prop}' is present, object must satisfy additional constraints:\\\\n\\${errors}\\`,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t})`;\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Generate condition check for if/then/else\r\n */\r\nexport function generateConditionalCheck(schema: OpenAPISchema): string {\r\n\tconst conditions: string[] = [];\r\n\r\n\t// Check properties\r\n\tif (schema.properties) {\r\n\t\tfor (const [prop, propSchema] of Object.entries(schema.properties)) {\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\t\tif (propSchema.type) {\r\n\t\t\t\tconditions.push(`typeof ${propAccess} === \"${propSchema.type}\"`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.const !== undefined) {\r\n\t\t\t\tconst value = typeof propSchema.const === \"string\" ? `\"${propSchema.const}\"` : propSchema.const;\r\n\t\t\t\tconditions.push(`${propAccess} === ${value}`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.minimum !== undefined) {\r\n\t\t\t\tconditions.push(`${propAccess} >= ${propSchema.minimum}`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.maximum !== undefined) {\r\n\t\t\t\tconditions.push(`${propAccess} <= ${propSchema.maximum}`);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Check required properties\r\n\tif (schema.required) {\r\n\t\tfor (const prop of schema.required) {\r\n\t\t\tconditions.push(`${generatePropertyAccess(prop)} !== undefined`);\r\n\t\t}\r\n\t}\r\n\r\n\treturn conditions.length > 0 ? conditions.join(\" && \") : \"true\";\r\n}\r\n\r\n/**\r\n * Generate validation for then/else clauses\r\n */\r\nexport function generateConditionalValidation(schema: OpenAPISchema): string {\r\n\tconst checks: string[] = [];\r\n\r\n\t// Check required properties\r\n\tif (schema.required) {\r\n\t\tfor (const prop of schema.required) {\r\n\t\t\tchecks.push(`${generatePropertyAccess(prop)} !== undefined`);\r\n\t\t}\r\n\t}\r\n\r\n\t// Check properties constraints\r\n\tif (schema.properties) {\r\n\t\tfor (const [prop, propSchema] of Object.entries(schema.properties)) {\r\n\t\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\t\tif (propSchema.minimum !== undefined) {\r\n\t\t\t\tchecks.push(`${propAccess} === undefined || ${propAccess} >= ${propSchema.minimum}`);\r\n\t\t\t}\r\n\t\t\tif (propSchema.maximum !== undefined) {\r\n\t\t\t\tchecks.push(`${propAccess} === undefined || ${propAccess} <= ${propSchema.maximum}`);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn checks.length > 0 ? checks.join(\" && \") : \"true\";\r\n}\r\n\r\n/**\r\n * Generate if/then/else conditional validation with better error messages\r\n * Uses superRefine with detailed error messages for complex cases\r\n */\r\nexport function generateIfThenElse(schema: OpenAPISchema): string {\r\n\tif (!schema.if || (!schema.then && !schema.else)) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tconst ifCondition = generateConditionalCheck(schema.if);\r\n\r\n\tif (schema.then && schema.else) {\r\n\t\t// Both then and else - provide detailed error messages\r\n\t\tconst thenValidation = generateConditionalValidation(schema.then);\r\n\t\tconst elseValidation = generateConditionalValidation(schema.else);\r\n\r\n\t\t// Try to detect which specific validations failed\r\n\t\tconst thenRequiredProps = schema.then.required || [];\r\n\t\tconst elseRequiredProps = schema.else.required || [];\r\n\r\n\t\treturn `.superRefine((obj, ctx) => {\r\n\t\t\tconst ifConditionMet = ${ifCondition};\r\n\t\t\tif (ifConditionMet) {\r\n\t\t\t\t// Then branch\r\n\t\t\t\tconst thenValid = ${thenValidation};\r\n\t\t\t\tif (!thenValid) {\r\n\t\t\t\t\t${\r\n\t\t\t\t\t\tthenRequiredProps.length > 0\r\n\t\t\t\t\t\t\t? `\r\n\t\t\t\t\tconst missingThenProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\t\tconst message = missingThenProps.length > 0 \r\n\t\t\t\t\t\t? \\`When condition is met, required properties are missing: \\${missingThenProps.join(', ')}\\`\r\n\t\t\t\t\t\t: \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t\t\t: `\r\n\t\t\t\t\tconst message = \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t}\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: message,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t// Else branch\r\n\t\t\t\tconst elseValid = ${elseValidation};\r\n\t\t\t\tif (!elseValid) {\r\n\t\t\t\t\t${\r\n\t\t\t\t\t\telseRequiredProps.length > 0\r\n\t\t\t\t\t\t\t? `\r\n\t\t\t\t\tconst missingElseProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\t\tconst message = missingElseProps.length > 0 \r\n\t\t\t\t\t\t? \\`When condition is not met, required properties are missing: \\${missingElseProps.join(', ')}\\`\r\n\t\t\t\t\t\t: \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t\t\t: `\r\n\t\t\t\t\tconst message = \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t}\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: message,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\r\n\tif (schema.then) {\r\n\t\t// Only then - provide detailed error message\r\n\t\tconst thenValidation = generateConditionalValidation(schema.then);\r\n\t\tconst thenRequiredProps = schema.then.required || [];\r\n\r\n\t\treturn `.superRefine((obj, ctx) => {\r\n\t\t\tconst ifConditionMet = ${ifCondition};\r\n\t\t\tif (ifConditionMet) {\r\n\t\t\t\tconst thenValid = ${thenValidation};\r\n\t\t\t\tif (!thenValid) {\r\n\t\t\t\t\t${\r\n\t\t\t\t\t\tthenRequiredProps.length > 0\r\n\t\t\t\t\t\t\t? `\r\n\t\t\t\t\tconst missingProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\t\tconst message = missingProps.length > 0 \r\n\t\t\t\t\t\t? \\`When condition is met, required properties are missing: \\${missingProps.join(', ')}\\`\r\n\t\t\t\t\t\t: \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t\t\t: `\r\n\t\t\t\t\tconst message = \"When condition is met, validation constraints failed\";\r\n\t\t\t\t\t`\r\n\t\t\t\t\t}\r\n\t\t\t\t\tctx.addIssue({\r\n\t\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\t\tmessage: message,\r\n\t\t\t\t\t\tpath: []\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\r\n\t// Only else - provide detailed error message\r\n\tif (!schema.else) return \"\";\r\n\tconst elseValidation = generateConditionalValidation(schema.else);\r\n\tconst elseRequiredProps = schema.else.required || [];\r\n\r\n\treturn `.superRefine((obj, ctx) => {\r\n\t\tconst ifConditionMet = ${ifCondition};\r\n\t\tif (!ifConditionMet) {\r\n\t\t\tconst elseValid = ${elseValidation};\r\n\t\t\tif (!elseValid) {\r\n\t\t\t\t${\r\n\t\t\t\t\telseRequiredProps.length > 0\r\n\t\t\t\t\t\t? `\r\n\t\t\t\tconst missingProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);\r\n\t\t\t\tconst message = missingProps.length > 0 \r\n\t\t\t\t\t? \\`When condition is not met, required properties are missing: \\${missingProps.join(', ')}\\`\r\n\t\t\t\t\t: \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t`\r\n\t\t\t\t\t\t: `\r\n\t\t\t\tconst message = \"When condition is not met, validation constraints failed\";\r\n\t\t\t\t`\r\n\t\t\t\t}\r\n\t\t\t\tctx.addIssue({\r\n\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\tmessage: message,\r\n\t\t\t\t\tpath: []\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t})`;\r\n}\r\n\r\n/**\r\n * Generate dependent required validation (OpenAPI 3.1)\r\n * Generates detailed error messages showing which specific fields are missing\r\n */\r\nexport function generateDependentRequired(schema: OpenAPISchema): string {\r\n\tif (!schema.dependentRequired) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tlet result = \"\";\r\n\tfor (const [prop, requiredProps] of Object.entries(schema.dependentRequired)) {\r\n\t\t// Skip empty required arrays (no dependencies to enforce)\r\n\t\tif (requiredProps.length === 0) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst propAccess = generatePropertyAccess(prop);\r\n\t\tconst checkLogic = requiredProps\r\n\t\t\t.map(rp => {\r\n\t\t\t\tconst rpAccess = generatePropertyAccess(rp);\r\n\t\t\t\treturn `if (${rpAccess} === undefined) missing.push('${rp}');`;\r\n\t\t\t})\r\n\t\t\t.join(\"\\n\\t\\t\");\r\n\r\n\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\tconst missing: string[] = [];\r\n\t\t\t${checkLogic}\r\n\t\t\tif (missing.length > 0) {\r\n\t\t\t\tctx.addIssue({\r\n\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\tmessage: \\`When '${prop}' is present, the following properties are required: \\${missing.join(', ')}\\`,\r\n\t\t\t\t\tpath: []\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Generate dependent schemas validation (JSON Schema 2019-09 / OpenAPI 3.1)\r\n * This is the modern replacement for schema-based dependencies\r\n * Generates detailed error messages showing validation failures\r\n */\r\nexport function generateDependentSchemas(\r\n\tschema: OpenAPISchema & { dependentSchemas?: Record<string, OpenAPISchema> },\r\n\tgeneratePropertySchema?: (schema: OpenAPISchema, currentSchema?: string) => string,\r\n\tcurrentSchema?: string\r\n): string {\r\n\tif (!schema.dependentSchemas || !generatePropertySchema) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tlet result = \"\";\r\n\tfor (const [prop, depSchema] of Object.entries(schema.dependentSchemas)) {\r\n\t\tconst depSchemaValidation = generatePropertySchema(depSchema, currentSchema);\r\n\t\tconst propAccess = generatePropertyAccess(prop);\r\n\r\n\t\tresult += `.superRefine((obj, ctx) => {\r\n\t\t\tif (${propAccess} === undefined) return;\r\n\t\t\tconst validation = ${depSchemaValidation}.safeParse(obj);\r\n\t\t\tif (!validation.success) {\r\n\t\t\t\tconst errors = validation.error.issues.map(i => \\` - \\${i.path.join('.')}: \\${i.message}\\`).join('\\\\n');\r\n\t\t\t\tctx.addIssue({\r\n\t\t\t\t\tcode: \"custom\",\r\n\t\t\t\t\tmessage: \\`When '${prop}' is present, dependent schema validation failed:\\\\n\\${errors}\\`,\r\n\t\t\t\t\tpath: []\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t})`;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Validate dependency graph for circular dependencies\r\n * Returns validation result with any detected circular dependency errors\r\n */\r\nexport function validateDependencyGraph(\r\n\tschema: OpenAPISchema,\r\n\tschemaName: string\r\n): { valid: boolean; errors: string[] } {\r\n\tconst errors: string[] = [];\r\n\r\n\tif (!schema.dependencies && !schema.dependentRequired) {\r\n\t\treturn { valid: true, errors: [] };\r\n\t}\r\n\r\n\t// Build dependency graph\r\n\tconst graph = new Map<string, Set<string>>();\r\n\r\n\t// Add dependentRequired edges\r\n\tif (schema.dependentRequired) {\r\n\t\tfor (const [prop, deps] of Object.entries(schema.dependentRequired)) {\r\n\t\t\tif (!graph.has(prop)) {\r\n\t\t\t\tgraph.set(prop, new Set());\r\n\t\t\t}\r\n\t\t\tconst propDeps = graph.get(prop);\r\n\t\t\tif (propDeps) {\r\n\t\t\t\tfor (const dep of deps) {\r\n\t\t\t\t\tpropDeps.add(dep);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Add dependencies (array type) edges\r\n\tif (schema.dependencies) {\r\n\t\tfor (const [prop, dep] of Object.entries(schema.dependencies)) {\r\n\t\t\tif (Array.isArray(dep)) {\r\n\t\t\t\tif (!graph.has(prop)) {\r\n\t\t\t\t\tgraph.set(prop, new Set());\r\n\t\t\t\t}\r\n\t\t\t\tconst propDeps = graph.get(prop);\r\n\t\t\t\tif (propDeps) {\r\n\t\t\t\t\tfor (const d of dep) {\r\n\t\t\t\t\t\tpropDeps.add(d);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Detect cycles using DFS\r\n\tconst visited = new Set<string>();\r\n\tconst recStack = new Set<string>();\r\n\tconst path: string[] = [];\r\n\r\n\tfunction detectCycle(prop: string): boolean {\r\n\t\tvisited.add(prop);\r\n\t\trecStack.add(prop);\r\n\t\tpath.push(prop);\r\n\r\n\t\tconst deps = graph.get(prop) || new Set();\r\n\t\tfor (const dep of deps) {\r\n\t\t\tif (!visited.has(dep)) {\r\n\t\t\t\tif (detectCycle(dep)) {\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t} else if (recStack.has(dep)) {\r\n\t\t\t\t// Cycle detected\r\n\t\t\t\tconst cycleStart = path.indexOf(dep);\r\n\t\t\t\tconst cycle = [...path.slice(cycleStart), dep];\r\n\t\t\t\terrors.push(`Circular dependency detected in schema '${schemaName}': ${cycle.join(\" -> \")}`);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\trecStack.delete(prop);\r\n\t\tpath.pop();\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Check all roots\r\n\tfor (const prop of graph.keys()) {\r\n\t\tif (!visited.has(prop)) {\r\n\t\t\tdetectCycle(prop);\r\n\t\t}\r\n\t}\r\n\r\n\treturn { valid: errors.length === 0, errors };\r\n}\r\n\r\n/**\r\n * Extract schema dependencies as reusable schemas\r\n * Useful for code generation and schema reuse\r\n */\r\nexport function extractSchemaDependencies(schema: OpenAPISchema, schemaName: string): Map<string, OpenAPISchema> {\r\n\tconst extracted = new Map<string, OpenAPISchema>();\r\n\r\n\tif (!schema.dependencies) {\r\n\t\treturn extracted;\r\n\t}\r\n\r\n\tfor (const [prop, dependency] of Object.entries(schema.dependencies)) {\r\n\t\tif (!Array.isArray(dependency)) {\r\n\t\t\t// This is a schema dependency\r\n\t\t\tconst depSchemaName = `${schemaName}_${prop}_Dependency`;\r\n\t\t\tconst depSchema: OpenAPISchema = {\r\n\t\t\t\t...dependency,\r\n\t\t\t\ttype: dependency.type || \"object\",\r\n\t\t\t};\r\n\t\t\textracted.set(depSchemaName, depSchema);\r\n\t\t}\r\n\t}\r\n\r\n\treturn extracted;\r\n}\r\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 { LRUCache } from \"../utils/lru-cache\";\nimport { addDescription, escapePattern } from \"../utils/string-utils\";\n\n// Performance optimization: Cache compiled regex patterns with size limit\nconst PATTERN_CACHE = new LRUCache<string, string>(1000);\n\nconst 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\t\"date-time\": \"z.iso.datetime()\",\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 * Generate Zod validation for string with format (Zod v4 compatible)\n */\nexport function generateStringValidation(schema: OpenAPISchema, useDescribe: boolean): string {\n\t// Handle format with Zod v4 top-level functions (performance optimized with map)\n\tlet validation = FORMAT_MAP[schema.format || \"\"] || \"z.string()\";\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)\n\tif (schema.pattern) {\n\t\tlet escapedPattern = PATTERN_CACHE.get(schema.pattern);\n\t\tif (escapedPattern === undefined) {\n\t\t\tescapedPattern = escapePattern(schema.pattern);\n\t\t\tPATTERN_CACHE.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 = PATTERN_CACHE.get(schema.pattern);\n\t\t\tif (escapedPattern === undefined) {\n\t\t\t\tescapedPattern = escapePattern(schema.pattern);\n\t\t\t\tPATTERN_CACHE.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 { NativeEnumType, OpenAPISchema, OpenAPISpec, TypeMode } from \"../types\";\nimport { LRUCache } from \"../utils/lru-cache\";\nimport type { NamingOptions } from \"../utils/name-utils\";\nimport { resolveRef, toCamelCase } from \"../utils/name-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\ttypeMode: TypeMode;\n\tnativeEnumType: NativeEnumType;\n\tnamingOptions: NamingOptions;\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 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 merge(), 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(\".merge(\")) {\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 */\n\tgeneratePropertySchema(schema: OpenAPISchema, currentSchema?: string, isTopLevel = false): 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({ schema, type: this.context.schemaType, mode: this.context.mode });\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\tconst nullable = isNullable(schema);\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\tconst schemaName = `${toCamelCase(resolvedRefName, this.context.namingOptions)}Schema`;\n\n\t\t\t// Check for circular dependency through alias\n\t\t\tif (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\tconst enumValues = schema.enum.map(v => `\"${v}\"`).join(\", \");\n\t\t\tconst zodEnum = `z.enum([${enumValues}])`;\n\t\t\treturn wrapNullable(zodEnum, nullable);\n\t\t}\n\n\t\t// Handle allOf\n\t\tif (schema.allOf) {\n\t\t\tlet composition = generateAllOf(\n\t\t\t\tschema.allOf,\n\t\t\t\tnullable,\n\t\t\t\t{ generatePropertySchema: this.generatePropertySchema.bind(this) },\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\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\tnullable,\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},\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\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\tnullable,\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},\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\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\tvalidation = \"z.record(z.string(), z.unknown())\";\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","import { ConfigurationError } from \"./errors\";\nimport { ZodSchemaGenerator } from \"./generator\";\nimport type { ExecutionMode, GeneratorOptions } from \"./types\";\n\n/**\n * Result of processing a single spec\n */\ninterface SpecResult {\n\tspec: GeneratorOptions;\n\tsuccess: boolean;\n\terror?: string;\n}\n\n/**\n * Summary of batch execution results\n */\ninterface BatchExecutionSummary {\n\ttotal: number;\n\tsuccessful: number;\n\tfailed: number;\n\tresults: SpecResult[];\n}\n\n/**\n * Process a single spec and return result with error handling\n */\nasync function processSpec(spec: GeneratorOptions, index: number, total: number): Promise<SpecResult> {\n\t// Live progress to stdout\n\tconsole.log(`Processing [${index + 1}/${total}] ${spec.input}...`);\n\n\ttry {\n\t\tconst generator = new ZodSchemaGenerator(spec);\n\t\tgenerator.generate();\n\n\t\tconsole.log(`✓ Successfully generated ${spec.output}`);\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 ${spec.output}: ${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\n * Continues processing all specs even if some fail\n */\nasync function executeParallel(specs: GeneratorOptions[]): Promise<SpecResult[]> {\n\tconsole.log(`\\nExecuting ${specs.length} spec(s) in parallel...\\n`);\n\n\tconst promises = specs.map((spec, index) => processSpec(spec, index, specs.length));\n\n\tconst results = await Promise.allSettled(promises);\n\n\treturn results.map((result, index) => {\n\t\tif (result.status === \"fulfilled\") {\n\t\t\treturn result.value;\n\t\t}\n\n\t\t// Handle unexpected promise rejection (shouldn't happen as processSpec catches errors)\n\t\treturn {\n\t\t\tspec: specs[index],\n\t\t\tsuccess: false,\n\t\t\terror: result.reason instanceof Error ? result.reason.message : String(result.reason),\n\t\t};\n\t});\n}\n\n/**\n * Execute specs sequentially one at a time\n * Continues processing all specs even if some fail\n */\nasync function executeSequential(specs: GeneratorOptions[]): Promise<SpecResult[]> {\n\tconsole.log(`\\nExecuting ${specs.length} spec(s) sequentially...\\n`);\n\n\tconst results: SpecResult[] = [];\n\n\tfor (let i = 0; i < specs.length; i++) {\n\t\tconst result = await processSpec(specs[i], i, specs.length);\n\t\tresults.push(result);\n\t}\n\n\treturn results;\n}\n\n/**\n * Print final summary of batch execution\n */\nfunction printSummary(summary: BatchExecutionSummary): 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\tconsole.error(` ✗ ${result.spec.input}`);\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 * Execute batch processing of multiple OpenAPI specs\n *\n * @param specs - Array of spec configurations to process\n * @param executionMode - Execution mode: \"parallel\" (default) or \"sequential\"\n * @returns BatchExecutionSummary with results\n * @throws Never throws - collects all errors and reports them\n */\nexport async function executeBatch(\n\tspecs: GeneratorOptions[],\n\texecutionMode: ExecutionMode = \"parallel\"\n): Promise<BatchExecutionSummary> {\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[] = [];\n\n\ttry {\n\t\t// Execute based on mode\n\t\tresults = executionMode === \"parallel\" ? await executeParallel(specs) : await executeSequential(specs);\n\n\t\t// Calculate summary\n\t\tconst summary: BatchExecutionSummary = {\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 > 10) {\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(summary: BatchExecutionSummary): number {\n\treturn summary.failed > 0 ? 1 : 0;\n}\n","import { cosmiconfig, type Loader } from \"cosmiconfig\";\nimport { z } from \"zod\";\nimport type { ConfigFile, GeneratorOptions } from \"../types\";\n\n/**\n * Zod schema for strict validation of config files\n * Rejects unknown properties to catch typos and invalid options\n */\nconst TypeModeSchema = z.enum([\"inferred\", \"native\"]);\nconst NativeEnumTypeSchema = z.enum([\"union\", \"enum\"]);\n\nconst RequestResponseOptionsSchema = z.strictObject({\n\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tuseDescribe: z.boolean().optional(),\n\tincludeDescriptions: z.boolean().optional(),\n\ttypeMode: TypeModeSchema.optional(),\n\tnativeEnumType: NativeEnumTypeSchema.optional(),\n});\n\nconst GeneratorOptionsSchema = z.strictObject({\n\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\tinput: z.string(),\n\toutput: z.string(),\n\tincludeDescriptions: z.boolean().optional(),\n\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\tuseDescribe: z.boolean().optional(),\n\tschemaType: z.enum([\"all\", \"request\", \"response\"]).optional(),\n\tprefix: z.string().optional(),\n\tsuffix: z.string().optional(),\n\tshowStats: z.boolean().optional(),\n\tnativeEnumType: NativeEnumTypeSchema.optional(),\n\trequest: RequestResponseOptionsSchema.optional(),\n\tresponse: RequestResponseOptionsSchema.optional(),\n\tname: z.string().optional(),\n});\n\nconst ConfigFileSchema = z.strictObject({\n\tdefaults: z\n\t\t.strictObject({\n\t\t\tmode: z.enum([\"strict\", \"normal\", \"loose\"]).optional(),\n\t\t\tincludeDescriptions: z.boolean().optional(),\n\t\t\tenumType: z.enum([\"zod\", \"typescript\"]).optional(),\n\t\t\tuseDescribe: z.boolean().optional(),\n\t\t\tschemaType: z.enum([\"all\", \"request\", \"response\"]).optional(),\n\t\t\tprefix: z.string().optional(),\n\t\t\tsuffix: z.string().optional(),\n\t\t\tshowStats: z.boolean().optional(),\n\t\t\tnativeEnumType: NativeEnumTypeSchema.optional(),\n\t\t\trequest: RequestResponseOptionsSchema.optional(),\n\t\t\tresponse: RequestResponseOptionsSchema.optional(),\n\t\t})\n\t\t.optional(),\n\tspecs: z.array(GeneratorOptionsSchema).min(1, \"At least one spec is required\"),\n\texecutionMode: z.enum([\"parallel\", \"sequential\"]).optional(),\n});\n\n/**\n * TypeScript loader using tsx for executing .ts config files\n * Uses Node's module._compile to execute TypeScript after transpiling with esbuild\n */\nconst 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\n/**\n * Load and validate configuration file\n * Supports: openapi-to-zod.config.{ts,json}, package.json under \"openapi-to-zod\" key\n *\n * @param configPath - Optional explicit path to config file. If not provided, searches automatically\n * @returns Validated ConfigFile object\n * @throws Error if config file not found, invalid, or contains unknown properties\n */\nexport async function loadConfig(configPath?: string): Promise<ConfigFile> {\n\tconst explorer = cosmiconfig(\"openapi-to-zod\", {\n\t\tsearchPlaces: [\"openapi-to-zod.config.ts\", \"openapi-to-zod.config.json\", \"package.json\"],\n\t\tloaders: {\n\t\t\t\".ts\": createTypeScriptLoader(),\n\t\t},\n\t});\n\n\tlet result: Awaited<ReturnType<typeof explorer.load>> | Awaited<ReturnType<typeof explorer.search>>;\n\n\tif (configPath) {\n\t\t// Load from explicit path (overrides auto-discovery)\n\t\tresult = await explorer.load(configPath);\n\t} else {\n\t\t// Auto-discover config file starting from cwd\n\t\tresult = await explorer.search();\n\t}\n\n\tif (!result || !result.config) {\n\t\tthrow new Error(\n\t\t\tconfigPath\n\t\t\t\t? `Config file not found at: ${configPath}`\n\t\t\t\t: \"No config file found. Searched for: openapi-to-zod.config.ts, openapi-to-zod.config.json, package.json (openapi-to-zod key)\"\n\t\t);\n\t}\n\n\t// Strict validation using Zod schema\n\ttry {\n\t\tconst validatedConfig = ConfigFileSchema.parse(result.config);\n\t\treturn validatedConfig;\n\t} catch (error) {\n\t\tif (error instanceof z.ZodError) {\n\t\t\tconst formattedErrors =\n\t\t\t\terror.issues\n\t\t\t\t\t?.map(err => {\n\t\t\t\t\t\tconst path = err.path.length > 0 ? err.path.join(\".\") : \"root\";\n\t\t\t\t\t\treturn ` - ${path}: ${err.message}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\") || \"Unknown validation error\";\n\n\t\t\tconst configSource = result.filepath || configPath || \"config file\";\n\t\t\tconst errorMessage = [\n\t\t\t\t`Invalid configuration file at: ${configSource}`,\n\t\t\t\t\"\",\n\t\t\t\t\"Validation errors:\",\n\t\t\t\tformattedErrors,\n\t\t\t\t\"\",\n\t\t\t\t\"Please check your configuration file and ensure:\",\n\t\t\t\t\" - All required fields are present (specs array with input/output)\",\n\t\t\t\t\" - Field names are spelled correctly (no typos)\",\n\t\t\t\t\" - Values match the expected types (e.g., mode: 'strict' | 'normal' | 'loose')\",\n\t\t\t\t\" - No unknown/extra properties are included\",\n\t\t\t].join(\"\\n\");\n\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Merge global defaults with per-spec configuration\n * CLI arguments have highest precedence and are merged separately in CLI layer\n *\n * @param config - Validated configuration file\n * @returns Array of fully resolved GeneratorOptions objects\n */\nexport function mergeConfigWithDefaults(config: ConfigFile): GeneratorOptions[] {\n\tif (!config?.specs || !Array.isArray(config.specs)) {\n\t\tthrow new Error(\"Invalid config: specs array is required\");\n\t}\n\n\tconst defaults = config.defaults || {};\n\n\treturn config.specs.map(spec => {\n\t\t// Deep merge: spec options override defaults\n\t\tconst merged: GeneratorOptions = {\n\t\t\t// Apply defaults first\n\t\t\tmode: defaults.mode,\n\t\t\tincludeDescriptions: defaults.includeDescriptions,\n\t\t\tenumType: defaults.enumType,\n\t\t\tuseDescribe: defaults.useDescribe,\n\t\t\tschemaType: defaults.schemaType,\n\t\t\tprefix: defaults.prefix,\n\t\t\tsuffix: defaults.suffix,\n\t\t\tshowStats: defaults.showStats,\n\n\t\t\t// Override with spec-specific values (including required input/output)\n\t\t\t...spec,\n\t\t};\n\n\t\treturn merged;\n\t});\n}\n\n/**\n * Merge CLI options with config options\n * CLI options have highest precedence and override both spec and default config\n *\n * @param specConfig - Configuration from config file (with defaults already applied)\n * @param cliOptions - Options provided via CLI arguments\n * @returns Merged GeneratorOptions with CLI taking precedence\n */\nexport function mergeCliWithConfig(\n\tspecConfig: GeneratorOptions,\n\tcliOptions: Partial<GeneratorOptions>\n): GeneratorOptions {\n\t// CLI options override everything\n\treturn {\n\t\t...specConfig,\n\t\t...Object.fromEntries(Object.entries(cliOpt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AAQ;AAAA,MACrB,qBAAqB,QAAQ;AAAA,IAC9B;AAAA,EACD;AAGA,MAAI,OAAO,KAAK,YAAY,EAAE,SAAS,GAAG;AACzC,YAAQ,MAAM,IAAI,UAAQ,mBAAmB,MAAM,YAAY,CAAC;AAAA,EACjE;AAGA,QAAM,gBAAgC,QAAQ,iBAAmC,OAAO,iBAAiB;AAGzG,QAAM,UAAU,MAAM,aAAa,OAAO,aAAa;AAGvD,QAAM,WAAW,iBAAiB,OAAO;AACzC,MAAI,aAAa,GAAG;AACnB,YAAQ,KAAK,QAAQ;AAAA,EACtB;AACD;","names":["import_zod","schemaCode","typeCode","isNullable","isNullable","schemaStrings","union","merged","elseValidation","elseRequiredProps","generatePropertyAccess","definedProps","_a","isNullable","wrapNullable","module"]}