@trpc/openapi 11.18.1-canary.9 → 11.19.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,10 +1,9 @@
1
- import { __toESM } from "./chunk-CJ2cON1m.mjs";
2
- import { require_objectSpread2 } from "./objectSpread2-Blgb1OZh.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { t as _objectSpread2 } from "./objectSpread2-Dh4InpQf.mjs";
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import * as ts from "typescript";
6
6
  import { pathToFileURL } from "node:url";
7
-
8
7
  //#region src/schemaExtraction.ts
9
8
  /**
10
9
  * Zod v4 stores `.describe()` strings in `globalThis.__zod_globalRegistry`,
@@ -34,7 +33,7 @@ function zodArrayElement(schema) {
34
33
  return null;
35
34
  }
36
35
  /** Wrapper def types whose inner schema is accessible via `innerType` or `in`. */
37
- const wrapperDefTypes = new Set([
36
+ const wrapperDefTypes = /* @__PURE__ */ new Set([
38
37
  "optional",
39
38
  "nullable",
40
39
  "nonoptional",
@@ -120,13 +119,13 @@ function walkZodShape(schema, prefix, ctx) {
120
119
  if (!shape) return;
121
120
  for (const [key, fieldSchema] of Object.entries(shape)) {
122
121
  var _meta$description;
123
- const path$1 = prefix ? `${prefix}.${key}` : key;
122
+ const path = prefix ? `${prefix}.${key}` : key;
124
123
  const meta = ctx.registry.get(fieldSchema);
125
124
  const unwrappedField = unwrapZodSchema(fieldSchema);
126
125
  const innerMeta = unwrappedField !== fieldSchema ? ctx.registry.get(unwrappedField) : void 0;
127
126
  const description = (_meta$description = meta === null || meta === void 0 ? void 0 : meta.description) !== null && _meta$description !== void 0 ? _meta$description : innerMeta === null || innerMeta === void 0 ? void 0 : innerMeta.description;
128
- if (description) ctx.map.properties.set(path$1, description);
129
- walkZodShape(unwrappedField, path$1, ctx);
127
+ if (description) ctx.map.properties.set(path, description);
128
+ walkZodShape(unwrappedField, path, ctx);
130
129
  }
131
130
  }
132
131
  /** Check whether a value looks like a tRPC router instance at runtime. */
@@ -158,8 +157,7 @@ function findRouterExport(mod, exportName) {
158
157
  */
159
158
  async function tryImportRouter(resolvedPath, exportName) {
160
159
  try {
161
- const mod = await import(pathToFileURL(resolvedPath).href);
162
- return findRouterExport(mod, exportName);
160
+ return findRouterExport(await import(pathToFileURL(resolvedPath).href), exportName);
163
161
  } catch (_unused) {
164
162
  return null;
165
163
  }
@@ -247,9 +245,8 @@ function setNestedDescription({ schema, pathParts, description, schemas }) {
247
245
  if (rest.length === 0) setLeafDescription(items, description);
248
246
  else {
249
247
  var _resolveSchemaRef;
250
- const target = (_resolveSchemaRef = resolveSchemaRef(items, schemas)) !== null && _resolveSchemaRef !== void 0 ? _resolveSchemaRef : items;
251
248
  setNestedDescription({
252
- schema: target,
249
+ schema: (_resolveSchemaRef = resolveSchemaRef(items, schemas)) !== null && _resolveSchemaRef !== void 0 ? _resolveSchemaRef : items,
253
250
  pathParts: rest,
254
251
  description,
255
252
  schemas
@@ -263,19 +260,16 @@ function setNestedDescription({ schema, pathParts, description, schemas }) {
263
260
  else {
264
261
  var _getArrayItemsSchema, _resolveSchemaRef2;
265
262
  const target = (_getArrayItemsSchema = getArrayItemsSchema(propSchema)) !== null && _getArrayItemsSchema !== void 0 ? _getArrayItemsSchema : propSchema;
266
- const resolvedTarget = (_resolveSchemaRef2 = resolveSchemaRef(target, schemas)) !== null && _resolveSchemaRef2 !== void 0 ? _resolveSchemaRef2 : target;
267
263
  setNestedDescription({
268
- schema: resolvedTarget,
264
+ schema: (_resolveSchemaRef2 = resolveSchemaRef(target, schemas)) !== null && _resolveSchemaRef2 !== void 0 ? _resolveSchemaRef2 : target,
269
265
  pathParts: rest,
270
266
  description,
271
267
  schemas
272
268
  });
273
269
  }
274
270
  }
275
-
276
271
  //#endregion
277
272
  //#region src/generate.ts
278
- var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
279
273
  const PRIMITIVE_FLAGS = ts.TypeFlags.String | ts.TypeFlags.Number | ts.TypeFlags.Boolean | ts.TypeFlags.StringLiteral | ts.TypeFlags.NumberLiteral | ts.TypeFlags.BooleanLiteral;
280
274
  function hasFlag(type, flag) {
281
275
  return (type.getFlags() & flag) !== 0;
@@ -286,6 +280,30 @@ function isPrimitive(type) {
286
280
  function isObjectType(type) {
287
281
  return hasFlag(type, ts.TypeFlags.Object);
288
282
  }
283
+ const STANDARD_FUNCTION_INTERFACES = /* @__PURE__ */ new Set([
284
+ "Function",
285
+ "CallableFunction",
286
+ "NewableFunction"
287
+ ]);
288
+ function isStandardFunctionInterface(type) {
289
+ var _symbol$declarations$, _symbol$declarations;
290
+ const symbol = type.getSymbol();
291
+ const name = symbol === null || symbol === void 0 ? void 0 : symbol.getName();
292
+ if (!name || !STANDARD_FUNCTION_INTERFACES.has(name)) return false;
293
+ return (_symbol$declarations$ = symbol === null || symbol === void 0 || (_symbol$declarations = symbol.declarations) === null || _symbol$declarations === void 0 ? void 0 : _symbol$declarations.some((d) => /(^|[\\/])lib\.[^\\/]*\.d\.ts$/.test(d.getSourceFile().fileName))) !== null && _symbol$declarations$ !== void 0 ? _symbol$declarations$ : false;
294
+ }
295
+ function isFunctionType(type) {
296
+ return type.getCallSignatures().length > 0 || type.getConstructSignatures().length > 0 || isStandardFunctionInterface(type);
297
+ }
298
+ function hasFunctionMember(type) {
299
+ if (isFunctionType(type)) return true;
300
+ return type.isUnion() && type.types.some(isFunctionType);
301
+ }
302
+ function isUnserialisableType(type) {
303
+ if (isFunctionType(type)) return true;
304
+ if (!type.isUnion() || !type.types.some(isFunctionType)) return false;
305
+ return !type.types.some((m) => !isFunctionType(m) && !hasFlag(m, ts.TypeFlags.Undefined | ts.TypeFlags.Void | ts.TypeFlags.Null));
306
+ }
289
307
  function isOptionalSymbol(sym) {
290
308
  return (sym.flags & ts.SymbolFlags.Optional) !== 0;
291
309
  }
@@ -301,7 +319,7 @@ function unwrapBrand(type) {
301
319
  if (first && hasObject) return first;
302
320
  return type;
303
321
  }
304
- const ANONYMOUS_NAMES = new Set([
322
+ const ANONYMOUS_NAMES = /* @__PURE__ */ new Set([
305
323
  "__type",
306
324
  "__object",
307
325
  "Object",
@@ -363,8 +381,8 @@ function typeToJsonSchema(type, ctx, depth = 0) {
363
381
  const storedSchema = ctx.schemas[existingRef];
364
382
  if (storedSchema && (isNonEmptySchema(storedSchema) || ctx.visited.has(type))) return schemaRef(existingRef);
365
383
  ctx.schemas[existingRef] = storedSchema !== null && storedSchema !== void 0 ? storedSchema : {};
366
- const schema$1 = convertTypeToSchema(type, ctx, depth);
367
- if (!isSelfSchemaRef(schema$1, existingRef)) ctx.schemas[existingRef] = schema$1;
384
+ const schema = convertTypeToSchema(type, ctx, depth);
385
+ if (!isSelfSchemaRef(schema, existingRef)) ctx.schemas[existingRef] = schema;
368
386
  return schemaRef(existingRef);
369
387
  }
370
388
  const schema = convertTypeToSchema(type, ctx, depth);
@@ -388,8 +406,7 @@ function handleCyclicRef(type, ctx) {
388
406
  let refName = ctx.typeToRef.get(type);
389
407
  if (!refName) {
390
408
  var _getTypeName;
391
- const name = (_getTypeName = getTypeName(type)) !== null && _getTypeName !== void 0 ? _getTypeName : "RecursiveType";
392
- refName = ensureUniqueName(name, ctx.schemas);
409
+ refName = ensureUniqueName((_getTypeName = getTypeName(type)) !== null && _getTypeName !== void 0 ? _getTypeName : "RecursiveType", ctx.schemas);
393
410
  ctx.typeToRef.set(type, refName);
394
411
  ctx.schemas[refName] = {};
395
412
  }
@@ -416,18 +433,14 @@ function convertPrimitiveOrLiteral(type, flags, checker) {
416
433
  type: "number",
417
434
  const: type.value
418
435
  };
419
- if (flags & ts.TypeFlags.BooleanLiteral) {
420
- const isTrue = checker.typeToString(type) === "true";
421
- return {
422
- type: "boolean",
423
- const: isTrue
424
- };
425
- }
436
+ if (flags & ts.TypeFlags.BooleanLiteral) return {
437
+ type: "boolean",
438
+ const: checker.typeToString(type) === "true"
439
+ };
426
440
  return null;
427
441
  }
428
442
  function convertUnionType(type, ctx, depth) {
429
- const members = type.types;
430
- const defined = members.filter((m) => !hasFlag(m, ts.TypeFlags.Undefined | ts.TypeFlags.Void));
443
+ const defined = type.types.filter((m) => !hasFlag(m, ts.TypeFlags.Undefined | ts.TypeFlags.Void) && !isFunctionType(m));
431
444
  if (defined.length === 0) return {};
432
445
  const hasNull = defined.some((m) => hasFlag(m, ts.TypeFlags.Null));
433
446
  const nonNull = defined.filter((m) => !hasFlag(m, ts.TypeFlags.Null));
@@ -461,14 +474,11 @@ function detectDiscriminatorProperty(schemas) {
461
474
  const first = schemas[0];
462
475
  if (!(first === null || first === void 0 ? void 0 : first.properties)) return null;
463
476
  const firstProps = Object.keys(first.properties);
464
- for (const prop of firstProps) {
465
- const allHaveConst = schemas.every((s) => {
466
- var _s$properties, _s$required;
467
- const propSchema = (_s$properties = s.properties) === null || _s$properties === void 0 ? void 0 : _s$properties[prop];
468
- return propSchema !== void 0 && propSchema.const !== void 0 && ((_s$required = s.required) === null || _s$required === void 0 ? void 0 : _s$required.includes(prop));
469
- });
470
- if (allHaveConst) return prop;
471
- }
477
+ for (const prop of firstProps) if (schemas.every((s) => {
478
+ var _s$properties, _s$required;
479
+ const propSchema = (_s$properties = s.properties) === null || _s$properties === void 0 ? void 0 : _s$properties[prop];
480
+ return (propSchema === null || propSchema === void 0 ? void 0 : propSchema.const) !== void 0 && ((_s$required = s.required) === null || _s$required === void 0 ? void 0 : _s$required.includes(prop));
481
+ })) return prop;
472
482
  return null;
473
483
  }
474
484
  /** A schema that is just `{ type: "somePrimitive" }` with no other keys. */
@@ -482,14 +492,12 @@ function isSimpleTypeSchema(s) {
482
492
  */
483
493
  function tryCollapseLiteralUnion(nonNull, hasNull) {
484
494
  if (nonNull.length <= 1) return null;
485
- const allLiterals = nonNull.every((m) => hasFlag(m, ts.TypeFlags.StringLiteral | ts.TypeFlags.NumberLiteral));
486
- if (!allLiterals) return null;
495
+ if (!nonNull.every((m) => hasFlag(m, ts.TypeFlags.StringLiteral | ts.TypeFlags.NumberLiteral))) return null;
487
496
  const [first] = nonNull;
488
497
  if (!first) return null;
489
498
  const isString = hasFlag(first, ts.TypeFlags.StringLiteral);
490
499
  const targetFlag = isString ? ts.TypeFlags.StringLiteral : ts.TypeFlags.NumberLiteral;
491
- const allSameKind = nonNull.every((m) => hasFlag(m, targetFlag));
492
- if (!allSameKind) return null;
500
+ if (!nonNull.every((m) => hasFlag(m, targetFlag))) return null;
493
501
  const values = nonNull.map((m) => isString ? m.value : m.value);
494
502
  const baseType = isString ? "string" : "number";
495
503
  return {
@@ -498,9 +506,7 @@ function tryCollapseLiteralUnion(nonNull, hasNull) {
498
506
  };
499
507
  }
500
508
  function convertIntersectionType(type, ctx, depth) {
501
- const hasPrimitiveMember = type.types.some(isPrimitive);
502
- const nonBrand = hasPrimitiveMember ? type.types.filter((m) => !isObjectType(m)) : type.types;
503
- const schemas = nonBrand.map((m) => typeToJsonSchema(m, ctx, depth + 1)).filter(isNonEmptySchema);
509
+ const schemas = (type.types.some(isPrimitive) ? type.types.filter((m) => !isObjectType(m)) : type.types).map((m) => typeToJsonSchema(m, ctx, depth + 1)).filter(isNonEmptySchema);
504
510
  if (schemas.length === 0) return {};
505
511
  const [onlySchema] = schemas;
506
512
  if (schemas.length === 1 && onlySchema !== void 0) return onlySchema;
@@ -560,10 +566,9 @@ function convertArrayType(type, ctx, depth) {
560
566
  }
561
567
  function convertTupleType(type, ctx, depth) {
562
568
  const args = ctx.checker.getTypeArguments(type);
563
- const schemas = args.map((a) => typeToJsonSchema(a, ctx, depth + 1));
564
569
  return {
565
570
  type: "array",
566
- prefixItems: schemas,
571
+ prefixItems: args.map((a) => typeToJsonSchema(a, ctx, depth + 1)),
567
572
  items: false,
568
573
  minItems: args.length,
569
574
  maxItems: args.length
@@ -580,8 +585,7 @@ function convertPlainObject(type, ctx, depth) {
580
585
  };
581
586
  let autoRegName = null;
582
587
  const tsName = getTypeName(type);
583
- const isNamedUnregisteredType = tsName !== null && typeProps.length > 0 && !ctx.typeToRef.has(type);
584
- if (isNamedUnregisteredType) {
588
+ if (tsName !== null && typeProps.length > 0 && !ctx.typeToRef.has(type)) {
585
589
  autoRegName = ensureUniqueName(tsName, ctx.schemas);
586
590
  ctx.typeToRef.set(type, autoRegName);
587
591
  ctx.schemas[autoRegName] = {};
@@ -592,18 +596,19 @@ function convertPlainObject(type, ctx, depth) {
592
596
  for (const prop of typeProps) {
593
597
  if (shouldSkipPropertySymbol(prop)) continue;
594
598
  const propType = checker.getTypeOfSymbol(prop);
599
+ if (isUnserialisableType(propType)) continue;
595
600
  const propSchema = typeToJsonSchema(propType, ctx, depth + 1);
596
601
  const jsDoc = getJsDocComment(prop, checker);
597
602
  if (jsDoc && !propSchema.description && !propSchema.$ref) propSchema.description = jsDoc;
598
603
  properties[prop.name] = propSchema;
599
- if (!isOptionalSymbol(prop)) required.push(prop.name);
604
+ if (!isOptionalSymbol(prop) && !hasFunctionMember(propType)) required.push(prop.name);
600
605
  }
601
606
  ctx.visited.delete(type);
602
607
  const result = { type: "object" };
603
608
  if (Object.keys(properties).length > 0) result.properties = properties;
604
609
  if (required.length > 0) result.required = required;
605
610
  if (stringIndexType) result.additionalProperties = typeToJsonSchema(stringIndexType, ctx, depth + 1);
606
- else if (Object.keys(properties).length > 0) result.additionalProperties = false;
611
+ else if (typeProps.length > 0) result.additionalProperties = false;
607
612
  const registeredName = (_autoRegName = autoRegName) !== null && _autoRegName !== void 0 ? _autoRegName : ctx.typeToRef.get(type);
608
613
  if (registeredName) {
609
614
  ctx.schemas[registeredName] = result;
@@ -621,8 +626,7 @@ function convertObjectType(type, ctx, depth) {
621
626
  /** Core type-to-schema conversion (no ref handling). */
622
627
  function convertTypeToSchema(type, ctx, depth) {
623
628
  if (ctx.visited.has(type)) return handleCyclicRef(type, ctx);
624
- const flags = type.getFlags();
625
- const primitive = convertPrimitiveOrLiteral(type, flags, ctx.checker);
629
+ const primitive = convertPrimitiveOrLiteral(type, type.getFlags(), ctx.checker);
626
630
  if (primitive) return primitive;
627
631
  if (type.isUnion()) {
628
632
  ctx.visited.add(type);
@@ -636,6 +640,7 @@ function convertTypeToSchema(type, ctx, depth) {
636
640
  ctx.visited.delete(type);
637
641
  return result;
638
642
  }
643
+ if (isFunctionType(type)) return {};
639
644
  if (isObjectType(type)) return convertObjectType(type, ctx, depth);
640
645
  return {};
641
646
  }
@@ -653,15 +658,13 @@ function getProcedureTypeName(defType, checker) {
653
658
  }
654
659
  function isVoidLikeInput(inputType) {
655
660
  if (!inputType) return true;
656
- const isVoidOrUndefinedOrNever = hasFlag(inputType, ts.TypeFlags.Void | ts.TypeFlags.Undefined | ts.TypeFlags.Never);
657
- if (isVoidOrUndefinedOrNever) return true;
658
- const isUnionOfVoids = inputType.isUnion() && inputType.types.every((t) => hasFlag(t, ts.TypeFlags.Void | ts.TypeFlags.Undefined));
659
- return isUnionOfVoids;
661
+ if (hasFlag(inputType, ts.TypeFlags.Void | ts.TypeFlags.Undefined | ts.TypeFlags.Never)) return true;
662
+ return inputType.isUnion() && inputType.types.every((t) => hasFlag(t, ts.TypeFlags.Void | ts.TypeFlags.Undefined));
660
663
  }
661
664
  function shouldIncludeProcedureInOpenAPI(type) {
662
665
  return type !== "subscription";
663
666
  }
664
- function getProcedureInputTypeName(type, path$1) {
667
+ function getProcedureInputTypeName(type, path) {
665
668
  const directName = getTypeName(type);
666
669
  if (directName) return directName;
667
670
  for (const sym of [type.aliasSymbol, type.getSymbol()].filter((candidate) => !!candidate)) {
@@ -672,8 +675,7 @@ function getProcedureInputTypeName(type, path$1) {
672
675
  if (declarationName && !ANONYMOUS_NAMES.has(declarationName) && !declarationName.startsWith("__")) return declarationName;
673
676
  }
674
677
  }
675
- const fallbackName = path$1.split(".").filter(Boolean).map((segment) => segment.split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")).join("");
676
- return `${fallbackName || "Procedure"}Input`;
678
+ return `${path.split(".").filter(Boolean).map((segment) => segment.split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")).join("") || "Procedure"}Input`;
677
679
  }
678
680
  function isUnknownLikeType(type) {
679
681
  return hasFlag(type, ts.TypeFlags.Unknown | ts.TypeFlags.Any);
@@ -704,14 +706,11 @@ function recoverProcedureInputType(def, checker) {
704
706
  if (callee.name.text !== "input") return;
705
707
  const [parserExpr] = expr.arguments;
706
708
  if (!parserExpr) return;
707
- const parserType = checker.getTypeAtLocation(parserExpr);
708
- const standardSym = parserType.getProperty("~standard");
709
+ const standardSym = checker.getTypeAtLocation(parserExpr).getProperty("~standard");
709
710
  if (!standardSym) return;
710
- const standardType = checker.getTypeOfSymbolAtLocation(standardSym, parserExpr);
711
- const typesSym = standardType.getProperty("types");
711
+ const typesSym = checker.getTypeOfSymbolAtLocation(standardSym, parserExpr).getProperty("types");
712
712
  if (!typesSym) return;
713
- const typesType = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(typesSym, parserExpr));
714
- const outputSym = typesType.getProperty("output");
713
+ const outputSym = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(typesSym, parserExpr)).getProperty("output");
715
714
  if (!outputSym) return;
716
715
  const outputType = checker.getTypeOfSymbolAtLocation(outputSym, parserExpr);
717
716
  if (!isUnknownLikeType(outputType)) recovered = outputType;
@@ -767,22 +766,18 @@ function getJsDocComment(sym, checker) {
767
766
  var _sym$declarations2;
768
767
  const normalize = (filePath) => filePath.replace(/\\/g, "/");
769
768
  const declarations = (_sym$declarations2 = sym.declarations) !== null && _sym$declarations2 !== void 0 ? _sym$declarations2 : [];
770
- const isExternalNodeModulesDeclaration = declarations.length > 0 && declarations.every((declaration) => {
769
+ if (declarations.length > 0 && declarations.every((declaration) => {
771
770
  const sourceFile = declaration.getSourceFile();
772
771
  if (!sourceFile.isDeclarationFile) return false;
773
- const declarationPath = normalize(sourceFile.fileName);
774
- if (!declarationPath.includes("/node_modules/")) return false;
772
+ if (!normalize(sourceFile.fileName).includes("/node_modules/")) return false;
775
773
  try {
776
- const realPath = normalize(fs.realpathSync.native(sourceFile.fileName));
777
- if (!realPath.includes("/node_modules/")) return false;
774
+ if (!normalize(fs.realpathSync.native(sourceFile.fileName)).includes("/node_modules/")) return false;
778
775
  } catch (_unused) {}
779
776
  return true;
780
- });
781
- if (isExternalNodeModulesDeclaration) return void 0;
777
+ })) return;
782
778
  const parts = sym.getDocumentationComment(checker);
783
- if (parts.length === 0) return void 0;
784
- const text = parts.map((p) => p.text).join("");
785
- return text || void 0;
779
+ if (parts.length === 0) return;
780
+ return parts.map((p) => p.text).join("") || void 0;
786
781
  }
787
782
  function walkType(opts) {
788
783
  const { type, ctx, currentPath, description, symbol } = opts;
@@ -813,28 +808,21 @@ function walkType(opts) {
813
808
  }
814
809
  const routerSym = defType.getProperty("router");
815
810
  if (!routerSym) return;
816
- const isRouter = checker.typeToString(checker.getTypeOfSymbol(routerSym)) === "true";
817
- if (!isRouter) return;
811
+ if (!(checker.typeToString(checker.getTypeOfSymbol(routerSym)) === "true")) return;
818
812
  const recordSym = defType.getProperty("record");
819
813
  if (!recordSym) return;
820
814
  ctx.seen.add(type);
821
- const recordType = checker.getTypeOfSymbol(recordSym);
822
- walkRecord(recordType, ctx, currentPath);
815
+ walkRecord(checker.getTypeOfSymbol(recordSym), ctx, currentPath);
823
816
  ctx.seen.delete(type);
824
817
  }
825
818
  function walkRecord(recordType, ctx, prefix) {
826
- for (const prop of recordType.getProperties()) {
827
- const propType = ctx.schemaCtx.checker.getTypeOfSymbol(prop);
828
- const fullPath = prefix ? `${prefix}.${prop.name}` : prop.name;
829
- const description = getJsDocComment(prop, ctx.schemaCtx.checker);
830
- walkType({
831
- type: propType,
832
- ctx,
833
- currentPath: fullPath,
834
- description,
835
- symbol: prop
836
- });
837
- }
819
+ for (const prop of recordType.getProperties()) walkType({
820
+ type: ctx.schemaCtx.checker.getTypeOfSymbol(prop),
821
+ ctx,
822
+ currentPath: prefix ? `${prefix}.${prop.name}` : prop.name,
823
+ description: getJsDocComment(prop, ctx.schemaCtx.checker),
824
+ symbol: prop
825
+ });
838
826
  }
839
827
  function loadCompilerOptions(startDir) {
840
828
  const configPath = ts.findConfigFile(startDir, (f) => ts.sys.fileExists(f), "tsconfig.json");
@@ -846,7 +834,7 @@ function loadCompilerOptions(startDir) {
846
834
  };
847
835
  const configFile = ts.readConfigFile(configPath, (f) => ts.sys.readFile(f));
848
836
  const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
849
- const options = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, parsed.options), {}, { noEmit: true });
837
+ const options = _objectSpread2(_objectSpread2({}, parsed.options), {}, { noEmit: true });
850
838
  if (options.moduleResolution === void 0) {
851
839
  const mod = options.module;
852
840
  if (mod === ts.ModuleKind.Node16 || mod === ts.ModuleKind.NodeNext) options.moduleResolution = ts.ModuleResolutionKind.NodeNext;
@@ -899,19 +887,18 @@ const DEFAULT_ERROR_SCHEMA = {
899
887
  */
900
888
  function wrapInSuccessEnvelope(outputSchema) {
901
889
  const hasOutput = outputSchema !== null && isNonEmptySchema(outputSchema);
902
- const resultSchema = (0, import_objectSpread2.default)({
903
- type: "object",
904
- properties: (0, import_objectSpread2.default)({}, hasOutput ? { data: outputSchema } : {})
905
- }, hasOutput ? { required: ["data"] } : {});
906
890
  return {
907
891
  type: "object",
908
- properties: { result: resultSchema },
892
+ properties: { result: _objectSpread2({
893
+ type: "object",
894
+ properties: _objectSpread2({}, hasOutput ? { data: outputSchema } : {})
895
+ }, hasOutput ? { required: ["data"] } : {}) },
909
896
  required: ["result"]
910
897
  };
911
898
  }
912
899
  function buildProcedureOperation(proc, method) {
913
900
  const [tag = proc.path] = proc.path.split(".");
914
- const operation = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({ operationId: proc.path }, proc.description ? { description: proc.description } : {}), {}, {
901
+ const operation = _objectSpread2(_objectSpread2({ operationId: proc.path }, proc.description ? { description: proc.description } : {}), {}, {
915
902
  tags: [tag],
916
903
  responses: {
917
904
  "200": {
@@ -948,7 +935,7 @@ function buildOpenAPIDocument(procedures, options, meta = { errorSchema: null })
948
935
  pathItem[method] = buildProcedureOperation(proc, method);
949
936
  }
950
937
  const hasNamedSchemas = meta.schemas !== void 0 && Object.keys(meta.schemas).length > 0;
951
- return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({
938
+ return _objectSpread2(_objectSpread2({
952
939
  openapi: "3.1.1",
953
940
  jsonSchemaDialect: "https://spec.openapis.org/oas/3.1/dialect/base",
954
941
  info: {
@@ -957,7 +944,7 @@ function buildOpenAPIDocument(procedures, options, meta = { errorSchema: null })
957
944
  }
958
945
  }, ((_options$servers = options.servers) === null || _options$servers === void 0 ? void 0 : _options$servers.length) ? { servers: options.servers } : {}), {}, {
959
946
  paths,
960
- components: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, hasNamedSchemas && meta.schemas ? { schemas: meta.schemas } : {}), {}, { responses: { Error: {
947
+ components: _objectSpread2(_objectSpread2({}, hasNamedSchemas && meta.schemas ? { schemas: meta.schemas } : {}), {}, { responses: { Error: {
961
948
  description: "Error response",
962
949
  content: { "application/json": { schema: {
963
950
  type: "object",
@@ -1021,11 +1008,10 @@ async function generateOpenAPIDocument(routerFilePath, options = {}) {
1021
1008
  schemas: schemaCtx.schemas
1022
1009
  });
1023
1010
  }
1024
-
1025
1011
  //#endregion
1026
1012
  //#region src/types.ts
1027
- var types_exports = {};
1028
-
1013
+ var types_exports = /* @__PURE__ */ __exportAll({});
1029
1014
  //#endregion
1030
1015
  export { types_exports as OpenAPIV3_1, generateOpenAPIDocument };
1016
+
1031
1017
  //# sourceMappingURL=index.mjs.map