zod-openapi 2.18.0 → 2.19.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/extend.cjs +4 -0
  2. package/dist/extend.d.mts +1 -0
  3. package/dist/extend.d.ts +1 -0
  4. package/dist/extend.mjs +3 -0
  5. package/{lib-esm/extend.mjs → dist/extendZod.chunk.cjs} +2 -7
  6. package/{lib-commonjs/extend.js → dist/extendZod.chunk.mjs} +3 -24
  7. package/{lib-commonjs/index.js → dist/index.cjs} +247 -365
  8. package/dist/index.d.mts +1055 -0
  9. package/dist/index.d.ts +1055 -0
  10. package/{lib-esm → dist}/index.mjs +243 -336
  11. package/extend/index.d.ts +1 -0
  12. package/extend/package.json +5 -0
  13. package/package.json +30 -32
  14. package/lib-types/api.d.ts +0 -3
  15. package/lib-types/create/callbacks.d.ts +0 -5
  16. package/lib-types/create/components.d.ts +0 -125
  17. package/lib-types/create/content.d.ts +0 -6
  18. package/lib-types/create/document.d.ts +0 -73
  19. package/lib-types/create/parameters.d.ts +0 -10
  20. package/lib-types/create/paths.d.ts +0 -6
  21. package/lib-types/create/responses.d.ts +0 -10
  22. package/lib-types/create/schema/index.d.ts +0 -29
  23. package/lib-types/create/schema/metadata.d.ts +0 -3
  24. package/lib-types/create/schema/parsers/array.d.ts +0 -3
  25. package/lib-types/create/schema/parsers/boolean.d.ts +0 -3
  26. package/lib-types/create/schema/parsers/brand.d.ts +0 -3
  27. package/lib-types/create/schema/parsers/catch.d.ts +0 -3
  28. package/lib-types/create/schema/parsers/date.d.ts +0 -3
  29. package/lib-types/create/schema/parsers/default.d.ts +0 -3
  30. package/lib-types/create/schema/parsers/discriminatedUnion.d.ts +0 -5
  31. package/lib-types/create/schema/parsers/enum.d.ts +0 -3
  32. package/lib-types/create/schema/parsers/index.d.ts +0 -3
  33. package/lib-types/create/schema/parsers/intersection.d.ts +0 -3
  34. package/lib-types/create/schema/parsers/lazy.d.ts +0 -3
  35. package/lib-types/create/schema/parsers/literal.d.ts +0 -3
  36. package/lib-types/create/schema/parsers/manual.d.ts +0 -3
  37. package/lib-types/create/schema/parsers/nativeEnum.d.ts +0 -10
  38. package/lib-types/create/schema/parsers/null.d.ts +0 -2
  39. package/lib-types/create/schema/parsers/nullable.d.ts +0 -3
  40. package/lib-types/create/schema/parsers/number.d.ts +0 -13
  41. package/lib-types/create/schema/parsers/object.d.ts +0 -21
  42. package/lib-types/create/schema/parsers/optional.d.ts +0 -10
  43. package/lib-types/create/schema/parsers/pipeline.d.ts +0 -3
  44. package/lib-types/create/schema/parsers/preprocess.d.ts +0 -3
  45. package/lib-types/create/schema/parsers/readonly.d.ts +0 -3
  46. package/lib-types/create/schema/parsers/record.d.ts +0 -3
  47. package/lib-types/create/schema/parsers/refine.d.ts +0 -3
  48. package/lib-types/create/schema/parsers/set.d.ts +0 -3
  49. package/lib-types/create/schema/parsers/string.d.ts +0 -3
  50. package/lib-types/create/schema/parsers/transform.d.ts +0 -10
  51. package/lib-types/create/schema/parsers/tuple.d.ts +0 -3
  52. package/lib-types/create/schema/parsers/union.d.ts +0 -3
  53. package/lib-types/create/schema/parsers/unknown.d.ts +0 -3
  54. package/lib-types/create/specificationExtension.d.ts +0 -1
  55. package/lib-types/extend.d.ts +0 -1
  56. package/lib-types/extendZod.d.ts +0 -3
  57. package/lib-types/extendZodTypes.d.ts +0 -75
  58. package/lib-types/index.d.ts +0 -4
  59. package/lib-types/openapi.d.ts +0 -5
  60. package/lib-types/openapi3-ts/dist/dsl/openapi-builder30.d.ts +0 -31
  61. package/lib-types/openapi3-ts/dist/dsl/openapi-builder31.d.ts +0 -32
  62. package/lib-types/openapi3-ts/dist/index.d.ts +0 -3
  63. package/lib-types/openapi3-ts/dist/model/oas-common.d.ts +0 -15
  64. package/lib-types/openapi3-ts/dist/model/openapi30.d.ts +0 -291
  65. package/lib-types/openapi3-ts/dist/model/openapi31.d.ts +0 -298
  66. package/lib-types/openapi3-ts/dist/model/server.d.ts +0 -19
  67. package/lib-types/openapi3-ts/dist/model/specification-extension.d.ts +0 -12
  68. package/lib-types/openapi3-ts/dist/oas30.d.ts +0 -4
  69. package/lib-types/openapi3-ts/dist/oas31.d.ts +0 -4
  70. package/lib-types/zodType.d.ts +0 -42
@@ -1,41 +1,17 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- api: () => api_exports,
24
- createDocument: () => createDocument,
25
- extendZodWithOpenApi: () => extendZodWithOpenApi,
26
- oas30: () => oas30_exports,
27
- oas31: () => oas31_exports
28
- });
29
- module.exports = __toCommonJS(src_exports);
30
-
31
- // src/zodType.ts
32
- var isZodType = (zodType, typeName) => zodType?._def?.typeName === typeName;
33
- var isAnyZodType = (zodType) => Boolean(
34
- zodType?._def?.typeName
35
- );
36
-
37
- // src/create/schema/metadata.ts
38
- var enhanceWithMetadata = (schema, metadata) => {
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const extendZod = require("./extendZod.chunk.cjs");
4
+ const isZodType = (zodType, typeName) => {
5
+ var _a;
6
+ return ((_a = zodType == null ? void 0 : zodType._def) == null ? void 0 : _a.typeName) === typeName;
7
+ };
8
+ const isAnyZodType = (zodType) => {
9
+ var _a;
10
+ return Boolean(
11
+ (_a = zodType == null ? void 0 : zodType._def) == null ? void 0 : _a.typeName
12
+ );
13
+ };
14
+ const enhanceWithMetadata = (schema, metadata) => {
39
15
  if (schema.type === "ref") {
40
16
  if (Object.values(metadata).every((val) => val === void 0)) {
41
17
  return schema;
@@ -57,12 +33,11 @@ var enhanceWithMetadata = (schema, metadata) => {
57
33
  effects: schema.effects
58
34
  };
59
35
  };
60
-
61
- // src/create/schema/parsers/array.ts
62
- var createArraySchema = (zodArray, state) => {
36
+ const createArraySchema = (zodArray, state) => {
37
+ var _a, _b, _c, _d;
63
38
  const zodType = zodArray._def.type;
64
- const minItems = zodArray._def.exactLength?.value ?? zodArray._def.minLength?.value;
65
- const maxItems = zodArray._def.exactLength?.value ?? zodArray._def.maxLength?.value;
39
+ const minItems = ((_a = zodArray._def.exactLength) == null ? void 0 : _a.value) ?? ((_b = zodArray._def.minLength) == null ? void 0 : _b.value);
40
+ const maxItems = ((_c = zodArray._def.exactLength) == null ? void 0 : _c.value) ?? ((_d = zodArray._def.maxLength) == null ? void 0 : _d.value);
66
41
  const items = createSchemaObject(zodType, state, ["array items"]);
67
42
  return {
68
43
  type: "schema",
@@ -75,31 +50,21 @@ var createArraySchema = (zodArray, state) => {
75
50
  effects: items.effects
76
51
  };
77
52
  };
78
-
79
- // src/create/schema/parsers/boolean.ts
80
- var createBooleanSchema = (_zodBoolean) => ({
53
+ const createBooleanSchema = (_zodBoolean) => ({
81
54
  type: "schema",
82
55
  schema: {
83
56
  type: "boolean"
84
57
  }
85
58
  });
86
-
87
- // src/create/schema/parsers/brand.ts
88
- var createBrandedSchema = (zodBranded, state) => createSchemaObject(zodBranded._def.type, state, ["brand"]);
89
-
90
- // src/create/schema/parsers/catch.ts
91
- var createCatchSchema = (zodCatch, state) => createSchemaObject(zodCatch._def.innerType, state, ["catch"]);
92
-
93
- // src/create/schema/parsers/date.ts
94
- var createDateSchema = (_zodDate) => ({
59
+ const createBrandedSchema = (zodBranded, state) => createSchemaObject(zodBranded._def.type, state, ["brand"]);
60
+ const createCatchSchema = (zodCatch, state) => createSchemaObject(zodCatch._def.innerType, state, ["catch"]);
61
+ const createDateSchema = (_zodDate) => ({
95
62
  type: "schema",
96
63
  schema: {
97
64
  type: "string"
98
65
  }
99
66
  });
100
-
101
- // src/create/schema/parsers/default.ts
102
- var createDefaultSchema = (zodDefault, state) => {
67
+ const createDefaultSchema = (zodDefault, state) => {
103
68
  const schemaObject = createSchemaObject(zodDefault._def.innerType, state, [
104
69
  "default"
105
70
  ]);
@@ -107,19 +72,15 @@ var createDefaultSchema = (zodDefault, state) => {
107
72
  default: zodDefault._def.defaultValue()
108
73
  });
109
74
  };
110
-
111
- // src/openapi.ts
112
- var openApiVersions = [
75
+ const openApiVersions = [
113
76
  "3.0.0",
114
77
  "3.0.1",
115
78
  "3.0.2",
116
79
  "3.0.3",
117
80
  "3.1.0"
118
81
  ];
119
- var satisfiesVersion = (test, against) => openApiVersions.indexOf(test) >= openApiVersions.indexOf(against);
120
-
121
- // src/create/schema/parsers/nativeEnum.ts
122
- var createNativeEnumSchema = (zodEnum, state) => {
82
+ const satisfiesVersion = (test, against) => openApiVersions.indexOf(test) >= openApiVersions.indexOf(against);
83
+ const createNativeEnumSchema = (zodEnum, state) => {
123
84
  const enumValues = getValidEnumValues(zodEnum._def.values);
124
85
  const { numbers, strings } = sortStringsAndNumbers(enumValues);
125
86
  if (strings.length && numbers.length) {
@@ -158,26 +119,25 @@ var createNativeEnumSchema = (zodEnum, state) => {
158
119
  }
159
120
  };
160
121
  };
161
- var getValidEnumValues = (enumValues) => {
122
+ const getValidEnumValues = (enumValues) => {
162
123
  const keys = Object.keys(enumValues).filter(
163
124
  (key) => typeof enumValues[enumValues[key]] !== "number"
164
125
  );
165
126
  return keys.map((key) => enumValues[key]);
166
127
  };
167
- var sortStringsAndNumbers = (values) => ({
128
+ const sortStringsAndNumbers = (values) => ({
168
129
  strings: values.filter((value) => typeof value === "string"),
169
130
  numbers: values.filter((value) => typeof value === "number")
170
131
  });
171
-
172
- // src/create/schema/parsers/transform.ts
173
- var createTransformSchema = (zodTransform, state) => {
174
- if (zodTransform._def.openapi?.effectType === "output") {
132
+ const createTransformSchema = (zodTransform, state) => {
133
+ var _a, _b, _c;
134
+ if (((_a = zodTransform._def.openapi) == null ? void 0 : _a.effectType) === "output") {
175
135
  return {
176
136
  type: "schema",
177
137
  schema: createManualOutputTransformSchema(zodTransform, state)
178
138
  };
179
139
  }
180
- if (zodTransform._def.openapi?.effectType === "input" || zodTransform._def.openapi?.effectType === "same") {
140
+ if (((_b = zodTransform._def.openapi) == null ? void 0 : _b.effectType) === "input" || ((_c = zodTransform._def.openapi) == null ? void 0 : _c.effectType) === "same") {
181
141
  return createSchemaObject(zodTransform._def.schema, state, [
182
142
  "transform input"
183
143
  ]);
@@ -206,8 +166,9 @@ var createTransformSchema = (zodTransform, state) => {
206
166
  ])
207
167
  };
208
168
  };
209
- var createManualOutputTransformSchema = (zodTransform, state) => {
210
- if (!zodTransform._def.openapi?.type) {
169
+ const createManualOutputTransformSchema = (zodTransform, state) => {
170
+ var _a;
171
+ if (!((_a = zodTransform._def.openapi) == null ? void 0 : _a.type)) {
211
172
  const zodType = zodTransform.constructor.name;
212
173
  const schemaName = `${zodType} - ${zodTransform._def.effect.type}`;
213
174
  throw new Error(
@@ -220,13 +181,13 @@ var createManualOutputTransformSchema = (zodTransform, state) => {
220
181
  type: zodTransform._def.openapi.type
221
182
  };
222
183
  };
223
- var getZodTypeName = (zodType) => {
184
+ const getZodTypeName = (zodType) => {
224
185
  if (isZodType(zodType, "ZodEffects")) {
225
186
  return `${zodType._def.typeName} - ${zodType._def.effect.type}`;
226
187
  }
227
188
  return zodType._def.typeName;
228
189
  };
229
- var throwTransformError = (effect) => {
190
+ const throwTransformError = (effect) => {
230
191
  const typeName = getZodTypeName(effect.zodType);
231
192
  const input = effect.creationType;
232
193
  const opposite = input === "input" ? "output" : "input";
@@ -246,7 +207,7 @@ This may cause the schema to render incorrectly and is most likely a mistake. Yo
246
207
  5. Deregister the component containing the transformation`
247
208
  );
248
209
  };
249
- var resolveSingleEffect = (effect, state) => {
210
+ const resolveSingleEffect = (effect, state) => {
250
211
  if (effect.type === "schema") {
251
212
  return {
252
213
  creationType: effect.creationType,
@@ -259,7 +220,7 @@ var resolveSingleEffect = (effect, state) => {
259
220
  return;
260
221
  }
261
222
  const component = state.components.schemas.get(effect.zodType);
262
- if (component?.type !== "complete") {
223
+ if ((component == null ? void 0 : component.type) !== "complete") {
263
224
  throw new Error("Something went wrong, component schema is not complete");
264
225
  }
265
226
  if (component.resolvedEffect) {
@@ -288,14 +249,14 @@ var resolveSingleEffect = (effect, state) => {
288
249
  }
289
250
  return void 0;
290
251
  };
291
- var resolveEffect = (effects, state) => {
252
+ const resolveEffect = (effects, state) => {
292
253
  const { input, output } = effects.reduce(
293
254
  (acc, effect) => {
294
255
  const resolvedSchemaEffect = resolveSingleEffect(effect, state);
295
- if (resolvedSchemaEffect?.creationType === "input") {
256
+ if ((resolvedSchemaEffect == null ? void 0 : resolvedSchemaEffect.creationType) === "input") {
296
257
  acc.input.push(resolvedSchemaEffect);
297
258
  }
298
- if (resolvedSchemaEffect?.creationType === "output") {
259
+ if ((resolvedSchemaEffect == null ? void 0 : resolvedSchemaEffect.creationType) === "output") {
299
260
  acc.output.push(resolvedSchemaEffect);
300
261
  }
301
262
  if (resolvedSchemaEffect && acc.input.length > 1 && acc.output.length > 1) {
@@ -313,13 +274,13 @@ var resolveEffect = (effects, state) => {
313
274
  }
314
275
  return void 0;
315
276
  };
316
- var verifyEffects = (effects, state) => {
277
+ const verifyEffects = (effects, state) => {
317
278
  const resolved = resolveEffect(effects, state);
318
- if (resolved?.creationType && resolved.creationType !== state.type) {
279
+ if ((resolved == null ? void 0 : resolved.creationType) && resolved.creationType !== state.type) {
319
280
  throwTransformError(resolved);
320
281
  }
321
282
  };
322
- var flattenEffects = (effects) => {
283
+ const flattenEffects = (effects) => {
323
284
  const allEffects = effects.reduce((acc, effect) => {
324
285
  if (effect) {
325
286
  return acc.concat(effect);
@@ -328,9 +289,7 @@ var flattenEffects = (effects) => {
328
289
  }, []);
329
290
  return allEffects.length ? allEffects : void 0;
330
291
  };
331
-
332
- // src/create/schema/parsers/discriminatedUnion.ts
333
- var createDiscriminatedUnionSchema = (zodDiscriminatedUnion, state) => {
292
+ const createDiscriminatedUnionSchema = (zodDiscriminatedUnion, state) => {
334
293
  const options = zodDiscriminatedUnion.options;
335
294
  const schemas = options.map(
336
295
  (option, index) => createSchemaObject(option, state, [`discriminated union option ${index}`])
@@ -351,7 +310,7 @@ var createDiscriminatedUnionSchema = (zodDiscriminatedUnion, state) => {
351
310
  effects: flattenEffects(schemas.map((schema) => schema.effects))
352
311
  };
353
312
  };
354
- var unwrapLiterals = (zodType, state) => {
313
+ const unwrapLiterals = (zodType, state) => {
355
314
  if (isZodType(zodType, "ZodLiteral")) {
356
315
  if (typeof zodType._def.value !== "string") {
357
316
  return void 0;
@@ -378,14 +337,14 @@ var unwrapLiterals = (zodType, state) => {
378
337
  }
379
338
  return void 0;
380
339
  };
381
- var mapDiscriminator = (schemas, zodObjects, discriminator, state) => {
340
+ const mapDiscriminator = (schemas, zodObjects, discriminator, state) => {
382
341
  if (typeof discriminator !== "string") {
383
342
  return void 0;
384
343
  }
385
344
  const mapping = {};
386
345
  for (const [index, zodObject] of zodObjects.entries()) {
387
346
  const schema = schemas[index];
388
- const componentSchemaRef = "$ref" in schema ? schema?.$ref : void 0;
347
+ const componentSchemaRef = "$ref" in schema ? schema == null ? void 0 : schema.$ref : void 0;
389
348
  if (!componentSchemaRef) {
390
349
  return void 0;
391
350
  }
@@ -403,18 +362,14 @@ var mapDiscriminator = (schemas, zodObjects, discriminator, state) => {
403
362
  mapping
404
363
  };
405
364
  };
406
-
407
- // src/create/schema/parsers/enum.ts
408
- var createEnumSchema = (zodEnum) => ({
365
+ const createEnumSchema = (zodEnum) => ({
409
366
  type: "schema",
410
367
  schema: {
411
368
  type: "string",
412
369
  enum: zodEnum._def.values
413
370
  }
414
371
  });
415
-
416
- // src/create/schema/parsers/intersection.ts
417
- var createIntersectionSchema = (zodIntersection, state) => {
372
+ const createIntersectionSchema = (zodIntersection, state) => {
418
373
  const left = createSchemaObject(zodIntersection._def.left, state, [
419
374
  "intersection left"
420
375
  ]);
@@ -429,23 +384,17 @@ var createIntersectionSchema = (zodIntersection, state) => {
429
384
  effects: flattenEffects([left.effects, right.effects])
430
385
  };
431
386
  };
432
-
433
- // src/create/schema/parsers/lazy.ts
434
- var createLazySchema = (zodLazy, state) => {
387
+ const createLazySchema = (zodLazy, state) => {
435
388
  const innerSchema = zodLazy._def.getter();
436
389
  return createSchemaObject(innerSchema, state, ["lazy schema"]);
437
390
  };
438
-
439
- // src/create/schema/parsers/null.ts
440
- var createNullSchema = () => ({
391
+ const createNullSchema = () => ({
441
392
  type: "schema",
442
393
  schema: {
443
394
  type: "null"
444
395
  }
445
396
  });
446
-
447
- // src/create/schema/parsers/literal.ts
448
- var createLiteralSchema = (zodLiteral, state) => {
397
+ const createLiteralSchema = (zodLiteral, state) => {
449
398
  if (zodLiteral.value === null) {
450
399
  return createNullSchema();
451
400
  }
@@ -466,10 +415,9 @@ var createLiteralSchema = (zodLiteral, state) => {
466
415
  }
467
416
  };
468
417
  };
469
-
470
- // src/create/schema/parsers/manual.ts
471
- var createManualTypeSchema = (zodSchema, state) => {
472
- if (!zodSchema._def.openapi?.type) {
418
+ const createManualTypeSchema = (zodSchema, state) => {
419
+ var _a;
420
+ if (!((_a = zodSchema._def.openapi) == null ? void 0 : _a.type)) {
473
421
  const schemaName = zodSchema.constructor.name;
474
422
  throw new Error(
475
423
  `Unknown schema ${schemaName} at ${state.path.join(
@@ -484,9 +432,7 @@ var createManualTypeSchema = (zodSchema, state) => {
484
432
  }
485
433
  };
486
434
  };
487
-
488
- // src/create/schema/parsers/nullable.ts
489
- var createNullableSchema = (zodNullable, state) => {
435
+ const createNullableSchema = (zodNullable, state) => {
490
436
  const schemaObject = createSchemaObject(zodNullable.unwrap(), state, [
491
437
  "nullable"
492
438
  ]);
@@ -556,7 +502,7 @@ var createNullableSchema = (zodNullable, state) => {
556
502
  effects: schemaObject.effects
557
503
  };
558
504
  };
559
- var mapNullType = (type) => {
505
+ const mapNullType = (type) => {
560
506
  if (!type) {
561
507
  return "null";
562
508
  }
@@ -565,15 +511,13 @@ var mapNullType = (type) => {
565
511
  }
566
512
  return [type, "null"];
567
513
  };
568
- var mapNullOf = (ofSchema, openapi) => {
514
+ const mapNullOf = (ofSchema, openapi) => {
569
515
  if (satisfiesVersion(openapi, "3.1.0")) {
570
516
  return [...ofSchema, { type: "null" }];
571
517
  }
572
518
  return [...ofSchema, { nullable: true }];
573
519
  };
574
-
575
- // src/create/schema/parsers/number.ts
576
- var createNumberSchema = (zodNumber, state) => {
520
+ const createNumberSchema = (zodNumber, state) => {
577
521
  const zodNumberChecks = getZodNumberChecks(zodNumber);
578
522
  const minimum = mapMinimum(zodNumberChecks, state.components.openapi);
579
523
  const maximum = mapMaximum(zodNumberChecks, state.components.openapi);
@@ -587,7 +531,7 @@ var createNumberSchema = (zodNumber, state) => {
587
531
  }
588
532
  };
589
533
  };
590
- var mapMaximum = (zodNumberCheck, openapi) => {
534
+ const mapMaximum = (zodNumberCheck, openapi) => {
591
535
  if (!zodNumberCheck.max) {
592
536
  return void 0;
593
537
  }
@@ -600,7 +544,7 @@ var mapMaximum = (zodNumberCheck, openapi) => {
600
544
  }
601
545
  return { maximum, exclusiveMaximum: true };
602
546
  };
603
- var mapMinimum = (zodNumberCheck, openapi) => {
547
+ const mapMinimum = (zodNumberCheck, openapi) => {
604
548
  if (!zodNumberCheck.min) {
605
549
  return void 0;
606
550
  }
@@ -613,23 +557,22 @@ var mapMinimum = (zodNumberCheck, openapi) => {
613
557
  }
614
558
  return { minimum, exclusiveMinimum: true };
615
559
  };
616
- var getZodNumberChecks = (zodNumber) => zodNumber._def.checks.reduce((acc, check) => {
560
+ const getZodNumberChecks = (zodNumber) => zodNumber._def.checks.reduce((acc, check) => {
617
561
  acc[check.kind] = check;
618
562
  return acc;
619
563
  }, {});
620
- var mapNumberType = (zodNumberChecks) => zodNumberChecks.int ? "integer" : "number";
621
-
622
- // src/create/schema/parsers/optional.ts
623
- var createOptionalSchema = (zodOptional, state) => createSchemaObject(zodOptional.unwrap(), state, ["optional"]);
624
- var isOptionalSchema = (zodSchema, state) => {
564
+ const mapNumberType = (zodNumberChecks) => zodNumberChecks.int ? "integer" : "number";
565
+ const createOptionalSchema = (zodOptional, state) => createSchemaObject(zodOptional.unwrap(), state, ["optional"]);
566
+ const isOptionalSchema = (zodSchema, state) => {
567
+ var _a, _b, _c;
625
568
  if (isZodType(zodSchema, "ZodOptional") || isZodType(zodSchema, "ZodNever") || isZodType(zodSchema, "ZodUndefined") || isZodType(zodSchema, "ZodLiteral") && zodSchema._def.value === void 0) {
626
569
  return { optional: true };
627
570
  }
628
571
  if (isZodType(zodSchema, "ZodDefault")) {
629
- if (zodSchema._def.openapi?.effectType === "input") {
572
+ if (((_a = zodSchema._def.openapi) == null ? void 0 : _a.effectType) === "input") {
630
573
  return { optional: true };
631
574
  }
632
- if (zodSchema._def.openapi?.effectType === "output") {
575
+ if (((_b = zodSchema._def.openapi) == null ? void 0 : _b.effectType) === "output") {
633
576
  return { optional: false };
634
577
  }
635
578
  return {
@@ -675,7 +618,7 @@ var isOptionalSchema = (zodSchema, state) => {
675
618
  );
676
619
  }
677
620
  if (isZodType(zodSchema, "ZodPipeline")) {
678
- const type = zodSchema._def.openapi?.effectType ?? state.type;
621
+ const type = ((_c = zodSchema._def.openapi) == null ? void 0 : _c.effectType) ?? state.type;
679
622
  if (type === "input") {
680
623
  return isOptionalSchema(zodSchema._def.in, state);
681
624
  }
@@ -688,12 +631,11 @@ var isOptionalSchema = (zodSchema, state) => {
688
631
  }
689
632
  return { optional: zodSchema.isOptional() };
690
633
  };
691
-
692
- // src/create/schema/parsers/object.ts
693
- var createObjectSchema = (zodObject, state) => {
634
+ const createObjectSchema = (zodObject, state) => {
635
+ var _a;
694
636
  const extendedSchema = createExtendedSchema(
695
637
  zodObject,
696
- zodObject._def.extendMetadata?.extends,
638
+ (_a = zodObject._def.extendMetadata) == null ? void 0 : _a.extends,
697
639
  state
698
640
  );
699
641
  if (extendedSchema) {
@@ -708,12 +650,13 @@ var createObjectSchema = (zodObject, state) => {
708
650
  state
709
651
  );
710
652
  };
711
- var createExtendedSchema = (zodObject, baseZodObject, state) => {
653
+ const createExtendedSchema = (zodObject, baseZodObject, state) => {
654
+ var _a;
712
655
  if (!baseZodObject) {
713
656
  return void 0;
714
657
  }
715
658
  const component = state.components.schemas.get(baseZodObject);
716
- if (component ?? baseZodObject._def.openapi?.ref) {
659
+ if (component ?? ((_a = baseZodObject._def.openapi) == null ? void 0 : _a.ref)) {
717
660
  createSchemaObject(baseZodObject, state, ["extended schema"]);
718
661
  }
719
662
  const completeComponent = state.components.schemas.get(baseZodObject);
@@ -764,7 +707,7 @@ var createExtendedSchema = (zodObject, baseZodObject, state) => {
764
707
  ])
765
708
  };
766
709
  };
767
- var createDiffOpts = (baseOpts, extendedOpts) => {
710
+ const createDiffOpts = (baseOpts, extendedOpts) => {
768
711
  if (baseOpts.unknownKeys === "strict" || !isZodType(baseOpts.catchAll, "ZodNever")) {
769
712
  return void 0;
770
713
  }
@@ -773,7 +716,7 @@ var createDiffOpts = (baseOpts, extendedOpts) => {
773
716
  unknownKeys: extendedOpts.unknownKeys
774
717
  };
775
718
  };
776
- var createShapeDiff = (baseObj, extendedObj) => {
719
+ const createShapeDiff = (baseObj, extendedObj) => {
777
720
  const acc = {};
778
721
  for (const [key, val] of Object.entries(extendedObj)) {
779
722
  const baseValue = baseObj[key];
@@ -788,7 +731,7 @@ var createShapeDiff = (baseObj, extendedObj) => {
788
731
  }
789
732
  return acc;
790
733
  };
791
- var createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state) => {
734
+ const createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state) => {
792
735
  const properties = mapProperties(shape, state);
793
736
  const required = mapRequired(shape, state);
794
737
  const additionalProperties = !isZodType(catchAll, "ZodNever") ? createSchemaObject(catchAll, state, ["additional properties"]) : void 0;
@@ -797,20 +740,20 @@ var createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state) => {
797
740
  schema: {
798
741
  type: "object",
799
742
  ...properties && { properties: properties.properties },
800
- ...required?.required.length && { required: required.required },
743
+ ...(required == null ? void 0 : required.required.length) && { required: required.required },
801
744
  ...unknownKeys === "strict" && { additionalProperties: false },
802
745
  ...additionalProperties && {
803
746
  additionalProperties: additionalProperties.schema
804
747
  }
805
748
  },
806
749
  effects: flattenEffects([
807
- ...properties?.effects ?? [],
808
- additionalProperties?.effects,
809
- required?.effects
750
+ ...(properties == null ? void 0 : properties.effects) ?? [],
751
+ additionalProperties == null ? void 0 : additionalProperties.effects,
752
+ required == null ? void 0 : required.effects
810
753
  ])
811
754
  };
812
755
  };
813
- var mapRequired = (shape, state) => {
756
+ const mapRequired = (shape, state) => {
814
757
  const { required, effects: allEffects } = Object.entries(shape).reduce(
815
758
  (acc, [key, zodSchema]) => {
816
759
  state.path.push(`property: ${key}`);
@@ -831,7 +774,7 @@ var mapRequired = (shape, state) => {
831
774
  );
832
775
  return { required, effects: flattenEffects(allEffects) };
833
776
  };
834
- var mapProperties = (shape, state) => {
777
+ const mapProperties = (shape, state) => {
835
778
  const shapeEntries = Object.entries(shape);
836
779
  if (!shapeEntries.length) {
837
780
  return void 0;
@@ -854,13 +797,12 @@ var mapProperties = (shape, state) => {
854
797
  }
855
798
  );
856
799
  };
857
-
858
- // src/create/schema/parsers/pipeline.ts
859
- var createPipelineSchema = (zodPipeline, state) => {
860
- if (zodPipeline._def.openapi?.effectType === "input" || zodPipeline._def.openapi?.effectType === "same") {
800
+ const createPipelineSchema = (zodPipeline, state) => {
801
+ var _a, _b, _c;
802
+ if (((_a = zodPipeline._def.openapi) == null ? void 0 : _a.effectType) === "input" || ((_b = zodPipeline._def.openapi) == null ? void 0 : _b.effectType) === "same") {
861
803
  return createSchemaObject(zodPipeline._def.in, state, ["pipeline input"]);
862
804
  }
863
- if (zodPipeline._def.openapi?.effectType === "output") {
805
+ if (((_c = zodPipeline._def.openapi) == null ? void 0 : _c.effectType) === "output") {
864
806
  return createSchemaObject(zodPipeline._def.out, state, ["pipeline output"]);
865
807
  }
866
808
  if (state.type === "input") {
@@ -900,18 +842,12 @@ var createPipelineSchema = (zodPipeline, state) => {
900
842
  ])
901
843
  };
902
844
  };
903
-
904
- // src/create/schema/parsers/preprocess.ts
905
- var createPreprocessSchema = (zodPreprocess, state) => createSchemaObject(zodPreprocess._def.schema, state, ["preprocess schema"]);
906
-
907
- // src/create/schema/parsers/readonly.ts
908
- var createReadonlySchema = (zodReadonly, state) => (
845
+ const createPreprocessSchema = (zodPreprocess, state) => createSchemaObject(zodPreprocess._def.schema, state, ["preprocess schema"]);
846
+ const createReadonlySchema = (zodReadonly, state) => (
909
847
  // Readonly doesn't change OpenAPI schema
910
848
  createSchemaObject(zodReadonly._def.innerType, state, ["readonly"])
911
849
  );
912
-
913
- // src/create/schema/parsers/record.ts
914
- var createRecordSchema = (zodRecord, state) => {
850
+ const createRecordSchema = (zodRecord, state) => {
915
851
  const additionalProperties = createSchemaObject(
916
852
  zodRecord.valueSchema,
917
853
  state,
@@ -966,15 +902,12 @@ var createRecordSchema = (zodRecord, state) => {
966
902
  effects: additionalProperties.effects
967
903
  };
968
904
  };
969
-
970
- // src/create/schema/parsers/refine.ts
971
- var createRefineSchema = (zodRefine, state) => createSchemaObject(zodRefine._def.schema, state, ["refine schema"]);
972
-
973
- // src/create/schema/parsers/set.ts
974
- var createSetSchema = (zodSet, state) => {
905
+ const createRefineSchema = (zodRefine, state) => createSchemaObject(zodRefine._def.schema, state, ["refine schema"]);
906
+ const createSetSchema = (zodSet, state) => {
907
+ var _a, _b;
975
908
  const schema = zodSet._def.valueType;
976
- const minItems = zodSet._def.minSize?.value;
977
- const maxItems = zodSet._def.maxSize?.value;
909
+ const minItems = (_a = zodSet._def.minSize) == null ? void 0 : _a.value;
910
+ const maxItems = (_b = zodSet._def.maxSize) == null ? void 0 : _b.value;
978
911
  const itemSchema = createSchemaObject(schema, state, ["set items"]);
979
912
  return {
980
913
  type: "schema",
@@ -988,14 +921,13 @@ var createSetSchema = (zodSet, state) => {
988
921
  effects: itemSchema.effects
989
922
  };
990
923
  };
991
-
992
- // src/create/schema/parsers/string.ts
993
- var createStringSchema = (zodString, state) => {
924
+ const createStringSchema = (zodString, state) => {
925
+ var _a, _b, _c, _d, _e, _f, _g, _h;
994
926
  const zodStringChecks = getZodStringChecks(zodString);
995
927
  const format = mapStringFormat(zodStringChecks);
996
928
  const patterns = mapPatterns(zodStringChecks);
997
- const minLength = zodStringChecks.length?.[0]?.value ?? zodStringChecks.min?.[0]?.value;
998
- const maxLength = zodStringChecks.length?.[0]?.value ?? zodStringChecks.max?.[0]?.value;
929
+ const minLength = ((_b = (_a = zodStringChecks.length) == null ? void 0 : _a[0]) == null ? void 0 : _b.value) ?? ((_d = (_c = zodStringChecks.min) == null ? void 0 : _c[0]) == null ? void 0 : _d.value);
930
+ const maxLength = ((_f = (_e = zodStringChecks.length) == null ? void 0 : _e[0]) == null ? void 0 : _f.value) ?? ((_h = (_g = zodStringChecks.max) == null ? void 0 : _g[0]) == null ? void 0 : _h.value);
999
931
  const contentEncoding = satisfiesVersion(state.components.openapi, "3.1.0") ? mapContentEncoding(zodStringChecks) : void 0;
1000
932
  if (patterns.length <= 1) {
1001
933
  return {
@@ -1032,7 +964,7 @@ var createStringSchema = (zodString, state) => {
1032
964
  }
1033
965
  };
1034
966
  };
1035
- var getZodStringChecks = (zodString) => zodString._def.checks.reduce(
967
+ const getZodStringChecks = (zodString) => zodString._def.checks.reduce(
1036
968
  (acc, check) => {
1037
969
  const mapping = acc[check.kind];
1038
970
  if (mapping) {
@@ -1044,7 +976,7 @@ var getZodStringChecks = (zodString) => zodString._def.checks.reduce(
1044
976
  },
1045
977
  {}
1046
978
  );
1047
- var mapPatterns = (zodStringChecks) => {
979
+ const mapPatterns = (zodStringChecks) => {
1048
980
  const startsWith = mapStartsWith(zodStringChecks);
1049
981
  const endsWith = mapEndsWith(zodStringChecks);
1050
982
  const regex = mapRegex(zodStringChecks);
@@ -1057,29 +989,37 @@ var mapPatterns = (zodStringChecks) => {
1057
989
  ];
1058
990
  return patterns;
1059
991
  };
1060
- var mapStartsWith = (zodStringChecks) => {
1061
- if (zodStringChecks.startsWith?.[0]?.value) {
992
+ const mapStartsWith = (zodStringChecks) => {
993
+ var _a, _b;
994
+ if ((_b = (_a = zodStringChecks.startsWith) == null ? void 0 : _a[0]) == null ? void 0 : _b.value) {
1062
995
  return `^${zodStringChecks.startsWith[0].value}`;
1063
996
  }
1064
997
  return void 0;
1065
998
  };
1066
- var mapEndsWith = (zodStringChecks) => {
1067
- if (zodStringChecks.endsWith?.[0]?.value) {
999
+ const mapEndsWith = (zodStringChecks) => {
1000
+ var _a, _b;
1001
+ if ((_b = (_a = zodStringChecks.endsWith) == null ? void 0 : _a[0]) == null ? void 0 : _b.value) {
1068
1002
  return `${zodStringChecks.endsWith[0].value}$`;
1069
1003
  }
1070
1004
  return void 0;
1071
1005
  };
1072
- var mapRegex = (zodStringChecks) => zodStringChecks.regex?.map((regexCheck) => regexCheck.regex.source);
1073
- var mapIncludes = (zodStringChecks) => zodStringChecks.includes?.map((includeCheck) => {
1074
- if (includeCheck.position === 0) {
1075
- return `^${includeCheck.value}`;
1076
- }
1077
- if (includeCheck.position) {
1078
- return `^.{${includeCheck.position}}${includeCheck.value}`;
1079
- }
1080
- return includeCheck.value;
1081
- });
1082
- var mapStringFormat = (zodStringChecks) => {
1006
+ const mapRegex = (zodStringChecks) => {
1007
+ var _a;
1008
+ return (_a = zodStringChecks.regex) == null ? void 0 : _a.map((regexCheck) => regexCheck.regex.source);
1009
+ };
1010
+ const mapIncludes = (zodStringChecks) => {
1011
+ var _a;
1012
+ return (_a = zodStringChecks.includes) == null ? void 0 : _a.map((includeCheck) => {
1013
+ if (includeCheck.position === 0) {
1014
+ return `^${includeCheck.value}`;
1015
+ }
1016
+ if (includeCheck.position) {
1017
+ return `^.{${includeCheck.position}}${includeCheck.value}`;
1018
+ }
1019
+ return includeCheck.value;
1020
+ });
1021
+ };
1022
+ const mapStringFormat = (zodStringChecks) => {
1083
1023
  if (zodStringChecks.uuid) {
1084
1024
  return "uuid";
1085
1025
  }
@@ -1103,15 +1043,13 @@ var mapStringFormat = (zodStringChecks) => {
1103
1043
  }
1104
1044
  return void 0;
1105
1045
  };
1106
- var mapContentEncoding = (zodStringChecks) => {
1046
+ const mapContentEncoding = (zodStringChecks) => {
1107
1047
  if (zodStringChecks.base64) {
1108
1048
  return "base64";
1109
1049
  }
1110
1050
  return void 0;
1111
1051
  };
1112
-
1113
- // src/create/schema/parsers/tuple.ts
1114
- var createTupleSchema = (zodTuple, state) => {
1052
+ const createTupleSchema = (zodTuple, state) => {
1115
1053
  const items = zodTuple.items;
1116
1054
  const rest = zodTuple._def.rest;
1117
1055
  const prefixItems = mapPrefixItems(items, state);
@@ -1127,7 +1065,7 @@ var createTupleSchema = (zodTuple, state) => {
1127
1065
  prefixItems: prefixItems.schemas.map((item) => item.schema)
1128
1066
  }
1129
1067
  },
1130
- effects: prefixItems?.effects
1068
+ effects: prefixItems == null ? void 0 : prefixItems.effects
1131
1069
  };
1132
1070
  }
1133
1071
  const itemSchema = createSchemaObject(rest, state, ["tuple items"]);
@@ -1140,7 +1078,7 @@ var createTupleSchema = (zodTuple, state) => {
1140
1078
  prefixItems: prefixItems.schemas.map((item) => item.schema)
1141
1079
  }
1142
1080
  },
1143
- effects: flattenEffects([prefixItems?.effects, itemSchema.effects])
1081
+ effects: flattenEffects([prefixItems == null ? void 0 : prefixItems.effects, itemSchema.effects])
1144
1082
  };
1145
1083
  }
1146
1084
  if (!rest) {
@@ -1154,7 +1092,7 @@ var createTupleSchema = (zodTuple, state) => {
1154
1092
  items: { oneOf: prefixItems.schemas.map((item) => item.schema) }
1155
1093
  }
1156
1094
  },
1157
- effects: prefixItems?.effects
1095
+ effects: prefixItems == null ? void 0 : prefixItems.effects
1158
1096
  };
1159
1097
  }
1160
1098
  if (prefixItems) {
@@ -1180,7 +1118,7 @@ var createTupleSchema = (zodTuple, state) => {
1180
1118
  }
1181
1119
  };
1182
1120
  };
1183
- var mapPrefixItems = (items, state) => {
1121
+ const mapPrefixItems = (items, state) => {
1184
1122
  if (items.length) {
1185
1123
  const schemas = items.map(
1186
1124
  (item, index) => createSchemaObject(item, state, [`tuple item ${index}`])
@@ -1192,13 +1130,12 @@ var mapPrefixItems = (items, state) => {
1192
1130
  }
1193
1131
  return void 0;
1194
1132
  };
1195
-
1196
- // src/create/schema/parsers/union.ts
1197
- var createUnionSchema = (zodUnion, state) => {
1133
+ const createUnionSchema = (zodUnion, state) => {
1134
+ var _a;
1198
1135
  const schemas = zodUnion.options.map(
1199
1136
  (option, index) => createSchemaObject(option, state, [`union option ${index}`])
1200
1137
  );
1201
- if (zodUnion._def.openapi?.unionOneOf) {
1138
+ if ((_a = zodUnion._def.openapi) == null ? void 0 : _a.unionOneOf) {
1202
1139
  return {
1203
1140
  type: "schema",
1204
1141
  schema: {
@@ -1215,16 +1152,13 @@ var createUnionSchema = (zodUnion, state) => {
1215
1152
  effects: flattenEffects(schemas.map((s) => s.effects))
1216
1153
  };
1217
1154
  };
1218
-
1219
- // src/create/schema/parsers/unknown.ts
1220
- var createUnknownSchema = (_zodUnknown) => ({
1155
+ const createUnknownSchema = (_zodUnknown) => ({
1221
1156
  type: "schema",
1222
1157
  schema: {}
1223
1158
  });
1224
-
1225
- // src/create/schema/parsers/index.ts
1226
- var createSchemaSwitch = (zodSchema, state) => {
1227
- if (zodSchema._def.openapi?.type) {
1159
+ const createSchemaSwitch = (zodSchema, state) => {
1160
+ var _a;
1161
+ if ((_a = zodSchema._def.openapi) == null ? void 0 : _a.type) {
1228
1162
  return createManualTypeSchema(zodSchema, state);
1229
1163
  }
1230
1164
  if (isZodType(zodSchema, "ZodString")) {
@@ -1234,7 +1168,7 @@ var createSchemaSwitch = (zodSchema, state) => {
1234
1168
  return createNumberSchema(zodSchema, state);
1235
1169
  }
1236
1170
  if (isZodType(zodSchema, "ZodBoolean")) {
1237
- return createBooleanSchema(zodSchema);
1171
+ return createBooleanSchema();
1238
1172
  }
1239
1173
  if (isZodType(zodSchema, "ZodEnum")) {
1240
1174
  return createEnumSchema(zodSchema);
@@ -1279,7 +1213,7 @@ var createSchemaSwitch = (zodSchema, state) => {
1279
1213
  return createTupleSchema(zodSchema, state);
1280
1214
  }
1281
1215
  if (isZodType(zodSchema, "ZodDate")) {
1282
- return createDateSchema(zodSchema);
1216
+ return createDateSchema();
1283
1217
  }
1284
1218
  if (isZodType(zodSchema, "ZodPipeline")) {
1285
1219
  return createPipelineSchema(zodSchema, state);
@@ -1303,7 +1237,7 @@ var createSchemaSwitch = (zodSchema, state) => {
1303
1237
  return createCatchSchema(zodSchema, state);
1304
1238
  }
1305
1239
  if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) {
1306
- return createUnknownSchema(zodSchema);
1240
+ return createUnknownSchema();
1307
1241
  }
1308
1242
  if (isZodType(zodSchema, "ZodLazy")) {
1309
1243
  return createLazySchema(zodSchema, state);
@@ -1316,10 +1250,8 @@ var createSchemaSwitch = (zodSchema, state) => {
1316
1250
  }
1317
1251
  return createManualTypeSchema(zodSchema, state);
1318
1252
  };
1319
-
1320
- // src/create/schema/index.ts
1321
- var isDescriptionEqual = (schema, zodSchema) => schema.type === "ref" && zodSchema.description === schema.zodType.description;
1322
- var createNewSchema = (zodSchema, state) => {
1253
+ const isDescriptionEqual = (schema, zodSchema) => schema.type === "ref" && zodSchema.description === schema.zodType.description;
1254
+ const createNewSchema = (zodSchema, state) => {
1323
1255
  if (state.visited.has(zodSchema)) {
1324
1256
  throw new Error(
1325
1257
  `The schema at ${state.path.join(
@@ -1346,7 +1278,7 @@ var createNewSchema = (zodSchema, state) => {
1346
1278
  state.visited.delete(zodSchema);
1347
1279
  return schemaWithMetadata;
1348
1280
  };
1349
- var createNewRef = (ref, zodSchema, state) => {
1281
+ const createNewRef = (ref, zodSchema, state) => {
1350
1282
  state.components.schemas.set(zodSchema, {
1351
1283
  type: "in-progress",
1352
1284
  ref
@@ -1374,7 +1306,7 @@ var createNewRef = (ref, zodSchema, state) => {
1374
1306
  zodType: zodSchema
1375
1307
  };
1376
1308
  };
1377
- var createExistingRef = (zodSchema, component, state) => {
1309
+ const createExistingRef = (zodSchema, component, state) => {
1378
1310
  if (component && component.type === "complete") {
1379
1311
  return {
1380
1312
  type: "ref",
@@ -1405,34 +1337,33 @@ var createExistingRef = (zodSchema, component, state) => {
1405
1337
  }
1406
1338
  return;
1407
1339
  };
1408
- var createSchemaOrRef = (zodSchema, state) => {
1340
+ const createSchemaOrRef = (zodSchema, state) => {
1341
+ var _a;
1409
1342
  const component = state.components.schemas.get(zodSchema);
1410
1343
  const existingRef = createExistingRef(zodSchema, component, state);
1411
1344
  if (existingRef) {
1412
1345
  return existingRef;
1413
1346
  }
1414
- const ref = zodSchema._def.openapi?.ref ?? component?.ref;
1347
+ const ref = ((_a = zodSchema._def.openapi) == null ? void 0 : _a.ref) ?? (component == null ? void 0 : component.ref);
1415
1348
  if (ref) {
1416
1349
  return createNewRef(ref, zodSchema, state);
1417
1350
  }
1418
1351
  return createNewSchema(zodSchema, state);
1419
1352
  };
1420
- var createSchemaObject = (zodSchema, state, subpath) => {
1353
+ const createSchemaObject = (zodSchema, state, subpath) => {
1421
1354
  state.path.push(...subpath);
1422
1355
  const schema = createSchemaOrRef(zodSchema, state);
1423
1356
  state.path.pop();
1424
1357
  return schema;
1425
1358
  };
1426
- var createSchema = (zodSchema, state, subpath) => {
1359
+ const createSchema = (zodSchema, state, subpath) => {
1427
1360
  const schema = createSchemaObject(zodSchema, state, subpath);
1428
1361
  if (schema.effects) {
1429
1362
  verifyEffects(schema.effects, state);
1430
1363
  }
1431
1364
  return schema.schema;
1432
1365
  };
1433
-
1434
- // src/create/content.ts
1435
- var createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1366
+ const createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1436
1367
  if (!schemaObject) {
1437
1368
  return void 0;
1438
1369
  }
@@ -1450,7 +1381,7 @@ var createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1450
1381
  subpath
1451
1382
  );
1452
1383
  };
1453
- var createMediaTypeObject = (mediaTypeObject, components, type, subpath) => {
1384
+ const createMediaTypeObject = (mediaTypeObject, components, type, subpath) => {
1454
1385
  if (!mediaTypeObject) {
1455
1386
  return void 0;
1456
1387
  }
@@ -1462,7 +1393,7 @@ var createMediaTypeObject = (mediaTypeObject, components, type, subpath) => {
1462
1393
  ])
1463
1394
  };
1464
1395
  };
1465
- var createContent = (contentObject, components, type, subpath) => Object.entries(contentObject).reduce(
1396
+ const createContent = (contentObject, components, type, subpath) => Object.entries(contentObject).reduce(
1466
1397
  (acc, [mediaType, zodOpenApiMediaTypeObject]) => {
1467
1398
  const mediaTypeObject = createMediaTypeObject(
1468
1399
  zodOpenApiMediaTypeObject,
@@ -1477,11 +1408,10 @@ var createContent = (contentObject, components, type, subpath) => Object.entries
1477
1408
  },
1478
1409
  {}
1479
1410
  );
1480
-
1481
- // src/create/parameters.ts
1482
- var createComponentParamRef = (ref) => `#/components/parameters/${ref}`;
1483
- var createBaseParameter = (schema, components, subpath) => {
1484
- const { ref, ...rest } = schema._def.openapi?.param ?? {};
1411
+ const createComponentParamRef = (ref) => `#/components/parameters/${ref}`;
1412
+ const createBaseParameter = (schema, components, subpath) => {
1413
+ var _a, _b, _c;
1414
+ const { ref, ...rest } = ((_a = schema._def.openapi) == null ? void 0 : _a.param) ?? {};
1485
1415
  const state = {
1486
1416
  components,
1487
1417
  type: "input",
@@ -1489,8 +1419,8 @@ var createBaseParameter = (schema, components, subpath) => {
1489
1419
  visited: /* @__PURE__ */ new Set()
1490
1420
  };
1491
1421
  const schemaObject = createSchema(schema, state, [...subpath, "schema"]);
1492
- const required = !isOptionalSchema(schema, state)?.optional;
1493
- const description = schema._def.openapi?.description ?? schema._def.description;
1422
+ const required = !((_b = isOptionalSchema(schema, state)) == null ? void 0 : _b.optional);
1423
+ const description = ((_c = schema._def.openapi) == null ? void 0 : _c.description) ?? schema._def.description;
1494
1424
  return {
1495
1425
  ...description && { description },
1496
1426
  ...rest,
@@ -1498,10 +1428,11 @@ var createBaseParameter = (schema, components, subpath) => {
1498
1428
  ...required && { required }
1499
1429
  };
1500
1430
  };
1501
- var createParamOrRef = (zodSchema, components, subpath, type, name) => {
1431
+ const createParamOrRef = (zodSchema, components, subpath, type, name) => {
1432
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1502
1433
  const component = components.parameters.get(zodSchema);
1503
- const paramType = zodSchema._def?.openapi?.param?.in ?? component?.in ?? type;
1504
- const paramName = zodSchema._def?.openapi?.param?.name ?? component?.name ?? name;
1434
+ const paramType = ((_c = (_b = (_a = zodSchema._def) == null ? void 0 : _a.openapi) == null ? void 0 : _b.param) == null ? void 0 : _c.in) ?? (component == null ? void 0 : component.in) ?? type;
1435
+ const paramName = ((_f = (_e = (_d = zodSchema._def) == null ? void 0 : _d.openapi) == null ? void 0 : _e.param) == null ? void 0 : _f.name) ?? (component == null ? void 0 : component.name) ?? name;
1505
1436
  if (!paramType) {
1506
1437
  throw new Error("Parameter type missing");
1507
1438
  }
@@ -1520,7 +1451,7 @@ var createParamOrRef = (zodSchema, components, subpath, type, name) => {
1520
1451
  if ("$ref" in baseParamOrRef) {
1521
1452
  throw new Error("Unexpected Error: received a reference object");
1522
1453
  }
1523
- const ref = zodSchema?._def?.openapi?.param?.ref ?? component?.ref;
1454
+ const ref = ((_i = (_h = (_g = zodSchema == null ? void 0 : zodSchema._def) == null ? void 0 : _g.openapi) == null ? void 0 : _h.param) == null ? void 0 : _i.ref) ?? (component == null ? void 0 : component.ref);
1524
1455
  const paramObject = {
1525
1456
  in: paramType,
1526
1457
  name: paramName,
@@ -1540,16 +1471,16 @@ var createParamOrRef = (zodSchema, components, subpath, type, name) => {
1540
1471
  }
1541
1472
  return paramObject;
1542
1473
  };
1543
- var createParameters = (type, zodObjectType, components, subpath) => {
1474
+ const createParameters = (type, zodObjectType, components, subpath) => {
1544
1475
  if (!zodObjectType) {
1545
1476
  return [];
1546
1477
  }
1547
- const zodObject = getZodObject(zodObjectType, "input").shape;
1478
+ const zodObject = getZodObject(zodObjectType).shape;
1548
1479
  return Object.entries(zodObject).map(
1549
1480
  ([key, zodSchema]) => createParamOrRef(zodSchema, components, [...subpath, key], type, key)
1550
1481
  );
1551
1482
  };
1552
- var createRequestParams = (requestParams, components, subpath) => {
1483
+ const createRequestParams = (requestParams, components, subpath) => {
1553
1484
  if (!requestParams) {
1554
1485
  return [];
1555
1486
  }
@@ -1577,7 +1508,7 @@ var createRequestParams = (requestParams, components, subpath) => {
1577
1508
  );
1578
1509
  return [...pathParams, ...queryParams, ...cookieParams, ...headerParams];
1579
1510
  };
1580
- var createManualParameters = (parameters, components, subpath) => parameters?.map((param, index) => {
1511
+ const createManualParameters = (parameters, components, subpath) => (parameters == null ? void 0 : parameters.map((param, index) => {
1581
1512
  if (isAnyZodType(param)) {
1582
1513
  return createParamOrRef(param, components, [
1583
1514
  ...subpath,
@@ -1585,8 +1516,8 @@ var createManualParameters = (parameters, components, subpath) => parameters?.ma
1585
1516
  ]);
1586
1517
  }
1587
1518
  return param;
1588
- }) ?? [];
1589
- var createParametersObject = (parameters, requestParams, components, subpath) => {
1519
+ })) ?? [];
1520
+ const createParametersObject = (parameters, requestParams, components, subpath) => {
1590
1521
  const manualParameters = createManualParameters(
1591
1522
  parameters,
1592
1523
  components,
@@ -1599,33 +1530,28 @@ var createParametersObject = (parameters, requestParams, components, subpath) =>
1599
1530
  ];
1600
1531
  return combinedParameters.length ? combinedParameters : void 0;
1601
1532
  };
1602
- var getZodObject = (schema, type) => {
1533
+ const getZodObject = (schema, type) => {
1603
1534
  if (isZodType(schema, "ZodObject")) {
1604
1535
  return schema;
1605
1536
  }
1606
1537
  if (isZodType(schema, "ZodLazy")) {
1607
- return getZodObject(schema.schema, type);
1538
+ return getZodObject(schema.schema);
1608
1539
  }
1609
1540
  if (isZodType(schema, "ZodEffects")) {
1610
- return getZodObject(schema.innerType(), type);
1541
+ return getZodObject(schema.innerType());
1611
1542
  }
1612
1543
  if (isZodType(schema, "ZodBranded")) {
1613
- return getZodObject(schema.unwrap(), type);
1544
+ return getZodObject(schema.unwrap());
1614
1545
  }
1615
1546
  if (isZodType(schema, "ZodPipeline")) {
1616
- if (type === "input") {
1617
- return getZodObject(schema._def.in, type);
1547
+ {
1548
+ return getZodObject(schema._def.in);
1618
1549
  }
1619
- return getZodObject(schema._def.out, type);
1620
1550
  }
1621
1551
  throw new Error("failed to find ZodObject in schema");
1622
1552
  };
1623
-
1624
- // src/create/specificationExtension.ts
1625
- var isISpecificationExtension = (key) => key.startsWith("x-");
1626
-
1627
- // src/create/responses.ts
1628
- var createResponseHeaders = (responseHeaders, components) => {
1553
+ const isISpecificationExtension = (key) => key.startsWith("x-");
1554
+ const createResponseHeaders = (responseHeaders, components) => {
1629
1555
  if (!responseHeaders) {
1630
1556
  return void 0;
1631
1557
  }
@@ -1637,7 +1563,8 @@ var createResponseHeaders = (responseHeaders, components) => {
1637
1563
  }
1638
1564
  return responseHeaders;
1639
1565
  };
1640
- var createHeaderOrRef = (schema, components) => {
1566
+ const createHeaderOrRef = (schema, components) => {
1567
+ var _a, _b, _c;
1641
1568
  const component = components.headers.get(schema);
1642
1569
  if (component && component.type === "complete") {
1643
1570
  return {
@@ -1648,7 +1575,7 @@ var createHeaderOrRef = (schema, components) => {
1648
1575
  if ("$ref" in baseHeader) {
1649
1576
  throw new Error("Unexpected Error: received a reference object");
1650
1577
  }
1651
- const ref = schema._def?.openapi?.header?.ref ?? component?.ref;
1578
+ const ref = ((_c = (_b = (_a = schema._def) == null ? void 0 : _a.openapi) == null ? void 0 : _b.header) == null ? void 0 : _c.ref) ?? (component == null ? void 0 : component.ref);
1652
1579
  if (ref) {
1653
1580
  components.headers.set(schema, {
1654
1581
  type: "complete",
@@ -1661,8 +1588,9 @@ var createHeaderOrRef = (schema, components) => {
1661
1588
  }
1662
1589
  return baseHeader;
1663
1590
  };
1664
- var createBaseHeader = (schema, components) => {
1665
- const { ref, ...rest } = schema._def.openapi?.header ?? {};
1591
+ const createBaseHeader = (schema, components) => {
1592
+ var _a, _b;
1593
+ const { ref, ...rest } = ((_a = schema._def.openapi) == null ? void 0 : _a.header) ?? {};
1666
1594
  const state = {
1667
1595
  components,
1668
1596
  type: "output",
@@ -1670,15 +1598,15 @@ var createBaseHeader = (schema, components) => {
1670
1598
  visited: /* @__PURE__ */ new Set()
1671
1599
  };
1672
1600
  const schemaObject = createSchema(schema, state, ["header"]);
1673
- const required = !isOptionalSchema(schema, state)?.optional;
1601
+ const required = !((_b = isOptionalSchema(schema, state)) == null ? void 0 : _b.optional);
1674
1602
  return {
1675
1603
  ...rest,
1676
1604
  ...schema && { schema: schemaObject },
1677
1605
  ...required && { required }
1678
1606
  };
1679
1607
  };
1680
- var createComponentHeaderRef = (ref) => `#/components/headers/${ref}`;
1681
- var createResponse = (responseObject, components, subpath) => {
1608
+ const createComponentHeaderRef = (ref) => `#/components/headers/${ref}`;
1609
+ const createResponse = (responseObject, components, subpath) => {
1682
1610
  if ("$ref" in responseObject) {
1683
1611
  return responseObject;
1684
1612
  }
@@ -1698,7 +1626,7 @@ var createResponse = (responseObject, components, subpath) => {
1698
1626
  ])
1699
1627
  }
1700
1628
  };
1701
- const responseRef = ref ?? component?.ref;
1629
+ const responseRef = ref ?? (component == null ? void 0 : component.ref);
1702
1630
  if (responseRef) {
1703
1631
  components.responses.set(responseObject, {
1704
1632
  responseObject: response,
@@ -1711,7 +1639,7 @@ var createResponse = (responseObject, components, subpath) => {
1711
1639
  }
1712
1640
  return response;
1713
1641
  };
1714
- var createResponses = (responsesObject, components, subpath) => Object.entries(responsesObject).reduce(
1642
+ const createResponses = (responsesObject, components, subpath) => Object.entries(responsesObject).reduce(
1715
1643
  (acc, [statusCode, responseObject]) => {
1716
1644
  if (isISpecificationExtension(statusCode)) {
1717
1645
  acc[statusCode] = responseObject;
@@ -1725,9 +1653,7 @@ var createResponses = (responsesObject, components, subpath) => Object.entries(r
1725
1653
  },
1726
1654
  {}
1727
1655
  );
1728
-
1729
- // src/create/paths.ts
1730
- var createRequestBody = (requestBodyObject, components, subpath) => {
1656
+ const createRequestBody = (requestBodyObject, components, subpath) => {
1731
1657
  if (!requestBodyObject) {
1732
1658
  return void 0;
1733
1659
  }
@@ -1737,7 +1663,7 @@ var createRequestBody = (requestBodyObject, components, subpath) => {
1737
1663
  $ref: createComponentRequestBodyRef(component.ref)
1738
1664
  };
1739
1665
  }
1740
- const ref = requestBodyObject.ref ?? component?.ref;
1666
+ const ref = requestBodyObject.ref ?? (component == null ? void 0 : component.ref);
1741
1667
  const requestBody = {
1742
1668
  ...requestBodyObject,
1743
1669
  content: createContent(requestBodyObject.content, components, "input", [
@@ -1757,7 +1683,7 @@ var createRequestBody = (requestBodyObject, components, subpath) => {
1757
1683
  }
1758
1684
  return requestBody;
1759
1685
  };
1760
- var createOperation = (operationObject, components, subpath) => {
1686
+ const createOperation = (operationObject, components, subpath) => {
1761
1687
  const { parameters, requestParams, requestBody, responses, ...rest } = operationObject;
1762
1688
  const maybeParameters = createParametersObject(
1763
1689
  parameters,
@@ -1788,7 +1714,7 @@ var createOperation = (operationObject, components, subpath) => {
1788
1714
  ...maybeCallbacks && { callbacks: maybeCallbacks }
1789
1715
  };
1790
1716
  };
1791
- var createPathItem = (pathObject, components, path) => Object.entries(pathObject).reduce(
1717
+ const createPathItem = (pathObject, components, path) => Object.entries(pathObject).reduce(
1792
1718
  (acc, [key, value]) => {
1793
1719
  if (!value) {
1794
1720
  return acc;
@@ -1806,7 +1732,7 @@ var createPathItem = (pathObject, components, path) => Object.entries(pathObject
1806
1732
  },
1807
1733
  {}
1808
1734
  );
1809
- var createPaths = (pathsObject, components) => {
1735
+ const createPaths = (pathsObject, components) => {
1810
1736
  if (!pathsObject) {
1811
1737
  return void 0;
1812
1738
  }
@@ -1822,9 +1748,7 @@ var createPaths = (pathsObject, components) => {
1822
1748
  {}
1823
1749
  );
1824
1750
  };
1825
-
1826
- // src/create/callbacks.ts
1827
- var createCallback = (callbackObject, components, subpath) => {
1751
+ const createCallback = (callbackObject, components, subpath) => {
1828
1752
  const { ref, ...callbacks } = callbackObject;
1829
1753
  const callback = Object.entries(
1830
1754
  callbacks
@@ -1851,7 +1775,7 @@ var createCallback = (callbackObject, components, subpath) => {
1851
1775
  }
1852
1776
  return callback;
1853
1777
  };
1854
- var createCallbacks = (callbacksObject, components, subpath) => {
1778
+ const createCallbacks = (callbacksObject, components, subpath) => {
1855
1779
  if (!callbacksObject) {
1856
1780
  return void 0;
1857
1781
  }
@@ -1870,9 +1794,7 @@ var createCallbacks = (callbacksObject, components, subpath) => {
1870
1794
  {}
1871
1795
  );
1872
1796
  };
1873
-
1874
- // src/create/components.ts
1875
- var getDefaultComponents = (componentsObject, openapi = "3.1.0") => {
1797
+ const getDefaultComponents = (componentsObject, openapi = "3.1.0") => {
1876
1798
  const defaultComponents = {
1877
1799
  schemas: /* @__PURE__ */ new Map(),
1878
1800
  parameters: /* @__PURE__ */ new Map(),
@@ -1893,18 +1815,19 @@ var getDefaultComponents = (componentsObject, openapi = "3.1.0") => {
1893
1815
  getCallbacks(componentsObject.callbacks, defaultComponents);
1894
1816
  return defaultComponents;
1895
1817
  };
1896
- var getSchemas = (schemas, components) => {
1818
+ const getSchemas = (schemas, components) => {
1897
1819
  if (!schemas) {
1898
1820
  return;
1899
1821
  }
1900
1822
  Object.entries(schemas).forEach(([key, schema]) => {
1823
+ var _a;
1901
1824
  if (isAnyZodType(schema)) {
1902
1825
  if (components.schemas.has(schema)) {
1903
1826
  throw new Error(
1904
1827
  `Schema ${JSON.stringify(schema._def)} is already registered`
1905
1828
  );
1906
1829
  }
1907
- const ref = schema._def.openapi?.ref ?? key;
1830
+ const ref = ((_a = schema._def.openapi) == null ? void 0 : _a.ref) ?? key;
1908
1831
  components.schemas.set(schema, {
1909
1832
  type: "manual",
1910
1833
  ref
@@ -1912,20 +1835,21 @@ var getSchemas = (schemas, components) => {
1912
1835
  }
1913
1836
  });
1914
1837
  };
1915
- var getParameters = (parameters, components) => {
1838
+ const getParameters = (parameters, components) => {
1916
1839
  if (!parameters) {
1917
1840
  return;
1918
1841
  }
1919
1842
  Object.entries(parameters).forEach(([key, schema]) => {
1843
+ var _a, _b, _c, _d, _e, _f;
1920
1844
  if (isAnyZodType(schema)) {
1921
1845
  if (components.parameters.has(schema)) {
1922
1846
  throw new Error(
1923
1847
  `Parameter ${JSON.stringify(schema._def)} is already registered`
1924
1848
  );
1925
1849
  }
1926
- const ref = schema._def.openapi?.param?.ref ?? key;
1927
- const name = schema._def.openapi?.param?.name;
1928
- const location = schema._def.openapi?.param?.in;
1850
+ const ref = ((_b = (_a = schema._def.openapi) == null ? void 0 : _a.param) == null ? void 0 : _b.ref) ?? key;
1851
+ const name = (_d = (_c = schema._def.openapi) == null ? void 0 : _c.param) == null ? void 0 : _d.name;
1852
+ const location = (_f = (_e = schema._def.openapi) == null ? void 0 : _e.param) == null ? void 0 : _f.in;
1929
1853
  if (!name || !location) {
1930
1854
  throw new Error("`name` or `in` missing in .openapi()");
1931
1855
  }
@@ -1938,18 +1862,19 @@ var getParameters = (parameters, components) => {
1938
1862
  }
1939
1863
  });
1940
1864
  };
1941
- var getHeaders = (responseHeaders, components) => {
1865
+ const getHeaders = (responseHeaders, components) => {
1942
1866
  if (!responseHeaders) {
1943
1867
  return;
1944
1868
  }
1945
1869
  Object.entries(responseHeaders).forEach(([key, schema]) => {
1870
+ var _a, _b;
1946
1871
  if (isAnyZodType(schema)) {
1947
1872
  if (components.parameters.has(schema)) {
1948
1873
  throw new Error(
1949
1874
  `Header ${JSON.stringify(schema._def)} is already registered`
1950
1875
  );
1951
1876
  }
1952
- const ref = schema._def.openapi?.param?.ref ?? key;
1877
+ const ref = ((_b = (_a = schema._def.openapi) == null ? void 0 : _a.param) == null ? void 0 : _b.ref) ?? key;
1953
1878
  components.headers.set(schema, {
1954
1879
  type: "manual",
1955
1880
  ref
@@ -1957,7 +1882,7 @@ var getHeaders = (responseHeaders, components) => {
1957
1882
  }
1958
1883
  });
1959
1884
  };
1960
- var getResponses = (responses, components) => {
1885
+ const getResponses = (responses, components) => {
1961
1886
  if (!responses) {
1962
1887
  return;
1963
1888
  }
@@ -1967,14 +1892,14 @@ var getResponses = (responses, components) => {
1967
1892
  `Header ${JSON.stringify(responseObject)} is already registered`
1968
1893
  );
1969
1894
  }
1970
- const ref = responseObject?.ref ?? key;
1895
+ const ref = (responseObject == null ? void 0 : responseObject.ref) ?? key;
1971
1896
  components.responses.set(responseObject, {
1972
1897
  type: "manual",
1973
1898
  ref
1974
1899
  });
1975
1900
  });
1976
1901
  };
1977
- var getRequestBodies = (requestBodies, components) => {
1902
+ const getRequestBodies = (requestBodies, components) => {
1978
1903
  if (!requestBodies) {
1979
1904
  return;
1980
1905
  }
@@ -1984,14 +1909,14 @@ var getRequestBodies = (requestBodies, components) => {
1984
1909
  `Header ${JSON.stringify(requestBody)} is already registered`
1985
1910
  );
1986
1911
  }
1987
- const ref = requestBody?.ref ?? key;
1912
+ const ref = (requestBody == null ? void 0 : requestBody.ref) ?? key;
1988
1913
  components.requestBodies.set(requestBody, {
1989
1914
  type: "manual",
1990
1915
  ref
1991
1916
  });
1992
1917
  });
1993
1918
  };
1994
- var getCallbacks = (callbacks, components) => {
1919
+ const getCallbacks = (callbacks, components) => {
1995
1920
  if (!callbacks) {
1996
1921
  return;
1997
1922
  }
@@ -2001,18 +1926,18 @@ var getCallbacks = (callbacks, components) => {
2001
1926
  `Callback ${JSON.stringify(callback)} is already registered`
2002
1927
  );
2003
1928
  }
2004
- const ref = callback?.ref ?? key;
1929
+ const ref = (callback == null ? void 0 : callback.ref) ?? key;
2005
1930
  components.callbacks.set(callback, {
2006
1931
  type: "manual",
2007
1932
  ref
2008
1933
  });
2009
1934
  });
2010
1935
  };
2011
- var createComponentSchemaRef = (schemaRef) => `#/components/schemas/${schemaRef}`;
2012
- var createComponentResponseRef = (responseRef) => `#/components/responses/${responseRef}`;
2013
- var createComponentRequestBodyRef = (requestBodyRef) => `#/components/requestBodies/${requestBodyRef}`;
2014
- var createComponentCallbackRef = (callbackRef) => `#/components/callbacks/${callbackRef}`;
2015
- var createComponents = (componentsObject, components) => {
1936
+ const createComponentSchemaRef = (schemaRef) => `#/components/schemas/${schemaRef}`;
1937
+ const createComponentResponseRef = (responseRef) => `#/components/responses/${responseRef}`;
1938
+ const createComponentRequestBodyRef = (requestBodyRef) => `#/components/requestBodies/${requestBodyRef}`;
1939
+ const createComponentCallbackRef = (callbackRef) => `#/components/callbacks/${callbackRef}`;
1940
+ const createComponents = (componentsObject, components) => {
2016
1941
  const combinedSchemas = createSchemaComponents(componentsObject, components);
2017
1942
  const combinedParameters = createParamComponents(
2018
1943
  componentsObject,
@@ -2034,12 +1959,13 @@ var createComponents = (componentsObject, components) => {
2034
1959
  };
2035
1960
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2036
1961
  };
2037
- var createSchemaComponents = (componentsObject, components) => {
1962
+ const createSchemaComponents = (componentsObject, components) => {
2038
1963
  Array.from(components.schemas).forEach(([schema, { type }], index) => {
1964
+ var _a;
2039
1965
  if (type === "manual") {
2040
1966
  const state = {
2041
1967
  components,
2042
- type: schema._def.openapi?.refType ?? "output",
1968
+ type: ((_a = schema._def.openapi) == null ? void 0 : _a.refType) ?? "output",
2043
1969
  path: [],
2044
1970
  visited: /* @__PURE__ */ new Set()
2045
1971
  };
@@ -2072,7 +1998,7 @@ var createSchemaComponents = (componentsObject, components) => {
2072
1998
  }, customComponents);
2073
1999
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2074
2000
  };
2075
- var createParamComponents = (componentsObject, components) => {
2001
+ const createParamComponents = (componentsObject, components) => {
2076
2002
  Array.from(components.parameters).forEach(([schema, component], index) => {
2077
2003
  if (component.type === "manual") {
2078
2004
  createParamOrRef(
@@ -2109,7 +2035,7 @@ var createParamComponents = (componentsObject, components) => {
2109
2035
  }, customComponents);
2110
2036
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2111
2037
  };
2112
- var createHeaderComponents = (componentsObject, components) => {
2038
+ const createHeaderComponents = (componentsObject, components) => {
2113
2039
  Array.from(components.headers).forEach(([schema, component]) => {
2114
2040
  if (component.type === "manual") {
2115
2041
  createHeaderOrRef(schema, components);
@@ -2136,7 +2062,7 @@ var createHeaderComponents = (componentsObject, components) => {
2136
2062
  }, customComponents);
2137
2063
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2138
2064
  };
2139
- var createResponseComponents = (components) => {
2065
+ const createResponseComponents = (components) => {
2140
2066
  Array.from(components.responses).forEach(([schema, component], index) => {
2141
2067
  if (component.type === "manual") {
2142
2068
  createResponse(schema, components, [`component response index ${index}`]);
@@ -2153,7 +2079,7 @@ var createResponseComponents = (components) => {
2153
2079
  }, {});
2154
2080
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2155
2081
  };
2156
- var createRequestBodiesComponents = (components) => {
2082
+ const createRequestBodiesComponents = (components) => {
2157
2083
  Array.from(components.requestBodies).forEach(([schema, component], index) => {
2158
2084
  if (component.type === "manual") {
2159
2085
  createRequestBody(schema, components, [
@@ -2172,7 +2098,7 @@ var createRequestBodiesComponents = (components) => {
2172
2098
  }, {});
2173
2099
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2174
2100
  };
2175
- var createCallbackComponents = (components) => {
2101
+ const createCallbackComponents = (components) => {
2176
2102
  Array.from(components.callbacks).forEach(([schema, component], index) => {
2177
2103
  if (component.type === "manual") {
2178
2104
  createCallback(schema, components, [`component callback ${index}`]);
@@ -2189,9 +2115,7 @@ var createCallbackComponents = (components) => {
2189
2115
  }, {});
2190
2116
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2191
2117
  };
2192
-
2193
- // src/create/document.ts
2194
- var createDocument = (zodOpenApiObject) => {
2118
+ const createDocument = (zodOpenApiObject) => {
2195
2119
  const { paths, webhooks, components = {}, ...rest } = zodOpenApiObject;
2196
2120
  const defaultComponents = getDefaultComponents(
2197
2121
  components,
@@ -2207,63 +2131,21 @@ var createDocument = (zodOpenApiObject) => {
2207
2131
  ...createdComponents && { components: createdComponents }
2208
2132
  };
2209
2133
  };
2210
-
2211
- // src/extendZod.ts
2212
- function extendZodWithOpenApi(zod) {
2213
- if (typeof zod.ZodType.prototype.openapi !== "undefined") {
2214
- return;
2215
- }
2216
- zod.ZodType.prototype.openapi = function(openapi) {
2217
- const result = new this.constructor({
2218
- ...this._def,
2219
- openapi
2220
- });
2221
- return result;
2222
- };
2223
- const zodObjectExtend = zod.ZodObject.prototype.extend;
2224
- zod.ZodObject.prototype.extend = function(...args) {
2225
- const extendResult = zodObjectExtend.apply(this, args);
2226
- extendResult._def.extendMetadata = {
2227
- extends: this
2228
- };
2229
- delete extendResult._def.openapi;
2230
- return extendResult;
2231
- };
2232
- const zodObjectOmit = zod.ZodObject.prototype.omit;
2233
- zod.ZodObject.prototype.omit = function(...args) {
2234
- const omitResult = zodObjectOmit.apply(this, args);
2235
- delete omitResult._def.extendMetadata;
2236
- delete omitResult._def.openapi;
2237
- return omitResult;
2238
- };
2239
- const zodObjectPick = zod.ZodObject.prototype.pick;
2240
- zod.ZodObject.prototype.pick = function(...args) {
2241
- const pickResult = zodObjectPick.apply(this, args);
2242
- delete pickResult._def.extendMetadata;
2243
- delete pickResult._def.openapi;
2244
- return pickResult;
2245
- };
2246
- }
2247
-
2248
- // src/openapi3-ts/dist/oas30.ts
2249
- var oas30_exports = {};
2250
-
2251
- // src/openapi3-ts/dist/oas31.ts
2252
- var oas31_exports = {};
2253
-
2254
- // src/api.ts
2255
- var api_exports = {};
2256
- __export(api_exports, {
2257
- createComponents: () => createComponents,
2258
- createMediaTypeSchema: () => createMediaTypeSchema,
2259
- createParamOrRef: () => createParamOrRef,
2260
- getDefaultComponents: () => getDefaultComponents
2261
- });
2262
- // Annotate the CommonJS export names for ESM import in node:
2263
- 0 && (module.exports = {
2264
- api,
2265
- createDocument,
2266
- extendZodWithOpenApi,
2267
- oas30,
2268
- oas31
2269
- });
2134
+ const oas30 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2135
+ __proto__: null
2136
+ }, Symbol.toStringTag, { value: "Module" }));
2137
+ const oas31 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2138
+ __proto__: null
2139
+ }, Symbol.toStringTag, { value: "Module" }));
2140
+ const api = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2141
+ __proto__: null,
2142
+ createComponents,
2143
+ createMediaTypeSchema,
2144
+ createParamOrRef,
2145
+ getDefaultComponents
2146
+ }, Symbol.toStringTag, { value: "Module" }));
2147
+ exports.extendZodWithOpenApi = extendZod.extendZodWithOpenApi;
2148
+ exports.api = api;
2149
+ exports.createDocument = createDocument;
2150
+ exports.oas30 = oas30;
2151
+ exports.oas31 = oas31;