next-openapi-gen 1.3.0 → 1.4.1

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 CHANGED
@@ -588,122 +588,6 @@ import fse2 from "fs-extra";
588
588
  import path16 from "path";
589
589
  import fs12 from "fs";
590
590
 
591
- // ../openapi-core/dist/config/normalize.js
592
- function normalizeRouterType(routerType) {
593
- return routerType ?? DEFAULT_ROUTER_TYPE;
594
- }
595
- function normalizeSchemaTypes(schemaType) {
596
- const schemaBackends = Array.isArray(schemaType) ? schemaType : [schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE];
597
- return [...new Set(schemaBackends)];
598
- }
599
- function normalizeOpenApiVersion(template) {
600
- if (template.openapi.startsWith("3.2")) {
601
- return "3.2";
602
- }
603
- if (template.openapi.startsWith("3.1")) {
604
- return "3.1";
605
- }
606
- if (template.openapi.startsWith("4.")) {
607
- return "4.0";
608
- }
609
- return DEFAULT_OPENAPI_VERSION;
610
- }
611
- function normalizeFrameworkKind(kind) {
612
- switch (kind) {
613
- case FrameworkKind.Nextjs:
614
- case "next":
615
- return FrameworkKind.Nextjs;
616
- case FrameworkKind.Tanstack:
617
- case "tanstack":
618
- return FrameworkKind.Tanstack;
619
- case FrameworkKind.ReactRouter:
620
- case "react-router":
621
- return FrameworkKind.ReactRouter;
622
- default:
623
- return FrameworkKind.Nextjs;
624
- }
625
- }
626
- function normalizeFramework(config2, routerType) {
627
- if (config2.framework) {
628
- const frameworkKind = normalizeFrameworkKind(config2.framework.kind);
629
- switch (frameworkKind) {
630
- case FrameworkKind.Nextjs:
631
- return {
632
- ...config2.framework,
633
- kind: frameworkKind,
634
- router: config2.framework.router || routerType,
635
- modulePath: config2.framework.modulePath || config2.framework.adapterPath || config2.next?.adapterPath,
636
- adapterPath: config2.framework.adapterPath || config2.next?.adapterPath
637
- };
638
- case FrameworkKind.Tanstack:
639
- case FrameworkKind.ReactRouter:
640
- return {
641
- ...config2.framework,
642
- kind: frameworkKind,
643
- modulePath: config2.framework.modulePath || config2.framework.adapterPath
644
- };
645
- }
646
- }
647
- return {
648
- kind: FrameworkKind.Nextjs,
649
- router: routerType,
650
- modulePath: config2.next?.adapterPath,
651
- adapterPath: config2.next?.adapterPath
652
- };
653
- }
654
- function normalizeOpenApiConfig(template) {
655
- const routerType = normalizeRouterType(template.routerType);
656
- const schemaBackends = normalizeSchemaTypes(template.schemaType);
657
- const openapiVersion = normalizeOpenApiVersion({
658
- openapi: "openapi" in template ? template.openapi || "3.0.0" : "3.0.0"
659
- });
660
- return {
661
- apiDir: template.apiDir ?? DEFAULT_API_DIR,
662
- routerType,
663
- schemaDir: template.schemaDir ?? DEFAULT_SCHEMA_DIR,
664
- docsUrl: template.docsUrl ?? DEFAULT_DOCS_URL,
665
- ui: template.ui ?? DEFAULT_UI,
666
- outputFile: template.outputFile ?? DEFAULT_GENERATED_OPENAPI_FILENAME,
667
- outputDir: template.outputDir ?? DEFAULT_OUTPUT_DIR,
668
- includeOpenApiRoutes: template.includeOpenApiRoutes ?? DEFAULT_INCLUDE_OPENAPI_ROUTES,
669
- ignoreRoutes: template.ignoreRoutes ?? [],
670
- excludeSchemas: template.excludeSchemas ?? [],
671
- schemaType: template.schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE,
672
- schemaBackends,
673
- schemaFiles: template.schemaFiles ?? [],
674
- defaultResponseSet: template.defaultResponseSet,
675
- responseSets: template.responseSets,
676
- errorConfig: template.errorConfig,
677
- errorDefinitions: template.errorDefinitions,
678
- openapiVersion,
679
- framework: normalizeFramework(template, routerType),
680
- next: {
681
- adapterPath: template.next?.adapterPath
682
- },
683
- diagnostics: template.diagnostics ?? { enabled: DEFAULT_DIAGNOSTICS_ENABLED },
684
- debug: template.debug ?? DEFAULT_DEBUG
685
- };
686
- }
687
-
688
- // ../openapi-core/dist/diagnostics/collector.js
689
- var DiagnosticsCollector = class {
690
- diagnostics = [];
691
- add(diagnostic) {
692
- this.diagnostics.push(diagnostic);
693
- }
694
- getAll() {
695
- return [...this.diagnostics];
696
- }
697
- hasAny() {
698
- return this.diagnostics.length > 0;
699
- }
700
- };
701
-
702
- // ../openapi-core/dist/openapi/document.js
703
- function createDocumentFromTemplate(template) {
704
- return structuredClone(template);
705
- }
706
-
707
591
  // ../openapi-core/dist/shared/utils.js
708
592
  import { parse } from "@babel/parser";
709
593
  import * as t from "@babel/types";
@@ -1039,7 +923,7 @@ function parseJSDocBlock(commentValue, filePath) {
1039
923
  result.cookieType = extractTypeFromComment(normalizedComment, "@cookie");
1040
924
  const authValue = extractLineValue(normalizedComment, "@auth");
1041
925
  if (authValue) {
1042
- result.auth = performAuthPresetReplacements(authValue);
926
+ result.auth = authValue;
1043
927
  }
1044
928
  const querystring = parseQuerystringTag(normalizedComment);
1045
929
  if (querystring) {
@@ -1715,16 +1599,17 @@ var INTERNAL_OPENAPI_CONFIG_KEYS = [
1715
1599
  "next",
1716
1600
  "diagnostics",
1717
1601
  "debug",
1602
+ "authPresets",
1718
1603
  "excludeSchemas"
1719
1604
  ];
1720
- var AUTH_PRESET_REPLACEMENTS = {
1605
+ var DEFAULT_AUTH_PRESET_REPLACEMENTS = {
1721
1606
  bearer: "BearerAuth",
1722
1607
  basic: "BasicAuth",
1723
1608
  apikey: "ApiKeyAuth"
1724
1609
  };
1725
- function performAuthPresetReplacements(authValue) {
1610
+ function performAuthPresetReplacements(authValue, presets = DEFAULT_AUTH_PRESET_REPLACEMENTS) {
1726
1611
  const authParts = authValue.split(",").map((part) => part.trim());
1727
- const mappedParts = authParts.map((part) => AUTH_PRESET_REPLACEMENTS[part.toLowerCase()] || part);
1612
+ const mappedParts = authParts.map((part) => presets[part.toLowerCase()] || part);
1728
1613
  return mappedParts.join(",");
1729
1614
  }
1730
1615
  function getOperationId(routePath, method) {
@@ -1742,6 +1627,123 @@ function parseTypeScriptFile(content, options) {
1742
1627
  });
1743
1628
  }
1744
1629
 
1630
+ // ../openapi-core/dist/config/normalize.js
1631
+ function normalizeRouterType(routerType) {
1632
+ return routerType ?? DEFAULT_ROUTER_TYPE;
1633
+ }
1634
+ function normalizeSchemaTypes(schemaType) {
1635
+ const schemaBackends = Array.isArray(schemaType) ? schemaType : [schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE];
1636
+ return [...new Set(schemaBackends)];
1637
+ }
1638
+ function normalizeOpenApiVersion(template) {
1639
+ if (template.openapi.startsWith("3.2")) {
1640
+ return "3.2";
1641
+ }
1642
+ if (template.openapi.startsWith("3.1")) {
1643
+ return "3.1";
1644
+ }
1645
+ if (template.openapi.startsWith("4.")) {
1646
+ return "4.0";
1647
+ }
1648
+ return DEFAULT_OPENAPI_VERSION;
1649
+ }
1650
+ function normalizeFrameworkKind(kind) {
1651
+ switch (kind) {
1652
+ case FrameworkKind.Nextjs:
1653
+ case "next":
1654
+ return FrameworkKind.Nextjs;
1655
+ case FrameworkKind.Tanstack:
1656
+ case "tanstack":
1657
+ return FrameworkKind.Tanstack;
1658
+ case FrameworkKind.ReactRouter:
1659
+ case "react-router":
1660
+ return FrameworkKind.ReactRouter;
1661
+ default:
1662
+ return FrameworkKind.Nextjs;
1663
+ }
1664
+ }
1665
+ function normalizeFramework(config2, routerType) {
1666
+ if (config2.framework) {
1667
+ const frameworkKind = normalizeFrameworkKind(config2.framework.kind);
1668
+ switch (frameworkKind) {
1669
+ case FrameworkKind.Nextjs:
1670
+ return {
1671
+ ...config2.framework,
1672
+ kind: frameworkKind,
1673
+ router: config2.framework.router || routerType,
1674
+ modulePath: config2.framework.modulePath || config2.framework.adapterPath || config2.next?.adapterPath,
1675
+ adapterPath: config2.framework.adapterPath || config2.next?.adapterPath
1676
+ };
1677
+ case FrameworkKind.Tanstack:
1678
+ case FrameworkKind.ReactRouter:
1679
+ return {
1680
+ ...config2.framework,
1681
+ kind: frameworkKind,
1682
+ modulePath: config2.framework.modulePath || config2.framework.adapterPath
1683
+ };
1684
+ }
1685
+ }
1686
+ return {
1687
+ kind: FrameworkKind.Nextjs,
1688
+ router: routerType,
1689
+ modulePath: config2.next?.adapterPath,
1690
+ adapterPath: config2.next?.adapterPath
1691
+ };
1692
+ }
1693
+ function normalizeOpenApiConfig(template) {
1694
+ const routerType = normalizeRouterType(template.routerType);
1695
+ const schemaBackends = normalizeSchemaTypes(template.schemaType);
1696
+ const openapiVersion = normalizeOpenApiVersion({
1697
+ openapi: "openapi" in template ? template.openapi || "3.0.0" : "3.0.0"
1698
+ });
1699
+ return {
1700
+ apiDir: template.apiDir ?? DEFAULT_API_DIR,
1701
+ routerType,
1702
+ schemaDir: template.schemaDir ?? DEFAULT_SCHEMA_DIR,
1703
+ docsUrl: template.docsUrl ?? DEFAULT_DOCS_URL,
1704
+ ui: template.ui ?? DEFAULT_UI,
1705
+ outputFile: template.outputFile ?? DEFAULT_GENERATED_OPENAPI_FILENAME,
1706
+ outputDir: template.outputDir ?? DEFAULT_OUTPUT_DIR,
1707
+ includeOpenApiRoutes: template.includeOpenApiRoutes ?? DEFAULT_INCLUDE_OPENAPI_ROUTES,
1708
+ ignoreRoutes: template.ignoreRoutes ?? [],
1709
+ excludeSchemas: template.excludeSchemas ?? [],
1710
+ schemaType: template.schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE,
1711
+ schemaBackends,
1712
+ schemaFiles: template.schemaFiles ?? [],
1713
+ defaultResponseSet: template.defaultResponseSet,
1714
+ responseSets: template.responseSets,
1715
+ errorConfig: template.errorConfig,
1716
+ errorDefinitions: template.errorDefinitions,
1717
+ openapiVersion,
1718
+ framework: normalizeFramework(template, routerType),
1719
+ next: {
1720
+ adapterPath: template.next?.adapterPath
1721
+ },
1722
+ diagnostics: template.diagnostics ?? { enabled: DEFAULT_DIAGNOSTICS_ENABLED },
1723
+ authPresets: { ...DEFAULT_AUTH_PRESET_REPLACEMENTS, ...template.authPresets },
1724
+ debug: template.debug ?? DEFAULT_DEBUG
1725
+ };
1726
+ }
1727
+
1728
+ // ../openapi-core/dist/diagnostics/collector.js
1729
+ var DiagnosticsCollector = class {
1730
+ diagnostics = [];
1731
+ add(diagnostic) {
1732
+ this.diagnostics.push(diagnostic);
1733
+ }
1734
+ getAll() {
1735
+ return [...this.diagnostics];
1736
+ }
1737
+ hasAny() {
1738
+ return this.diagnostics.length > 0;
1739
+ }
1740
+ };
1741
+
1742
+ // ../openapi-core/dist/openapi/document.js
1743
+ function createDocumentFromTemplate(template) {
1744
+ return structuredClone(template);
1745
+ }
1746
+
1745
1747
  // ../openapi-core/dist/openapi/version-processor.js
1746
1748
  var DefaultOpenApiVersionProcessor = class {
1747
1749
  id;
@@ -2200,8 +2202,10 @@ function downgradeSchemaForOpenApi30(schema, mediaTypeName) {
2200
2202
  const nullableBranch = nextSchema.anyOf.find((item) => item.type === "null");
2201
2203
  const baseBranch = nextSchema.anyOf.find((item) => item.type !== "null");
2202
2204
  if (nullableBranch && baseBranch) {
2205
+ const { anyOf: _anyOf, ...outerMeta } = nextSchema;
2203
2206
  nextSchema = {
2204
2207
  ...structuredClone(baseBranch),
2208
+ ...outerMeta,
2205
2209
  nullable: true
2206
2210
  };
2207
2211
  }
@@ -4116,7 +4120,7 @@ function processZodLiteral(node, context) {
4116
4120
  return { type: "string", enum: [arg.value] };
4117
4121
  }
4118
4122
  if (t8.isNumericLiteral(arg)) {
4119
- return { type: "number", enum: [arg.value] };
4123
+ return { type: Number.isInteger(arg.value) ? "integer" : "number", enum: [arg.value] };
4120
4124
  }
4121
4125
  if (t8.isBooleanLiteral(arg)) {
4122
4126
  return { type: "boolean", enum: [arg.value] };
@@ -4132,7 +4136,7 @@ function processZodLiteral(node, context) {
4132
4136
  if (typeof value === "string")
4133
4137
  return { type: "string", enum: [value] };
4134
4138
  if (typeof value === "number")
4135
- return { type: "number", enum: [value] };
4139
+ return { type: Number.isInteger(value) ? "integer" : "number", enum: [value] };
4136
4140
  if (typeof value === "boolean")
4137
4141
  return { type: "boolean", enum: [value] };
4138
4142
  if (value === null)
@@ -4227,7 +4231,7 @@ function processZodTuple(node, processNode, context) {
4227
4231
  if (t8.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
4228
4232
  const values = context.resolveConstArrayValues(node.arguments[0].name);
4229
4233
  if (values && values.length > 0) {
4230
- const prefixItems = values.map((value) => typeof value === "number" ? { type: "number", enum: [value] } : { type: "string", enum: [value] });
4234
+ const prefixItems = values.map((value) => typeof value === "number" ? { type: Number.isInteger(value) ? "integer" : "number", enum: [value] } : { type: "string", enum: [value] });
4231
4235
  return {
4232
4236
  type: "array",
4233
4237
  prefixItems,
@@ -4271,7 +4275,7 @@ function processZodUnion(node, processNode, context) {
4271
4275
  if (t8.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
4272
4276
  const values = context.resolveConstArrayValues(node.arguments[0].name);
4273
4277
  if (values && values.length > 0) {
4274
- const type = typeof values[0] === "number" ? "number" : "string";
4278
+ const type = typeof values[0] === "number" ? Number.isInteger(values[0]) ? "integer" : "number" : "string";
4275
4279
  return { type, enum: values };
4276
4280
  }
4277
4281
  }
@@ -11718,8 +11722,17 @@ var ZodRuntimeExporter = class {
11718
11722
  return node.arguments[0] ? literal(this.buildLiteralValue(node.arguments[0])) : null;
11719
11723
  case "enum":
11720
11724
  return this.buildEnum(node);
11721
- case "array":
11722
- return node.arguments[0] && isProcessableNode(node.arguments[0]) ? array(this.buildSchema(node.arguments[0]) ?? unknown()) : array(unknown());
11725
+ case "array": {
11726
+ const arg = node.arguments[0];
11727
+ if (!arg || !isProcessableNode(arg)) {
11728
+ return array(unknown());
11729
+ }
11730
+ const itemSchema = this.buildSchema(arg);
11731
+ if (!itemSchema) {
11732
+ return null;
11733
+ }
11734
+ return array(itemSchema);
11735
+ }
11723
11736
  case "strictObject": {
11724
11737
  const base = this.buildObject(node);
11725
11738
  return base && typeof base.strict === "function" ? base.strict() : base;
@@ -11851,13 +11864,17 @@ var ZodRuntimeExporter = class {
11851
11864
  if (node.arguments.length === 0 || !t9.isArrayExpression(node.arguments[0])) {
11852
11865
  return tuple([]);
11853
11866
  }
11854
- const items = node.arguments[0].elements.flatMap((element) => {
11867
+ const items = [];
11868
+ for (const element of node.arguments[0].elements) {
11855
11869
  if (!isProcessableNode(element)) {
11856
- return [];
11870
+ return null;
11857
11871
  }
11858
11872
  const schema = this.buildSchema(element);
11859
- return schema ? [schema] : [];
11860
- });
11873
+ if (!schema) {
11874
+ return null;
11875
+ }
11876
+ items.push(schema);
11877
+ }
11861
11878
  return tuple(items);
11862
11879
  }
11863
11880
  buildTemplateLiteral(node) {
@@ -12469,7 +12486,12 @@ var ZodSchemaConverter = class {
12469
12486
  if (this.isZodSchema(path25.node.init)) {
12470
12487
  const schema = this.processZodNode(path25.node.init);
12471
12488
  if (schema) {
12472
- this.storeResolvedSchema(schemaName, schema);
12489
+ const overrideId = this.extractMetaIdFromNode(path25.node.init);
12490
+ if (overrideId) {
12491
+ this.applyMetaIdOverride(schemaName, schema, overrideId, filePath);
12492
+ } else {
12493
+ this.storeResolvedSchema(schemaName, schema);
12494
+ }
12473
12495
  }
12474
12496
  return;
12475
12497
  }
@@ -12812,8 +12834,15 @@ var ZodSchemaConverter = class {
12812
12834
  };
12813
12835
  switch (methodName) {
12814
12836
  case "optional":
12837
+ break;
12815
12838
  case "nullable":
12816
12839
  case "nullish":
12840
+ schema = {
12841
+ anyOf: [
12842
+ { $ref: `#/components/schemas/${this.getSchemaReferenceName(schemaName)}` },
12843
+ { type: "null" }
12844
+ ]
12845
+ };
12817
12846
  break;
12818
12847
  case "describe":
12819
12848
  if (node.arguments.length > 0 && t10.isStringLiteral(node.arguments[0])) {
@@ -13308,7 +13337,7 @@ var ZodSchemaConverter = class {
13308
13337
  return helperName.startsWith("coerce.") || helperName === "templateLiteral" || helperName === "stringbool";
13309
13338
  }
13310
13339
  if (t10.isMemberExpression(node.callee) && t10.isIdentifier(node.callee.property)) {
13311
- const runtimeMethods = /* @__PURE__ */ new Set(["pipe", "meta"]);
13340
+ const runtimeMethods = /* @__PURE__ */ new Set(["pipe"]);
13312
13341
  if (runtimeMethods.has(node.callee.property.name)) {
13313
13342
  return true;
13314
13343
  }
@@ -13331,12 +13360,16 @@ var ZodSchemaConverter = class {
13331
13360
  case "optional":
13332
13361
  break;
13333
13362
  case "nullable":
13334
- if (!schema.allOf) {
13363
+ if (schema.allOf) {
13364
+ schema = { anyOf: [...schema.allOf, { type: "null" }] };
13365
+ } else {
13335
13366
  schema.nullable = true;
13336
13367
  }
13337
13368
  break;
13338
13369
  case "nullish":
13339
- if (!schema.allOf) {
13370
+ if (schema.allOf) {
13371
+ schema = { anyOf: [...schema.allOf, { type: "null" }] };
13372
+ } else {
13340
13373
  schema.nullable = true;
13341
13374
  }
13342
13375
  break;
@@ -13481,15 +13514,13 @@ var ZodSchemaConverter = class {
13481
13514
  schema.type = "integer";
13482
13515
  break;
13483
13516
  case "positive":
13484
- schema.minimum = 0;
13485
- schema.exclusiveMinimum = true;
13517
+ schema.exclusiveMinimum = 0;
13486
13518
  break;
13487
13519
  case "nonnegative":
13488
13520
  schema.minimum = 0;
13489
13521
  break;
13490
13522
  case "negative":
13491
- schema.maximum = 0;
13492
- schema.exclusiveMaximum = true;
13523
+ schema.exclusiveMaximum = 0;
13493
13524
  break;
13494
13525
  case "nonpositive":
13495
13526
  schema.maximum = 0;
@@ -13851,6 +13882,9 @@ var ZodSchemaConverter = class {
13851
13882
  if (!this.getStoredSchema(schemaName)) {
13852
13883
  logger.debug(`Pre-processing Zod schema: ${schemaName}`);
13853
13884
  this.processingSchemas.add(schemaName);
13885
+ this.currentFilePath = filePath;
13886
+ this.currentAST = ast;
13887
+ this.currentImports = importedModules;
13854
13888
  const schema = this.processZodNode(declaration.init);
13855
13889
  this.processingSchemas.delete(schemaName);
13856
13890
  if (schema) {
@@ -13883,6 +13917,9 @@ var ZodSchemaConverter = class {
13883
13917
  if (!this.getStoredSchema(schemaName) && !this.processingSchemas.has(schemaName)) {
13884
13918
  logger.debug(`Pre-processing Zod schema: ${schemaName}`);
13885
13919
  this.processingSchemas.add(schemaName);
13920
+ this.currentFilePath = filePath;
13921
+ this.currentAST = ast;
13922
+ this.currentImports = importedModules;
13886
13923
  const schema = this.processZodNode(declaration.init);
13887
13924
  this.processingSchemas.delete(schemaName);
13888
13925
  if (schema) {
@@ -16753,11 +16790,16 @@ var ResponseProcessor = class {
16753
16790
  var OperationProcessor = class {
16754
16791
  schemaProcessor;
16755
16792
  responseProcessor;
16793
+ authPresets;
16756
16794
  performanceProfile;
16757
- constructor(schemaProcessor, responseProcessor, performanceProfile) {
16795
+ constructor(schemaProcessor, responseProcessor, options = {}) {
16758
16796
  this.schemaProcessor = schemaProcessor;
16759
16797
  this.responseProcessor = responseProcessor;
16760
- this.performanceProfile = performanceProfile;
16798
+ this.authPresets = {
16799
+ ...DEFAULT_AUTH_PRESET_REPLACEMENTS,
16800
+ ...options.authPresets
16801
+ };
16802
+ this.performanceProfile = options.performanceProfile;
16761
16803
  }
16762
16804
  processOperation(varName, routePath, dataTypes, pathParamNames = []) {
16763
16805
  const method = varName.toLowerCase();
@@ -16782,9 +16824,10 @@ var OperationProcessor = class {
16782
16824
  definition.deprecated = true;
16783
16825
  }
16784
16826
  if (explicitSecurity && explicitSecurity.length > 0) {
16785
- definition.security = explicitSecurity;
16827
+ definition.security = explicitSecurity.map((req) => Object.fromEntries(Object.entries(req).map(([scheme, scopes]) => [this.applyPreset(scheme), scopes])));
16786
16828
  } else if (auth) {
16787
- const authItems = auth.split(",").map((item) => item.trim());
16829
+ const mapped = performAuthPresetReplacements(auth, this.authPresets);
16830
+ const authItems = mapped.split(",").map((item) => item.trim());
16788
16831
  definition.security = authItems.map((authItem) => ({
16789
16832
  [authItem]: []
16790
16833
  }));
@@ -16997,6 +17040,9 @@ ${suffix}`;
16997
17040
  response.links[link.name] = linkObject;
16998
17041
  }
16999
17042
  }
17043
+ applyPreset(scheme) {
17044
+ return this.authPresets[scheme.toLowerCase()] ?? scheme;
17045
+ }
17000
17046
  createQuerystringParameter(dataTypes) {
17001
17047
  if (!dataTypes.querystringType) {
17002
17048
  return void 0;
@@ -17085,7 +17131,10 @@ var RouteProcessor = class {
17085
17131
  return new RegExp(`^${regexPattern}$`);
17086
17132
  });
17087
17133
  this.responseProcessor = new ResponseProcessor(this.config, this.schemaProcessor);
17088
- this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor, this.performanceProfile);
17134
+ this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor, {
17135
+ authPresets: this.config.authPresets,
17136
+ performanceProfile: this.performanceProfile
17137
+ });
17089
17138
  }
17090
17139
  processResponsesFromConfig(dataTypes, method) {
17091
17140
  return this.responseProcessor.processResponses(dataTypes, method);
@@ -17327,6 +17376,7 @@ function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
17327
17376
  if (excludedNames.size === 0)
17328
17377
  return;
17329
17378
  walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
17379
+ walkAndInline(mergedSchemas, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
17330
17380
  for (const name of excludedNames) {
17331
17381
  delete mergedSchemas[name];
17332
17382
  }
@@ -18106,96 +18156,100 @@ function typeToOpenApiSchema(type, checker, seen) {
18106
18156
  return { type: "object" };
18107
18157
  }
18108
18158
  seen.add(seenKey);
18109
- if (type.isStringLiteral()) {
18110
- return { type: "string", enum: [type.value] };
18111
- }
18112
- if (type.isNumberLiteral()) {
18113
- return { type: "number", enum: [type.value] };
18114
- }
18115
- if (type.flags & ts3.TypeFlags.BooleanLiteral) {
18116
- return {
18117
- type: "boolean",
18118
- enum: [checker.typeToString(type) === "true"]
18119
- };
18120
- }
18121
- if (type.flags & ts3.TypeFlags.TemplateLiteral) {
18122
- return { type: "string" };
18123
- }
18124
- if (type.flags & ts3.TypeFlags.StringLike) {
18125
- return { type: "string" };
18126
- }
18127
- if (type.flags & ts3.TypeFlags.NumberLike) {
18128
- return { type: "number" };
18129
- }
18130
- if (type.flags & ts3.TypeFlags.BooleanLike) {
18131
- return { type: "boolean" };
18132
- }
18133
- if (type.flags & ts3.TypeFlags.Null) {
18134
- return { type: "null" };
18135
- }
18136
- if (type.isUnion()) {
18137
- const nullable2 = type.types.some((member) => member.flags & ts3.TypeFlags.Null);
18138
- const nonNullTypes = type.types.filter((member) => !(member.flags & ts3.TypeFlags.Null));
18139
- const soleNonNullType = nonNullTypes[0];
18140
- if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
18159
+ try {
18160
+ if (type.isStringLiteral()) {
18161
+ return { type: "string", enum: [type.value] };
18162
+ }
18163
+ if (type.isNumberLiteral()) {
18164
+ return { type: "number", enum: [type.value] };
18165
+ }
18166
+ if (type.flags & ts3.TypeFlags.BooleanLiteral) {
18141
18167
  return {
18142
- ...typeToOpenApiSchema(soleNonNullType, checker, seen),
18143
- nullable: true
18168
+ type: "boolean",
18169
+ enum: [checker.typeToString(type) === "true"]
18144
18170
  };
18145
18171
  }
18146
- return {
18147
- oneOf: nonNullTypes.map((member) => typeToOpenApiSchema(member, checker, seen))
18148
- };
18149
- }
18150
- if (checker.isTupleType(type)) {
18151
- const itemTypes = checker.getTypeArguments(type);
18152
- return {
18153
- type: "array",
18154
- prefixItems: itemTypes.map((itemType) => typeToOpenApiSchema(itemType, checker, seen)),
18155
- items: false,
18156
- minItems: itemTypes.length,
18157
- maxItems: itemTypes.length
18158
- };
18159
- }
18160
- if (checker.isArrayType(type)) {
18161
- const elementType = checker.getTypeArguments(type)[0];
18162
- return {
18163
- type: "array",
18164
- items: elementType ? typeToOpenApiSchema(elementType, checker, seen) : { type: "object" }
18165
- };
18166
- }
18167
- const properties = checker.getPropertiesOfType(type);
18168
- if (properties.length > 0) {
18169
- const schemaProperties = {};
18170
- const required2 = [];
18171
- properties.forEach((property) => {
18172
- const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
18173
- if (!propertyDeclaration) {
18174
- return;
18175
- }
18176
- const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
18177
- schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
18178
- if (!(property.flags & ts3.SymbolFlags.Optional)) {
18179
- required2.push(property.getName());
18172
+ if (type.flags & ts3.TypeFlags.TemplateLiteral) {
18173
+ return { type: "string" };
18174
+ }
18175
+ if (type.flags & ts3.TypeFlags.StringLike) {
18176
+ return { type: "string" };
18177
+ }
18178
+ if (type.flags & ts3.TypeFlags.NumberLike) {
18179
+ return { type: "number" };
18180
+ }
18181
+ if (type.flags & ts3.TypeFlags.BooleanLike) {
18182
+ return { type: "boolean" };
18183
+ }
18184
+ if (type.flags & ts3.TypeFlags.Null) {
18185
+ return { type: "null" };
18186
+ }
18187
+ if (type.isUnion()) {
18188
+ const nullable2 = type.types.some((member) => member.flags & ts3.TypeFlags.Null);
18189
+ const nonNullTypes = type.types.filter((member) => !(member.flags & ts3.TypeFlags.Null));
18190
+ const soleNonNullType = nonNullTypes[0];
18191
+ if (nullable2 && soleNonNullType && nonNullTypes.length === 1) {
18192
+ return {
18193
+ ...typeToOpenApiSchema(soleNonNullType, checker, seen),
18194
+ nullable: true
18195
+ };
18180
18196
  }
18181
- });
18182
- return required2.length > 0 ? {
18183
- type: "object",
18184
- properties: schemaProperties,
18185
- required: required2
18186
- } : {
18187
- type: "object",
18188
- properties: schemaProperties
18189
- };
18190
- }
18191
- const stringIndexType = type.getStringIndexType();
18192
- if (stringIndexType) {
18193
- return {
18194
- type: "object",
18195
- additionalProperties: typeToOpenApiSchema(stringIndexType, checker, seen)
18196
- };
18197
+ return {
18198
+ oneOf: nonNullTypes.map((member) => typeToOpenApiSchema(member, checker, seen))
18199
+ };
18200
+ }
18201
+ if (checker.isTupleType(type)) {
18202
+ const itemTypes = checker.getTypeArguments(type);
18203
+ return {
18204
+ type: "array",
18205
+ prefixItems: itemTypes.map((itemType) => typeToOpenApiSchema(itemType, checker, seen)),
18206
+ items: false,
18207
+ minItems: itemTypes.length,
18208
+ maxItems: itemTypes.length
18209
+ };
18210
+ }
18211
+ if (checker.isArrayType(type)) {
18212
+ const elementType = checker.getTypeArguments(type)[0];
18213
+ return {
18214
+ type: "array",
18215
+ items: elementType ? typeToOpenApiSchema(elementType, checker, seen) : { type: "object" }
18216
+ };
18217
+ }
18218
+ const properties = checker.getPropertiesOfType(type);
18219
+ if (properties.length > 0) {
18220
+ const schemaProperties = {};
18221
+ const required2 = [];
18222
+ properties.forEach((property) => {
18223
+ const propertyDeclaration = property.valueDeclaration || property.declarations?.[0];
18224
+ if (!propertyDeclaration) {
18225
+ return;
18226
+ }
18227
+ const propertyType = checker.getTypeOfSymbolAtLocation(property, propertyDeclaration);
18228
+ schemaProperties[property.getName()] = typeToOpenApiSchema(propertyType, checker, seen);
18229
+ if (!(property.flags & ts3.SymbolFlags.Optional)) {
18230
+ required2.push(property.getName());
18231
+ }
18232
+ });
18233
+ return required2.length > 0 ? {
18234
+ type: "object",
18235
+ properties: schemaProperties,
18236
+ required: required2
18237
+ } : {
18238
+ type: "object",
18239
+ properties: schemaProperties
18240
+ };
18241
+ }
18242
+ const stringIndexType = type.getStringIndexType();
18243
+ if (stringIndexType) {
18244
+ return {
18245
+ type: "object",
18246
+ additionalProperties: typeToOpenApiSchema(stringIndexType, checker, seen)
18247
+ };
18248
+ }
18249
+ return { type: "object" };
18250
+ } finally {
18251
+ seen.delete(seenKey);
18197
18252
  }
18198
- return { type: "object" };
18199
18253
  }
18200
18254
  function unwrapPromiseType(type, checker) {
18201
18255
  const symbolName = type.getSymbol()?.getName();