@trpc/openapi 11.18.1-canary.2 → 11.18.1-canary.30

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.d.mts CHANGED
@@ -1,7 +1,4 @@
1
- import { __export } from "./chunk-CJ2cON1m.mjs";
2
1
  import { OpenAPIV3_1 } from "openapi-types";
3
-
4
- //#region src/types.d.ts
5
2
  declare namespace types_d_exports {
6
3
  export { ArraySchemaObject, CallbackObject, ComponentsObject, DiscriminatorObject, Document, ExampleObject, ExternalDocumentationObject, HeaderObject, HttpMethods, LinkObject, MediaTypeObject, OperationObject, ParameterBaseObject, ParameterObject, PathItemObject, PathsObject, PrimitiveSchemaType, ReferenceObject, Replace, RequestBodyObject, ResponseObject, ResponsesObject, SchemaLike, SchemaObject, SchemaType, SecuritySchemeObject, ServerObject, XMLObject };
7
4
  }
@@ -76,7 +73,7 @@ type OperationObject<T extends {} = {}> = Replace<OpenAPIV3_1.OperationObject<T>
76
73
  }> & T;
77
74
  type PathItemObject<T extends {} = {}> = Replace<OpenAPIV3_1.PathItemObject<T>, {
78
75
  parameters?: (ReferenceObject | ParameterObject)[];
79
- }> & { [method in HttpMethods]?: OperationObject<T> };
76
+ }> & { [method in HttpMethods]?: OperationObject<T>; };
80
77
  type PathsObject<T extends {} = {}, TPath extends {} = {}> = Record<string, (PathItemObject<T> & TPath) | undefined>;
81
78
  type CallbackObject = Record<string, PathItemObject | ReferenceObject>;
82
79
  type ComponentsObject = Replace<OpenAPIV3_1.ComponentsObject, {
@@ -93,7 +90,6 @@ type Document<T extends {} = {}> = Replace<OpenAPIV3_1.Document<T>, {
93
90
  paths?: PathsObject<T>;
94
91
  components?: ComponentsObject;
95
92
  }>;
96
- //# sourceMappingURL=types.d.ts.map
97
93
  //#endregion
98
94
  //#region src/generate.d.ts
99
95
  interface GenerateOptions {
@@ -122,9 +118,7 @@ interface GenerateOptions {
122
118
  * the AppRouter.
123
119
  * @param options - Optional generation settings (export name, title, version).
124
120
  */
125
- declare function generateOpenAPIDocument(routerFilePath: string, options?: GenerateOptions): Promise<Document>;
126
- //# sourceMappingURL=generate.d.ts.map
127
-
121
+ export declare function generateOpenAPIDocument(routerFilePath: string, options?: GenerateOptions): Promise<Document>;
128
122
  //#endregion
129
- export { GenerateOptions, types_d_exports as OpenAPIV3_1, generateOpenAPIDocument };
123
+ export { type GenerateOptions, types_d_exports as OpenAPIV3_1 };
130
124
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/generate.ts"],"sourcesContent":[],"mappings":";;;;;;;KAEY,iCAAiC,KAAK,eAAe,gBAC/D;KAEU,UAAA;KASA,mBAAA,GAAsB;KAEtB,WAAA,GAAc,WAAA,CAAgB;KAC9B,eAAA,GAAkB,WAAA,CAAgB;KAClC,aAAA,GAAgB,WAAA,CAAgB;KAChC,mBAAA,GAAsB,WAAA,CAAgB;KACtC,2BAAA,GACV,WAAA,CAAgB;KACN,SAAA,GAAY,WAAA,CAAgB;KAC5B,UAAA,GAAa,WAAA,CAAgB;KAC7B,oBAAA,GAAuB,WAAA,CAAgB;KACvC,YAAA,GAAe,WAAA,CAAgB;KAE/B,YAAA,GAAe,QACzB,WAAA,CAAgB;;UAGN,eAAe;;;eAGV,eAAe;;UAEpB;gBACM;;;UAGN;UACA;UACA;QACF;mCAC2B;kBACjB;iBACD;QACT;;;;AA7CV,CAAA,CAAA;AAAmB,KAoDP,UAAA,GAAa,YApDN;AAA+B,UAsDjC,iBAAA,SAA0B,YAtDO,CAAA;EAAO,IAAQ,EAAA,OAAA;EAAY,KAAhC,EAwDpC,YAxDoC,GAAA,KAAA;;AAC/B,KA0DF,eAAA,GAAkB,OA1DhB,CA2DZ,WAAA,CAAgB,eA3DJ,EAAA;EAEF,MAAA,CAAA,EA2DC,YA3DS,GA2DM,eA3DN;EASV,QAAA,CAAA,EAmDG,MAnDH,CAAA,MAAmB,EAmDD,eAn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.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;
@@ -301,7 +295,7 @@ function unwrapBrand(type) {
301
295
  if (first && hasObject) return first;
302
296
  return type;
303
297
  }
304
- const ANONYMOUS_NAMES = new Set([
298
+ const ANONYMOUS_NAMES = /* @__PURE__ */ new Set([
305
299
  "__type",
306
300
  "__object",
307
301
  "Object",
@@ -363,8 +357,8 @@ function typeToJsonSchema(type, ctx, depth = 0) {
363
357
  const storedSchema = ctx.schemas[existingRef];
364
358
  if (storedSchema && (isNonEmptySchema(storedSchema) || ctx.visited.has(type))) return schemaRef(existingRef);
365
359
  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;
360
+ const schema = convertTypeToSchema(type, ctx, depth);
361
+ if (!isSelfSchemaRef(schema, existingRef)) ctx.schemas[existingRef] = schema;
368
362
  return schemaRef(existingRef);
369
363
  }
370
364
  const schema = convertTypeToSchema(type, ctx, depth);
@@ -388,8 +382,7 @@ function handleCyclicRef(type, ctx) {
388
382
  let refName = ctx.typeToRef.get(type);
389
383
  if (!refName) {
390
384
  var _getTypeName;
391
- const name = (_getTypeName = getTypeName(type)) !== null && _getTypeName !== void 0 ? _getTypeName : "RecursiveType";
392
- refName = ensureUniqueName(name, ctx.schemas);
385
+ refName = ensureUniqueName((_getTypeName = getTypeName(type)) !== null && _getTypeName !== void 0 ? _getTypeName : "RecursiveType", ctx.schemas);
393
386
  ctx.typeToRef.set(type, refName);
394
387
  ctx.schemas[refName] = {};
395
388
  }
@@ -416,18 +409,14 @@ function convertPrimitiveOrLiteral(type, flags, checker) {
416
409
  type: "number",
417
410
  const: type.value
418
411
  };
419
- if (flags & ts.TypeFlags.BooleanLiteral) {
420
- const isTrue = checker.typeToString(type) === "true";
421
- return {
422
- type: "boolean",
423
- const: isTrue
424
- };
425
- }
412
+ if (flags & ts.TypeFlags.BooleanLiteral) return {
413
+ type: "boolean",
414
+ const: checker.typeToString(type) === "true"
415
+ };
426
416
  return null;
427
417
  }
428
418
  function convertUnionType(type, ctx, depth) {
429
- const members = type.types;
430
- const defined = members.filter((m) => !hasFlag(m, ts.TypeFlags.Undefined | ts.TypeFlags.Void));
419
+ const defined = type.types.filter((m) => !hasFlag(m, ts.TypeFlags.Undefined | ts.TypeFlags.Void));
431
420
  if (defined.length === 0) return {};
432
421
  const hasNull = defined.some((m) => hasFlag(m, ts.TypeFlags.Null));
433
422
  const nonNull = defined.filter((m) => !hasFlag(m, ts.TypeFlags.Null));
@@ -461,14 +450,11 @@ function detectDiscriminatorProperty(schemas) {
461
450
  const first = schemas[0];
462
451
  if (!(first === null || first === void 0 ? void 0 : first.properties)) return null;
463
452
  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
- }
453
+ for (const prop of firstProps) if (schemas.every((s) => {
454
+ var _s$properties, _s$required;
455
+ const propSchema = (_s$properties = s.properties) === null || _s$properties === void 0 ? void 0 : _s$properties[prop];
456
+ 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));
457
+ })) return prop;
472
458
  return null;
473
459
  }
474
460
  /** A schema that is just `{ type: "somePrimitive" }` with no other keys. */
@@ -482,14 +468,12 @@ function isSimpleTypeSchema(s) {
482
468
  */
483
469
  function tryCollapseLiteralUnion(nonNull, hasNull) {
484
470
  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;
471
+ if (!nonNull.every((m) => hasFlag(m, ts.TypeFlags.StringLiteral | ts.TypeFlags.NumberLiteral))) return null;
487
472
  const [first] = nonNull;
488
473
  if (!first) return null;
489
474
  const isString = hasFlag(first, ts.TypeFlags.StringLiteral);
490
475
  const targetFlag = isString ? ts.TypeFlags.StringLiteral : ts.TypeFlags.NumberLiteral;
491
- const allSameKind = nonNull.every((m) => hasFlag(m, targetFlag));
492
- if (!allSameKind) return null;
476
+ if (!nonNull.every((m) => hasFlag(m, targetFlag))) return null;
493
477
  const values = nonNull.map((m) => isString ? m.value : m.value);
494
478
  const baseType = isString ? "string" : "number";
495
479
  return {
@@ -498,9 +482,7 @@ function tryCollapseLiteralUnion(nonNull, hasNull) {
498
482
  };
499
483
  }
500
484
  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);
485
+ const schemas = (type.types.some(isPrimitive) ? type.types.filter((m) => !isObjectType(m)) : type.types).map((m) => typeToJsonSchema(m, ctx, depth + 1)).filter(isNonEmptySchema);
504
486
  if (schemas.length === 0) return {};
505
487
  const [onlySchema] = schemas;
506
488
  if (schemas.length === 1 && onlySchema !== void 0) return onlySchema;
@@ -560,10 +542,9 @@ function convertArrayType(type, ctx, depth) {
560
542
  }
561
543
  function convertTupleType(type, ctx, depth) {
562
544
  const args = ctx.checker.getTypeArguments(type);
563
- const schemas = args.map((a) => typeToJsonSchema(a, ctx, depth + 1));
564
545
  return {
565
546
  type: "array",
566
- prefixItems: schemas,
547
+ prefixItems: args.map((a) => typeToJsonSchema(a, ctx, depth + 1)),
567
548
  items: false,
568
549
  minItems: args.length,
569
550
  maxItems: args.length
@@ -580,8 +561,7 @@ function convertPlainObject(type, ctx, depth) {
580
561
  };
581
562
  let autoRegName = null;
582
563
  const tsName = getTypeName(type);
583
- const isNamedUnregisteredType = tsName !== null && typeProps.length > 0 && !ctx.typeToRef.has(type);
584
- if (isNamedUnregisteredType) {
564
+ if (tsName !== null && typeProps.length > 0 && !ctx.typeToRef.has(type)) {
585
565
  autoRegName = ensureUniqueName(tsName, ctx.schemas);
586
566
  ctx.typeToRef.set(type, autoRegName);
587
567
  ctx.schemas[autoRegName] = {};
@@ -591,8 +571,7 @@ function convertPlainObject(type, ctx, depth) {
591
571
  const required = [];
592
572
  for (const prop of typeProps) {
593
573
  if (shouldSkipPropertySymbol(prop)) continue;
594
- const propType = checker.getTypeOfSymbol(prop);
595
- const propSchema = typeToJsonSchema(propType, ctx, depth + 1);
574
+ const propSchema = typeToJsonSchema(checker.getTypeOfSymbol(prop), ctx, depth + 1);
596
575
  const jsDoc = getJsDocComment(prop, checker);
597
576
  if (jsDoc && !propSchema.description && !propSchema.$ref) propSchema.description = jsDoc;
598
577
  properties[prop.name] = propSchema;
@@ -621,8 +600,7 @@ function convertObjectType(type, ctx, depth) {
621
600
  /** Core type-to-schema conversion (no ref handling). */
622
601
  function convertTypeToSchema(type, ctx, depth) {
623
602
  if (ctx.visited.has(type)) return handleCyclicRef(type, ctx);
624
- const flags = type.getFlags();
625
- const primitive = convertPrimitiveOrLiteral(type, flags, ctx.checker);
603
+ const primitive = convertPrimitiveOrLiteral(type, type.getFlags(), ctx.checker);
626
604
  if (primitive) return primitive;
627
605
  if (type.isUnion()) {
628
606
  ctx.visited.add(type);
@@ -653,15 +631,13 @@ function getProcedureTypeName(defType, checker) {
653
631
  }
654
632
  function isVoidLikeInput(inputType) {
655
633
  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;
634
+ if (hasFlag(inputType, ts.TypeFlags.Void | ts.TypeFlags.Undefined | ts.TypeFlags.Never)) return true;
635
+ return inputType.isUnion() && inputType.types.every((t) => hasFlag(t, ts.TypeFlags.Void | ts.TypeFlags.Undefined));
660
636
  }
661
637
  function shouldIncludeProcedureInOpenAPI(type) {
662
638
  return type !== "subscription";
663
639
  }
664
- function getProcedureInputTypeName(type, path$1) {
640
+ function getProcedureInputTypeName(type, path) {
665
641
  const directName = getTypeName(type);
666
642
  if (directName) return directName;
667
643
  for (const sym of [type.aliasSymbol, type.getSymbol()].filter((candidate) => !!candidate)) {
@@ -672,8 +648,7 @@ function getProcedureInputTypeName(type, path$1) {
672
648
  if (declarationName && !ANONYMOUS_NAMES.has(declarationName) && !declarationName.startsWith("__")) return declarationName;
673
649
  }
674
650
  }
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`;
651
+ 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
652
  }
678
653
  function isUnknownLikeType(type) {
679
654
  return hasFlag(type, ts.TypeFlags.Unknown | ts.TypeFlags.Any);
@@ -704,14 +679,11 @@ function recoverProcedureInputType(def, checker) {
704
679
  if (callee.name.text !== "input") return;
705
680
  const [parserExpr] = expr.arguments;
706
681
  if (!parserExpr) return;
707
- const parserType = checker.getTypeAtLocation(parserExpr);
708
- const standardSym = parserType.getProperty("~standard");
682
+ const standardSym = checker.getTypeAtLocation(parserExpr).getProperty("~standard");
709
683
  if (!standardSym) return;
710
- const standardType = checker.getTypeOfSymbolAtLocation(standardSym, parserExpr);
711
- const typesSym = standardType.getProperty("types");
684
+ const typesSym = checker.getTypeOfSymbolAtLocation(standardSym, parserExpr).getProperty("types");
712
685
  if (!typesSym) return;
713
- const typesType = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(typesSym, parserExpr));
714
- const outputSym = typesType.getProperty("output");
686
+ const outputSym = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(typesSym, parserExpr)).getProperty("output");
715
687
  if (!outputSym) return;
716
688
  const outputType = checker.getTypeOfSymbolAtLocation(outputSym, parserExpr);
717
689
  if (!isUnknownLikeType(outputType)) recovered = outputType;
@@ -767,22 +739,18 @@ function getJsDocComment(sym, checker) {
767
739
  var _sym$declarations2;
768
740
  const normalize = (filePath) => filePath.replace(/\\/g, "/");
769
741
  const declarations = (_sym$declarations2 = sym.declarations) !== null && _sym$declarations2 !== void 0 ? _sym$declarations2 : [];
770
- const isExternalNodeModulesDeclaration = declarations.length > 0 && declarations.every((declaration) => {
742
+ if (declarations.length > 0 && declarations.every((declaration) => {
771
743
  const sourceFile = declaration.getSourceFile();
772
744
  if (!sourceFile.isDeclarationFile) return false;
773
- const declarationPath = normalize(sourceFile.fileName);
774
- if (!declarationPath.includes("/node_modules/")) return false;
745
+ if (!normalize(sourceFile.fileName).includes("/node_modules/")) return false;
775
746
  try {
776
- const realPath = normalize(fs.realpathSync.native(sourceFile.fileName));
777
- if (!realPath.includes("/node_modules/")) return false;
747
+ if (!normalize(fs.realpathSync.native(sourceFile.fileName)).includes("/node_modules/")) return false;
778
748
  } catch (_unused) {}
779
749
  return true;
780
- });
781
- if (isExternalNodeModulesDeclaration) return void 0;
750
+ })) return;
782
751
  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;
752
+ if (parts.length === 0) return;
753
+ return parts.map((p) => p.text).join("") || void 0;
786
754
  }
787
755
  function walkType(opts) {
788
756
  const { type, ctx, currentPath, description, symbol } = opts;
@@ -813,28 +781,21 @@ function walkType(opts) {
813
781
  }
814
782
  const routerSym = defType.getProperty("router");
815
783
  if (!routerSym) return;
816
- const isRouter = checker.typeToString(checker.getTypeOfSymbol(routerSym)) === "true";
817
- if (!isRouter) return;
784
+ if (!(checker.typeToString(checker.getTypeOfSymbol(routerSym)) === "true")) return;
818
785
  const recordSym = defType.getProperty("record");
819
786
  if (!recordSym) return;
820
787
  ctx.seen.add(type);
821
- const recordType = checker.getTypeOfSymbol(recordSym);
822
- walkRecord(recordType, ctx, currentPath);
788
+ walkRecord(checker.getTypeOfSymbol(recordSym), ctx, currentPath);
823
789
  ctx.seen.delete(type);
824
790
  }
825
791
  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
- }
792
+ for (const prop of recordType.getProperties()) walkType({
793
+ type: ctx.schemaCtx.checker.getTypeOfSymbol(prop),
794
+ ctx,
795
+ currentPath: prefix ? `${prefix}.${prop.name}` : prop.name,
796
+ description: getJsDocComment(prop, ctx.schemaCtx.checker),
797
+ symbol: prop
798
+ });
838
799
  }
839
800
  function loadCompilerOptions(startDir) {
840
801
  const configPath = ts.findConfigFile(startDir, (f) => ts.sys.fileExists(f), "tsconfig.json");
@@ -846,7 +807,7 @@ function loadCompilerOptions(startDir) {
846
807
  };
847
808
  const configFile = ts.readConfigFile(configPath, (f) => ts.sys.readFile(f));
848
809
  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 });
810
+ const options = _objectSpread2(_objectSpread2({}, parsed.options), {}, { noEmit: true });
850
811
  if (options.moduleResolution === void 0) {
851
812
  const mod = options.module;
852
813
  if (mod === ts.ModuleKind.Node16 || mod === ts.ModuleKind.NodeNext) options.moduleResolution = ts.ModuleResolutionKind.NodeNext;
@@ -899,19 +860,18 @@ const DEFAULT_ERROR_SCHEMA = {
899
860
  */
900
861
  function wrapInSuccessEnvelope(outputSchema) {
901
862
  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
863
  return {
907
864
  type: "object",
908
- properties: { result: resultSchema },
865
+ properties: { result: _objectSpread2({
866
+ type: "object",
867
+ properties: _objectSpread2({}, hasOutput ? { data: outputSchema } : {})
868
+ }, hasOutput ? { required: ["data"] } : {}) },
909
869
  required: ["result"]
910
870
  };
911
871
  }
912
872
  function buildProcedureOperation(proc, method) {
913
873
  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 } : {}), {}, {
874
+ const operation = _objectSpread2(_objectSpread2({ operationId: proc.path }, proc.description ? { description: proc.description } : {}), {}, {
915
875
  tags: [tag],
916
876
  responses: {
917
877
  "200": {
@@ -948,7 +908,7 @@ function buildOpenAPIDocument(procedures, options, meta = { errorSchema: null })
948
908
  pathItem[method] = buildProcedureOperation(proc, method);
949
909
  }
950
910
  const hasNamedSchemas = meta.schemas !== void 0 && Object.keys(meta.schemas).length > 0;
951
- return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({
911
+ return _objectSpread2(_objectSpread2({
952
912
  openapi: "3.1.1",
953
913
  jsonSchemaDialect: "https://spec.openapis.org/oas/3.1/dialect/base",
954
914
  info: {
@@ -957,7 +917,7 @@ function buildOpenAPIDocument(procedures, options, meta = { errorSchema: null })
957
917
  }
958
918
  }, ((_options$servers = options.servers) === null || _options$servers === void 0 ? void 0 : _options$servers.length) ? { servers: options.servers } : {}), {}, {
959
919
  paths,
960
- components: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, hasNamedSchemas && meta.schemas ? { schemas: meta.schemas } : {}), {}, { responses: { Error: {
920
+ components: _objectSpread2(_objectSpread2({}, hasNamedSchemas && meta.schemas ? { schemas: meta.schemas } : {}), {}, { responses: { Error: {
961
921
  description: "Error response",
962
922
  content: { "application/json": { schema: {
963
923
  type: "object",
@@ -1021,11 +981,10 @@ async function generateOpenAPIDocument(routerFilePath, options = {}) {
1021
981
  schemas: schemaCtx.schemas
1022
982
  });
1023
983
  }
1024
-
1025
984
  //#endregion
1026
985
  //#region src/types.ts
1027
- var types_exports = {};
1028
-
986
+ var types_exports = /* @__PURE__ */ __exportAll({});
1029
987
  //#endregion
1030
988
  export { types_exports as OpenAPIV3_1, generateOpenAPIDocument };
989
+
1031
990
  //# sourceMappingURL=index.mjs.map