next-openapi-gen 1.2.0 → 1.2.2

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.
@@ -756,6 +756,17 @@ function mergeJSDocData(target, source) {
756
756
  function cleanComment(commentValue) {
757
757
  return commentValue.replace(/\*\s*/g, "").trim();
758
758
  }
759
+ function extractSchemaIdFromComments(comments) {
760
+ if (!comments)
761
+ return null;
762
+ for (const comment of comments) {
763
+ const cleaned = cleanComment(comment.value);
764
+ const id = extractTokenValue(cleaned, "@id");
765
+ if (id)
766
+ return id;
767
+ }
768
+ return null;
769
+ }
759
770
  function extractLineValue(commentValue, tag) {
760
771
  return commentValue.match(new RegExp(`${escapeRegExp(tag)}\\s*(.*)`, "m"))?.[1]?.trim() || "";
761
772
  }
@@ -3172,7 +3183,8 @@ var DrizzleZodProcessor = class _DrizzleZodProcessor {
3172
3183
  if (firstArg && !t4.isSpreadElement(firstArg) && !t4.isArgumentPlaceholder(firstArg)) {
3173
3184
  const metadata = _DrizzleZodProcessor.extractStaticObject(firstArg);
3174
3185
  if (metadata) {
3175
- Object.assign(result, metadata);
3186
+ const { id: _id, ...rest } = metadata;
3187
+ Object.assign(result, rest);
3176
3188
  }
3177
3189
  }
3178
3190
  break;
@@ -11456,8 +11468,11 @@ var ZodRuntimeExporter = class {
11456
11468
  case "deprecated":
11457
11469
  return schema.meta({ deprecated: true });
11458
11470
  case "meta": {
11459
- const metadata = node.arguments[0] ? this.buildMetadataObject(node.arguments[0]) : null;
11460
- return metadata ? schema.meta(metadata) : schema;
11471
+ const rawMetadata = node.arguments[0] ? this.buildMetadataObject(node.arguments[0]) : null;
11472
+ if (!rawMetadata)
11473
+ return schema;
11474
+ const { id: _id, ...metadata } = rawMetadata;
11475
+ return Object.keys(metadata).length > 0 ? schema.meta(metadata) : schema;
11461
11476
  }
11462
11477
  case "default":
11463
11478
  case "prefault":
@@ -11693,7 +11708,9 @@ var ZodSchemaConverter = class {
11693
11708
  apiDir;
11694
11709
  zodSchemas = {};
11695
11710
  processingSchemas = /* @__PURE__ */ new Set();
11696
- processedModules = /* @__PURE__ */ new Set();
11711
+ /** Memoization guard for processFileForZodSchema. Keys: `${filePath}|${schemaName}`.
11712
+ * Prevents infinite recursion when re-export files reference schemas via z.infer<typeof X>. */
11713
+ processedFileSchemaPairs = /* @__PURE__ */ new Set();
11697
11714
  typeToSchemaMapping = {};
11698
11715
  drizzleZodImports = /* @__PURE__ */ new Set();
11699
11716
  factoryCache = /* @__PURE__ */ new Map();
@@ -11907,6 +11924,11 @@ var ZodSchemaConverter = class {
11907
11924
  * Process a file to find Zod schema definitions
11908
11925
  */
11909
11926
  processFileForZodSchema(filePath, schemaName) {
11927
+ const visitKey = `${filePath}|${schemaName}|${this.currentContentType}`;
11928
+ if (this.processedFileSchemaPairs.has(visitKey)) {
11929
+ return;
11930
+ }
11931
+ this.processedFileSchemaPairs.add(visitKey);
11910
11932
  try {
11911
11933
  const content = this.fileAccess.readFileSync(filePath, "utf-8");
11912
11934
  if (!content.includes(schemaName)) {
@@ -12220,7 +12242,9 @@ var ZodSchemaConverter = class {
12220
12242
  const param = path17.node.typeAnnotation.typeParameters.params[0];
12221
12243
  if (t10.isTSTypeQuery(param) && t10.isIdentifier(param.exprName)) {
12222
12244
  const referencedSchemaName = param.exprName.name;
12223
- this.processFileForZodSchema(filePath, referencedSchemaName);
12245
+ if (!this.getStoredSchema(referencedSchemaName)) {
12246
+ this.processFileForZodSchema(filePath, referencedSchemaName);
12247
+ }
12224
12248
  }
12225
12249
  }
12226
12250
  }
@@ -12238,6 +12262,8 @@ var ZodSchemaConverter = class {
12238
12262
  try {
12239
12263
  const content = this.fileAccess.readFileSync(filePath, "utf-8");
12240
12264
  const ast = parseTypeScriptFile(content);
12265
+ this.currentFilePath = filePath;
12266
+ this.currentAST = ast;
12241
12267
  resolvedTraverse(ast, {
12242
12268
  ExportNamedDeclaration: (path17) => {
12243
12269
  if (t10.isVariableDeclaration(path17.node.declaration)) {
@@ -12252,6 +12278,17 @@ var ZodSchemaConverter = class {
12252
12278
  }
12253
12279
  this.processingSchemas.delete(schemaName);
12254
12280
  }
12281
+ } else if (t10.isIdentifier(declaration.id) && declaration.init) {
12282
+ const schemaName = declaration.id.name;
12283
+ const overrideId = this.extractMetaIdFromNode(declaration.init);
12284
+ if (overrideId && !this.getStoredSchema(schemaName) && !this.processingSchemas.has(schemaName)) {
12285
+ this.processingSchemas.add(schemaName);
12286
+ const schema = this.processZodNode(declaration.init);
12287
+ this.processingSchemas.delete(schemaName);
12288
+ if (schema) {
12289
+ this.applyMetaIdOverride(schemaName, schema, overrideId, filePath);
12290
+ }
12291
+ }
12255
12292
  }
12256
12293
  });
12257
12294
  }
@@ -12805,6 +12842,24 @@ var ZodSchemaConverter = class {
12805
12842
  }
12806
12843
  return void 0;
12807
12844
  }
12845
+ extractMetaIdFromNode(node) {
12846
+ if (!t10.isCallExpression(node))
12847
+ return null;
12848
+ if (t10.isMemberExpression(node.callee) && t10.isIdentifier(node.callee.property)) {
12849
+ if (node.callee.property.name === "meta" && node.arguments.length > 0) {
12850
+ const metadata = this.extractStaticJsonValue(node.arguments[0]);
12851
+ if (metadata && typeof metadata === "object" && !Array.isArray(metadata)) {
12852
+ const id = metadata.id;
12853
+ if (typeof id === "string" && id.length > 0)
12854
+ return id;
12855
+ }
12856
+ }
12857
+ if (t10.isCallExpression(node.callee.object)) {
12858
+ return this.extractMetaIdFromNode(node.callee.object);
12859
+ }
12860
+ }
12861
+ return null;
12862
+ }
12808
12863
  shouldUseRuntimeExport(node) {
12809
12864
  if (!t10.isCallExpression(node)) {
12810
12865
  return false;
@@ -13045,7 +13100,8 @@ var ZodSchemaConverter = class {
13045
13100
  if (node.arguments.length > 0) {
13046
13101
  const metadata = this.extractStaticJsonValue(node.arguments[0]);
13047
13102
  if (metadata && typeof metadata === "object" && !Array.isArray(metadata)) {
13048
- Object.assign(schema, metadata);
13103
+ const { id: _id, ...rest } = metadata;
13104
+ Object.assign(schema, rest);
13049
13105
  }
13050
13106
  }
13051
13107
  break;
@@ -13331,6 +13387,7 @@ var ZodSchemaConverter = class {
13331
13387
  this.currentFilePath = filePath;
13332
13388
  this.currentAST = ast;
13333
13389
  this.currentImports = importedModules;
13390
+ this.preprocessedFiles.add(filePath);
13334
13391
  resolvedTraverse(ast, {
13335
13392
  ExportNamedDeclaration: (path17) => {
13336
13393
  if (t10.isVariableDeclaration(path17.node.declaration)) {
@@ -13338,15 +13395,19 @@ var ZodSchemaConverter = class {
13338
13395
  if (t10.isIdentifier(declaration.id) && declaration.init) {
13339
13396
  const schemaName = declaration.id.name;
13340
13397
  if (this.isZodSchema(declaration.init)) {
13341
- this.indexSchemaName(schemaName, filePath);
13342
13398
  if (!this.getStoredSchema(schemaName)) {
13343
13399
  logger.debug(`Pre-processing Zod schema: ${schemaName}`);
13344
13400
  this.processingSchemas.add(schemaName);
13345
13401
  const schema = this.processZodNode(declaration.init);
13402
+ this.processingSchemas.delete(schemaName);
13346
13403
  if (schema) {
13347
- this.storeResolvedSchema(schemaName, schema);
13404
+ const overrideId = this.extractMetaIdFromNode(declaration.init);
13405
+ this.applyMetaIdOverride(schemaName, schema, overrideId, filePath);
13406
+ } else {
13407
+ this.indexSchemaName(schemaName, filePath);
13348
13408
  }
13349
- this.processingSchemas.delete(schemaName);
13409
+ } else {
13410
+ this.indexSchemaName(schemaName, filePath);
13350
13411
  }
13351
13412
  }
13352
13413
  }
@@ -13359,22 +13420,25 @@ var ZodSchemaConverter = class {
13359
13420
  if (t10.isIdentifier(declaration.id) && declaration.init) {
13360
13421
  const schemaName = declaration.id.name;
13361
13422
  if (this.isZodSchema(declaration.init)) {
13362
- this.indexSchemaName(schemaName, filePath);
13363
13423
  if (!this.getStoredSchema(schemaName) && !this.processingSchemas.has(schemaName)) {
13364
13424
  logger.debug(`Pre-processing Zod schema: ${schemaName}`);
13365
13425
  this.processingSchemas.add(schemaName);
13366
13426
  const schema = this.processZodNode(declaration.init);
13427
+ this.processingSchemas.delete(schemaName);
13367
13428
  if (schema) {
13368
- this.storeResolvedSchema(schemaName, schema);
13429
+ const overrideId = this.extractMetaIdFromNode(declaration.init);
13430
+ this.applyMetaIdOverride(schemaName, schema, overrideId, filePath);
13431
+ } else {
13432
+ this.indexSchemaName(schemaName, filePath);
13369
13433
  }
13370
- this.processingSchemas.delete(schemaName);
13434
+ } else {
13435
+ this.indexSchemaName(schemaName, filePath);
13371
13436
  }
13372
13437
  }
13373
13438
  }
13374
13439
  });
13375
13440
  }
13376
13441
  });
13377
- this.preprocessedFiles.add(filePath);
13378
13442
  } catch (error2) {
13379
13443
  logger.error(`Error pre-processing file ${filePath}: ${error2}`);
13380
13444
  }
@@ -13392,6 +13456,21 @@ var ZodSchemaConverter = class {
13392
13456
  }
13393
13457
  bucket.add(filePath);
13394
13458
  }
13459
+ applyMetaIdOverride(schemaName, schema, overrideId, filePath) {
13460
+ const finalName = overrideId && overrideId !== schemaName ? overrideId : schemaName;
13461
+ this.indexSchemaName(schemaName, filePath);
13462
+ if (finalName !== schemaName) {
13463
+ this.indexSchemaName(finalName, filePath);
13464
+ }
13465
+ if (!this.getStoredSchema(finalName)) {
13466
+ if (overrideId && overrideId !== schemaName) {
13467
+ this.typeToSchemaMapping[schemaName] = overrideId;
13468
+ }
13469
+ this.storeResolvedSchema(finalName, schema);
13470
+ } else {
13471
+ logger.warn(`Schema component name '${overrideId ?? finalName}' conflicts with an existing schema, ignoring .meta({ id }) on '${schemaName}'`);
13472
+ }
13473
+ }
13395
13474
  /**
13396
13475
  * Check if node is Zod schema
13397
13476
  */
@@ -13595,15 +13674,39 @@ function extractKeysFromLiteralType(node) {
13595
13674
  }
13596
13675
  return [];
13597
13676
  }
13677
+ function parsePropertyComment(commentValue) {
13678
+ const text = commentValue.split("\n").map((line) => line.replace(/^\s*\*\s?/, "").trim()).filter((line) => line.length > 0).join(" ").trim();
13679
+ const result = {};
13680
+ let remaining = text;
13681
+ const formatMatch = remaining.match(/@format\s+(\S+)/);
13682
+ if (formatMatch?.[1]) {
13683
+ result.format = formatMatch[1];
13684
+ remaining = remaining.replace(formatMatch[0], "").trim();
13685
+ }
13686
+ const exampleMatch = remaining.match(/@example\s+(.+?)(?=\s*@\w|$)/);
13687
+ if (exampleMatch?.[1]) {
13688
+ const raw = exampleMatch[1].trim();
13689
+ try {
13690
+ result.example = JSON.parse(raw);
13691
+ } catch {
13692
+ result.example = raw;
13693
+ }
13694
+ remaining = remaining.replace(exampleMatch[0], "").trim();
13695
+ }
13696
+ remaining = remaining.replace(/@\w+(?:\s+\S+)*/g, "").trim();
13697
+ if (remaining) {
13698
+ result.description = remaining;
13699
+ }
13700
+ return result;
13701
+ }
13598
13702
  function getPropertyOptions(node, contentType) {
13599
13703
  const isOptional = !!node.optional;
13600
- let description = null;
13601
- if (node.trailingComments && node.trailingComments.length) {
13602
- description = node.trailingComments[0].value.trim();
13603
- }
13604
13704
  const options = {};
13605
- if (description) {
13606
- options.description = description;
13705
+ const leadingComment = node.leadingComments?.findLast((c) => c.type === "CommentBlock" || !node.trailingComments?.length);
13706
+ const trailingComment = node.trailingComments?.[0];
13707
+ const sourceComment = leadingComment ?? trailingComment;
13708
+ if (sourceComment) {
13709
+ Object.assign(options, parsePropertyComment(sourceComment.value));
13607
13710
  }
13608
13711
  if (contentType === "body") {
13609
13712
  options.nullable = isOptional;
@@ -14002,31 +14105,60 @@ function resolveImportPath(importPath, fromFilePath, fileAccess) {
14002
14105
  }
14003
14106
  return null;
14004
14107
  }
14005
- function collectAllExportedDefinitions(ast, typeDefinitions, currentFile) {
14108
+ function collectFirstMemberLeadingComments(interfaceDecl) {
14109
+ const body = interfaceDecl?.body;
14110
+ if (!body)
14111
+ return [];
14112
+ const firstMember = body.body?.[0];
14113
+ return firstMember?.leadingComments ?? [];
14114
+ }
14115
+ function collectAllExportedDefinitions(ast, typeDefinitions, currentFile, schemaIdAliases) {
14116
+ function registerDefinition(name, entry, allComments) {
14117
+ if (!typeDefinitions[name]) {
14118
+ typeDefinitions[name] = entry;
14119
+ }
14120
+ const overrideId = extractSchemaIdFromComments(allComments);
14121
+ if (overrideId && schemaIdAliases) {
14122
+ schemaIdAliases[name] = overrideId;
14123
+ if (!typeDefinitions[overrideId]) {
14124
+ typeDefinitions[overrideId] = entry;
14125
+ }
14126
+ }
14127
+ }
14006
14128
  resolvedTraverse(ast, {
14007
14129
  TSTypeAliasDeclaration: (path17) => {
14008
14130
  if (path17.node.id && t12.isIdentifier(path17.node.id)) {
14009
14131
  const name = path17.node.id.name;
14010
- if (!typeDefinitions[name]) {
14011
- const node = path17.node.typeParameters && path17.node.typeParameters.params.length > 0 ? path17.node : path17.node.typeAnnotation;
14012
- typeDefinitions[name] = { node, filePath: currentFile };
14013
- }
14132
+ const node = path17.node.typeParameters && path17.node.typeParameters.params.length > 0 ? path17.node : path17.node.typeAnnotation;
14133
+ const allComments = [
14134
+ ...path17.parentPath?.node?.leadingComments ?? [],
14135
+ ...path17.node.leadingComments ?? [],
14136
+ ...path17.node.trailingComments ?? []
14137
+ ];
14138
+ registerDefinition(name, { node, filePath: currentFile }, allComments);
14014
14139
  }
14015
14140
  },
14016
14141
  TSInterfaceDeclaration: (path17) => {
14017
14142
  if (path17.node.id && t12.isIdentifier(path17.node.id)) {
14018
14143
  const name = path17.node.id.name;
14019
- if (!typeDefinitions[name]) {
14020
- typeDefinitions[name] = { node: path17.node, filePath: currentFile };
14021
- }
14144
+ const allComments = [
14145
+ ...path17.parentPath?.node?.leadingComments ?? [],
14146
+ ...path17.node.leadingComments ?? [],
14147
+ ...path17.node.trailingComments ?? [],
14148
+ ...collectFirstMemberLeadingComments(path17.node)
14149
+ ];
14150
+ registerDefinition(name, { node: path17.node, filePath: currentFile }, allComments);
14022
14151
  }
14023
14152
  },
14024
14153
  TSEnumDeclaration: (path17) => {
14025
14154
  if (path17.node.id && t12.isIdentifier(path17.node.id)) {
14026
14155
  const name = path17.node.id.name;
14027
- if (!typeDefinitions[name]) {
14028
- typeDefinitions[name] = { node: path17.node, filePath: currentFile };
14029
- }
14156
+ const allComments = [
14157
+ ...path17.parentPath?.node?.leadingComments ?? [],
14158
+ ...path17.node.leadingComments ?? [],
14159
+ ...path17.node.trailingComments ?? []
14160
+ ];
14161
+ registerDefinition(name, { node: path17.node, filePath: currentFile }, allComments);
14030
14162
  }
14031
14163
  },
14032
14164
  ExportNamedDeclaration: (path17) => {
@@ -14034,19 +14166,26 @@ function collectAllExportedDefinitions(ast, typeDefinitions, currentFile) {
14034
14166
  const interfaceDecl = path17.node.declaration;
14035
14167
  if (interfaceDecl.id && t12.isIdentifier(interfaceDecl.id)) {
14036
14168
  const name = interfaceDecl.id.name;
14037
- if (!typeDefinitions[name]) {
14038
- typeDefinitions[name] = { node: interfaceDecl, filePath: currentFile };
14039
- }
14169
+ const allComments = [
14170
+ ...path17.node.leadingComments ?? [],
14171
+ ...interfaceDecl.leadingComments ?? [],
14172
+ ...interfaceDecl.trailingComments ?? [],
14173
+ ...collectFirstMemberLeadingComments(interfaceDecl)
14174
+ ];
14175
+ registerDefinition(name, { node: interfaceDecl, filePath: currentFile }, allComments);
14040
14176
  }
14041
14177
  }
14042
14178
  if (t12.isTSTypeAliasDeclaration(path17.node.declaration)) {
14043
14179
  const typeDecl = path17.node.declaration;
14044
14180
  if (typeDecl.id && t12.isIdentifier(typeDecl.id)) {
14045
14181
  const name = typeDecl.id.name;
14046
- if (!typeDefinitions[name]) {
14047
- const node = typeDecl.typeParameters && typeDecl.typeParameters.params.length > 0 ? typeDecl : typeDecl.typeAnnotation;
14048
- typeDefinitions[name] = { node, filePath: currentFile };
14049
- }
14182
+ const node = typeDecl.typeParameters && typeDecl.typeParameters.params.length > 0 ? typeDecl : typeDecl.typeAnnotation;
14183
+ const allComments = [
14184
+ ...path17.node.leadingComments ?? [],
14185
+ ...typeDecl.leadingComments ?? [],
14186
+ ...typeDecl.trailingComments ?? []
14187
+ ];
14188
+ registerDefinition(name, { node, filePath: currentFile }, allComments);
14050
14189
  }
14051
14190
  }
14052
14191
  }
@@ -14463,6 +14602,7 @@ var SchemaProcessor = class {
14463
14602
  zodSchemaProcessor = null;
14464
14603
  schemaTypes;
14465
14604
  isResolvingPickOmitBase = false;
14605
+ schemaIdAliases = {};
14466
14606
  fileAccess;
14467
14607
  symbolResolver;
14468
14608
  // Track imports per file for resolving ReturnType<typeof func>
@@ -14503,7 +14643,7 @@ var SchemaProcessor = class {
14503
14643
  getDefinedSchemas() {
14504
14644
  const filteredSchemas = {};
14505
14645
  Object.entries(this.openapiDefinitions).forEach(([key, value]) => {
14506
- if (!this.isGenericTypeParameter(key) && !this.isInvalidSchemaName(key) && !this.isBuiltInUtilityType(key) && !this.isFunctionSchema(key)) {
14646
+ if (!this.schemaIdAliases[key] && !this.isGenericTypeParameter(key) && !this.isInvalidSchemaName(key) && !this.isBuiltInUtilityType(key) && !this.isFunctionSchema(key)) {
14507
14647
  filteredSchemas[key] = value;
14508
14648
  }
14509
14649
  });
@@ -14518,6 +14658,10 @@ var SchemaProcessor = class {
14518
14658
  if (schemaName.includes("<") && schemaName.includes(">")) {
14519
14659
  return this.resolveGenericTypeFromString(schemaName);
14520
14660
  }
14661
+ const overrideId = this.schemaIdAliases[schemaName];
14662
+ if (overrideId) {
14663
+ return this.findSchemaDefinition(overrideId, contentType);
14664
+ }
14521
14665
  if (this.openapiDefinitions[schemaName]) {
14522
14666
  return this.openapiDefinitions[schemaName];
14523
14667
  }
@@ -14599,6 +14743,7 @@ var SchemaProcessor = class {
14599
14743
  return;
14600
14744
  }
14601
14745
  this.collectImports(ast, filePath);
14746
+ const aliasesBeforeFile = new Set(Object.keys(this.schemaIdAliases));
14602
14747
  this.collectAllExportedDefinitions(ast, filePath);
14603
14748
  collectTopLevelDefinitionNames(ast).forEach((name) => {
14604
14749
  const indexedFiles = this.schemaDefinitionIndex[name];
@@ -14610,6 +14755,16 @@ var SchemaProcessor = class {
14610
14755
  }
14611
14756
  this.schemaDefinitionIndex[name] = [filePath];
14612
14757
  });
14758
+ Object.entries(this.schemaIdAliases).forEach(([originalName, aliasName]) => {
14759
+ if (aliasesBeforeFile.has(originalName))
14760
+ return;
14761
+ if (!this.schemaDefinitionIndex[aliasName]) {
14762
+ this.schemaDefinitionIndex[aliasName] = [];
14763
+ }
14764
+ if (!this.schemaDefinitionIndex[aliasName].includes(filePath)) {
14765
+ this.schemaDefinitionIndex[aliasName].push(filePath);
14766
+ }
14767
+ });
14613
14768
  }
14614
14769
  getParsedSchemaFile(filePath) {
14615
14770
  const cachedAst = this.fileASTCache.get(filePath);
@@ -14648,7 +14803,7 @@ var SchemaProcessor = class {
14648
14803
  * Used when processing imported files to ensure all referenced types are available
14649
14804
  */
14650
14805
  collectAllExportedDefinitions(ast, filePath) {
14651
- collectAllExportedDefinitions(ast, this.typeDefinitions, filePath || this.currentFilePath);
14806
+ collectAllExportedDefinitions(ast, this.typeDefinitions, filePath || this.currentFilePath, this.schemaIdAliases);
14652
14807
  }
14653
14808
  collectTypeDefinitions(ast, schemaName, filePath) {
14654
14809
  collectTypeDefinitions(ast, schemaName, this.typeDefinitions, filePath || this.currentFilePath);
@@ -15245,6 +15400,9 @@ var SchemaProcessor = class {
15245
15400
  logger.debug(`Record<...> used with ${node.typeParameters?.params.length ?? 0} type parameters; expected 2`);
15246
15401
  return { type: "object", additionalProperties: true };
15247
15402
  }
15403
+ if ((!node.typeParameters || node.typeParameters.params.length === 0) && this.schemaIdAliases[typeName] && this.openapiDefinitions[this.schemaIdAliases[typeName]]) {
15404
+ return { $ref: `#/components/schemas/${this.schemaIdAliases[typeName]}` };
15405
+ }
15248
15406
  const utilityType = resolveUtilityTypeReference(node, {
15249
15407
  currentFilePath: this.currentFilePath,
15250
15408
  contentType: this.contentType,
@@ -15420,7 +15578,9 @@ var SchemaProcessor = class {
15420
15578
  };
15421
15579
  }
15422
15580
  if (t15.isTSTypeReference(node) && t15.isIdentifier(node.typeName)) {
15423
- return { $ref: `#/components/schemas/${node.typeName.name}` };
15581
+ const refName = node.typeName.name;
15582
+ const aliasedName = this.schemaIdAliases[refName] ?? refName;
15583
+ return { $ref: `#/components/schemas/${aliasedName}` };
15424
15584
  }
15425
15585
  logger.debug("Unrecognized TypeScript type node:", node);
15426
15586
  return { type: "object" };
@@ -15561,7 +15721,8 @@ var SchemaProcessor = class {
15561
15721
  if (this.schemaTypes.includes("zod") && this.zodSchemaConverter) {
15562
15722
  return this.zodSchemaConverter.getSchemaReferenceName(baseTypeName, contentType);
15563
15723
  }
15564
- return baseTypeName;
15724
+ const aliasedName = this.schemaIdAliases[baseTypeName] ?? baseTypeName;
15725
+ return aliasedName;
15565
15726
  }
15566
15727
  /**
15567
15728
  * Parse and resolve a generic type from a string like "MyApiSuccessResponseBody<LLMSResponse>"