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,17 +1,15 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ import { extendZodWithOpenApi } from "./extendZod.chunk.mjs";
2
+ const isZodType = (zodType, typeName) => {
3
+ var _a;
4
+ return ((_a = zodType == null ? void 0 : zodType._def) == null ? void 0 : _a.typeName) === typeName;
5
+ };
6
+ const isAnyZodType = (zodType) => {
7
+ var _a;
8
+ return Boolean(
9
+ (_a = zodType == null ? void 0 : zodType._def) == null ? void 0 : _a.typeName
10
+ );
5
11
  };
6
-
7
- // src/zodType.ts
8
- var isZodType = (zodType, typeName) => zodType?._def?.typeName === typeName;
9
- var isAnyZodType = (zodType) => Boolean(
10
- zodType?._def?.typeName
11
- );
12
-
13
- // src/create/schema/metadata.ts
14
- var enhanceWithMetadata = (schema, metadata) => {
12
+ const enhanceWithMetadata = (schema, metadata) => {
15
13
  if (schema.type === "ref") {
16
14
  if (Object.values(metadata).every((val) => val === void 0)) {
17
15
  return schema;
@@ -33,12 +31,11 @@ var enhanceWithMetadata = (schema, metadata) => {
33
31
  effects: schema.effects
34
32
  };
35
33
  };
36
-
37
- // src/create/schema/parsers/array.ts
38
- var createArraySchema = (zodArray, state) => {
34
+ const createArraySchema = (zodArray, state) => {
35
+ var _a, _b, _c, _d;
39
36
  const zodType = zodArray._def.type;
40
- const minItems = zodArray._def.exactLength?.value ?? zodArray._def.minLength?.value;
41
- const maxItems = zodArray._def.exactLength?.value ?? zodArray._def.maxLength?.value;
37
+ const minItems = ((_a = zodArray._def.exactLength) == null ? void 0 : _a.value) ?? ((_b = zodArray._def.minLength) == null ? void 0 : _b.value);
38
+ const maxItems = ((_c = zodArray._def.exactLength) == null ? void 0 : _c.value) ?? ((_d = zodArray._def.maxLength) == null ? void 0 : _d.value);
42
39
  const items = createSchemaObject(zodType, state, ["array items"]);
43
40
  return {
44
41
  type: "schema",
@@ -51,31 +48,21 @@ var createArraySchema = (zodArray, state) => {
51
48
  effects: items.effects
52
49
  };
53
50
  };
54
-
55
- // src/create/schema/parsers/boolean.ts
56
- var createBooleanSchema = (_zodBoolean) => ({
51
+ const createBooleanSchema = (_zodBoolean) => ({
57
52
  type: "schema",
58
53
  schema: {
59
54
  type: "boolean"
60
55
  }
61
56
  });
62
-
63
- // src/create/schema/parsers/brand.ts
64
- var createBrandedSchema = (zodBranded, state) => createSchemaObject(zodBranded._def.type, state, ["brand"]);
65
-
66
- // src/create/schema/parsers/catch.ts
67
- var createCatchSchema = (zodCatch, state) => createSchemaObject(zodCatch._def.innerType, state, ["catch"]);
68
-
69
- // src/create/schema/parsers/date.ts
70
- var createDateSchema = (_zodDate) => ({
57
+ const createBrandedSchema = (zodBranded, state) => createSchemaObject(zodBranded._def.type, state, ["brand"]);
58
+ const createCatchSchema = (zodCatch, state) => createSchemaObject(zodCatch._def.innerType, state, ["catch"]);
59
+ const createDateSchema = (_zodDate) => ({
71
60
  type: "schema",
72
61
  schema: {
73
62
  type: "string"
74
63
  }
75
64
  });
76
-
77
- // src/create/schema/parsers/default.ts
78
- var createDefaultSchema = (zodDefault, state) => {
65
+ const createDefaultSchema = (zodDefault, state) => {
79
66
  const schemaObject = createSchemaObject(zodDefault._def.innerType, state, [
80
67
  "default"
81
68
  ]);
@@ -83,19 +70,15 @@ var createDefaultSchema = (zodDefault, state) => {
83
70
  default: zodDefault._def.defaultValue()
84
71
  });
85
72
  };
86
-
87
- // src/openapi.ts
88
- var openApiVersions = [
73
+ const openApiVersions = [
89
74
  "3.0.0",
90
75
  "3.0.1",
91
76
  "3.0.2",
92
77
  "3.0.3",
93
78
  "3.1.0"
94
79
  ];
95
- var satisfiesVersion = (test, against) => openApiVersions.indexOf(test) >= openApiVersions.indexOf(against);
96
-
97
- // src/create/schema/parsers/nativeEnum.ts
98
- var createNativeEnumSchema = (zodEnum, state) => {
80
+ const satisfiesVersion = (test, against) => openApiVersions.indexOf(test) >= openApiVersions.indexOf(against);
81
+ const createNativeEnumSchema = (zodEnum, state) => {
99
82
  const enumValues = getValidEnumValues(zodEnum._def.values);
100
83
  const { numbers, strings } = sortStringsAndNumbers(enumValues);
101
84
  if (strings.length && numbers.length) {
@@ -134,26 +117,25 @@ var createNativeEnumSchema = (zodEnum, state) => {
134
117
  }
135
118
  };
136
119
  };
137
- var getValidEnumValues = (enumValues) => {
120
+ const getValidEnumValues = (enumValues) => {
138
121
  const keys = Object.keys(enumValues).filter(
139
122
  (key) => typeof enumValues[enumValues[key]] !== "number"
140
123
  );
141
124
  return keys.map((key) => enumValues[key]);
142
125
  };
143
- var sortStringsAndNumbers = (values) => ({
126
+ const sortStringsAndNumbers = (values) => ({
144
127
  strings: values.filter((value) => typeof value === "string"),
145
128
  numbers: values.filter((value) => typeof value === "number")
146
129
  });
147
-
148
- // src/create/schema/parsers/transform.ts
149
- var createTransformSchema = (zodTransform, state) => {
150
- if (zodTransform._def.openapi?.effectType === "output") {
130
+ const createTransformSchema = (zodTransform, state) => {
131
+ var _a, _b, _c;
132
+ if (((_a = zodTransform._def.openapi) == null ? void 0 : _a.effectType) === "output") {
151
133
  return {
152
134
  type: "schema",
153
135
  schema: createManualOutputTransformSchema(zodTransform, state)
154
136
  };
155
137
  }
156
- if (zodTransform._def.openapi?.effectType === "input" || zodTransform._def.openapi?.effectType === "same") {
138
+ if (((_b = zodTransform._def.openapi) == null ? void 0 : _b.effectType) === "input" || ((_c = zodTransform._def.openapi) == null ? void 0 : _c.effectType) === "same") {
157
139
  return createSchemaObject(zodTransform._def.schema, state, [
158
140
  "transform input"
159
141
  ]);
@@ -182,8 +164,9 @@ var createTransformSchema = (zodTransform, state) => {
182
164
  ])
183
165
  };
184
166
  };
185
- var createManualOutputTransformSchema = (zodTransform, state) => {
186
- if (!zodTransform._def.openapi?.type) {
167
+ const createManualOutputTransformSchema = (zodTransform, state) => {
168
+ var _a;
169
+ if (!((_a = zodTransform._def.openapi) == null ? void 0 : _a.type)) {
187
170
  const zodType = zodTransform.constructor.name;
188
171
  const schemaName = `${zodType} - ${zodTransform._def.effect.type}`;
189
172
  throw new Error(
@@ -196,13 +179,13 @@ var createManualOutputTransformSchema = (zodTransform, state) => {
196
179
  type: zodTransform._def.openapi.type
197
180
  };
198
181
  };
199
- var getZodTypeName = (zodType) => {
182
+ const getZodTypeName = (zodType) => {
200
183
  if (isZodType(zodType, "ZodEffects")) {
201
184
  return `${zodType._def.typeName} - ${zodType._def.effect.type}`;
202
185
  }
203
186
  return zodType._def.typeName;
204
187
  };
205
- var throwTransformError = (effect) => {
188
+ const throwTransformError = (effect) => {
206
189
  const typeName = getZodTypeName(effect.zodType);
207
190
  const input = effect.creationType;
208
191
  const opposite = input === "input" ? "output" : "input";
@@ -222,7 +205,7 @@ This may cause the schema to render incorrectly and is most likely a mistake. Yo
222
205
  5. Deregister the component containing the transformation`
223
206
  );
224
207
  };
225
- var resolveSingleEffect = (effect, state) => {
208
+ const resolveSingleEffect = (effect, state) => {
226
209
  if (effect.type === "schema") {
227
210
  return {
228
211
  creationType: effect.creationType,
@@ -235,7 +218,7 @@ var resolveSingleEffect = (effect, state) => {
235
218
  return;
236
219
  }
237
220
  const component = state.components.schemas.get(effect.zodType);
238
- if (component?.type !== "complete") {
221
+ if ((component == null ? void 0 : component.type) !== "complete") {
239
222
  throw new Error("Something went wrong, component schema is not complete");
240
223
  }
241
224
  if (component.resolvedEffect) {
@@ -264,14 +247,14 @@ var resolveSingleEffect = (effect, state) => {
264
247
  }
265
248
  return void 0;
266
249
  };
267
- var resolveEffect = (effects, state) => {
250
+ const resolveEffect = (effects, state) => {
268
251
  const { input, output } = effects.reduce(
269
252
  (acc, effect) => {
270
253
  const resolvedSchemaEffect = resolveSingleEffect(effect, state);
271
- if (resolvedSchemaEffect?.creationType === "input") {
254
+ if ((resolvedSchemaEffect == null ? void 0 : resolvedSchemaEffect.creationType) === "input") {
272
255
  acc.input.push(resolvedSchemaEffect);
273
256
  }
274
- if (resolvedSchemaEffect?.creationType === "output") {
257
+ if ((resolvedSchemaEffect == null ? void 0 : resolvedSchemaEffect.creationType) === "output") {
275
258
  acc.output.push(resolvedSchemaEffect);
276
259
  }
277
260
  if (resolvedSchemaEffect && acc.input.length > 1 && acc.output.length > 1) {
@@ -289,13 +272,13 @@ var resolveEffect = (effects, state) => {
289
272
  }
290
273
  return void 0;
291
274
  };
292
- var verifyEffects = (effects, state) => {
275
+ const verifyEffects = (effects, state) => {
293
276
  const resolved = resolveEffect(effects, state);
294
- if (resolved?.creationType && resolved.creationType !== state.type) {
277
+ if ((resolved == null ? void 0 : resolved.creationType) && resolved.creationType !== state.type) {
295
278
  throwTransformError(resolved);
296
279
  }
297
280
  };
298
- var flattenEffects = (effects) => {
281
+ const flattenEffects = (effects) => {
299
282
  const allEffects = effects.reduce((acc, effect) => {
300
283
  if (effect) {
301
284
  return acc.concat(effect);
@@ -304,9 +287,7 @@ var flattenEffects = (effects) => {
304
287
  }, []);
305
288
  return allEffects.length ? allEffects : void 0;
306
289
  };
307
-
308
- // src/create/schema/parsers/discriminatedUnion.ts
309
- var createDiscriminatedUnionSchema = (zodDiscriminatedUnion, state) => {
290
+ const createDiscriminatedUnionSchema = (zodDiscriminatedUnion, state) => {
310
291
  const options = zodDiscriminatedUnion.options;
311
292
  const schemas = options.map(
312
293
  (option, index) => createSchemaObject(option, state, [`discriminated union option ${index}`])
@@ -327,7 +308,7 @@ var createDiscriminatedUnionSchema = (zodDiscriminatedUnion, state) => {
327
308
  effects: flattenEffects(schemas.map((schema) => schema.effects))
328
309
  };
329
310
  };
330
- var unwrapLiterals = (zodType, state) => {
311
+ const unwrapLiterals = (zodType, state) => {
331
312
  if (isZodType(zodType, "ZodLiteral")) {
332
313
  if (typeof zodType._def.value !== "string") {
333
314
  return void 0;
@@ -354,14 +335,14 @@ var unwrapLiterals = (zodType, state) => {
354
335
  }
355
336
  return void 0;
356
337
  };
357
- var mapDiscriminator = (schemas, zodObjects, discriminator, state) => {
338
+ const mapDiscriminator = (schemas, zodObjects, discriminator, state) => {
358
339
  if (typeof discriminator !== "string") {
359
340
  return void 0;
360
341
  }
361
342
  const mapping = {};
362
343
  for (const [index, zodObject] of zodObjects.entries()) {
363
344
  const schema = schemas[index];
364
- const componentSchemaRef = "$ref" in schema ? schema?.$ref : void 0;
345
+ const componentSchemaRef = "$ref" in schema ? schema == null ? void 0 : schema.$ref : void 0;
365
346
  if (!componentSchemaRef) {
366
347
  return void 0;
367
348
  }
@@ -379,18 +360,14 @@ var mapDiscriminator = (schemas, zodObjects, discriminator, state) => {
379
360
  mapping
380
361
  };
381
362
  };
382
-
383
- // src/create/schema/parsers/enum.ts
384
- var createEnumSchema = (zodEnum) => ({
363
+ const createEnumSchema = (zodEnum) => ({
385
364
  type: "schema",
386
365
  schema: {
387
366
  type: "string",
388
367
  enum: zodEnum._def.values
389
368
  }
390
369
  });
391
-
392
- // src/create/schema/parsers/intersection.ts
393
- var createIntersectionSchema = (zodIntersection, state) => {
370
+ const createIntersectionSchema = (zodIntersection, state) => {
394
371
  const left = createSchemaObject(zodIntersection._def.left, state, [
395
372
  "intersection left"
396
373
  ]);
@@ -405,23 +382,17 @@ var createIntersectionSchema = (zodIntersection, state) => {
405
382
  effects: flattenEffects([left.effects, right.effects])
406
383
  };
407
384
  };
408
-
409
- // src/create/schema/parsers/lazy.ts
410
- var createLazySchema = (zodLazy, state) => {
385
+ const createLazySchema = (zodLazy, state) => {
411
386
  const innerSchema = zodLazy._def.getter();
412
387
  return createSchemaObject(innerSchema, state, ["lazy schema"]);
413
388
  };
414
-
415
- // src/create/schema/parsers/null.ts
416
- var createNullSchema = () => ({
389
+ const createNullSchema = () => ({
417
390
  type: "schema",
418
391
  schema: {
419
392
  type: "null"
420
393
  }
421
394
  });
422
-
423
- // src/create/schema/parsers/literal.ts
424
- var createLiteralSchema = (zodLiteral, state) => {
395
+ const createLiteralSchema = (zodLiteral, state) => {
425
396
  if (zodLiteral.value === null) {
426
397
  return createNullSchema();
427
398
  }
@@ -442,10 +413,9 @@ var createLiteralSchema = (zodLiteral, state) => {
442
413
  }
443
414
  };
444
415
  };
445
-
446
- // src/create/schema/parsers/manual.ts
447
- var createManualTypeSchema = (zodSchema, state) => {
448
- if (!zodSchema._def.openapi?.type) {
416
+ const createManualTypeSchema = (zodSchema, state) => {
417
+ var _a;
418
+ if (!((_a = zodSchema._def.openapi) == null ? void 0 : _a.type)) {
449
419
  const schemaName = zodSchema.constructor.name;
450
420
  throw new Error(
451
421
  `Unknown schema ${schemaName} at ${state.path.join(
@@ -460,9 +430,7 @@ var createManualTypeSchema = (zodSchema, state) => {
460
430
  }
461
431
  };
462
432
  };
463
-
464
- // src/create/schema/parsers/nullable.ts
465
- var createNullableSchema = (zodNullable, state) => {
433
+ const createNullableSchema = (zodNullable, state) => {
466
434
  const schemaObject = createSchemaObject(zodNullable.unwrap(), state, [
467
435
  "nullable"
468
436
  ]);
@@ -532,7 +500,7 @@ var createNullableSchema = (zodNullable, state) => {
532
500
  effects: schemaObject.effects
533
501
  };
534
502
  };
535
- var mapNullType = (type) => {
503
+ const mapNullType = (type) => {
536
504
  if (!type) {
537
505
  return "null";
538
506
  }
@@ -541,15 +509,13 @@ var mapNullType = (type) => {
541
509
  }
542
510
  return [type, "null"];
543
511
  };
544
- var mapNullOf = (ofSchema, openapi) => {
512
+ const mapNullOf = (ofSchema, openapi) => {
545
513
  if (satisfiesVersion(openapi, "3.1.0")) {
546
514
  return [...ofSchema, { type: "null" }];
547
515
  }
548
516
  return [...ofSchema, { nullable: true }];
549
517
  };
550
-
551
- // src/create/schema/parsers/number.ts
552
- var createNumberSchema = (zodNumber, state) => {
518
+ const createNumberSchema = (zodNumber, state) => {
553
519
  const zodNumberChecks = getZodNumberChecks(zodNumber);
554
520
  const minimum = mapMinimum(zodNumberChecks, state.components.openapi);
555
521
  const maximum = mapMaximum(zodNumberChecks, state.components.openapi);
@@ -563,7 +529,7 @@ var createNumberSchema = (zodNumber, state) => {
563
529
  }
564
530
  };
565
531
  };
566
- var mapMaximum = (zodNumberCheck, openapi) => {
532
+ const mapMaximum = (zodNumberCheck, openapi) => {
567
533
  if (!zodNumberCheck.max) {
568
534
  return void 0;
569
535
  }
@@ -576,7 +542,7 @@ var mapMaximum = (zodNumberCheck, openapi) => {
576
542
  }
577
543
  return { maximum, exclusiveMaximum: true };
578
544
  };
579
- var mapMinimum = (zodNumberCheck, openapi) => {
545
+ const mapMinimum = (zodNumberCheck, openapi) => {
580
546
  if (!zodNumberCheck.min) {
581
547
  return void 0;
582
548
  }
@@ -589,23 +555,22 @@ var mapMinimum = (zodNumberCheck, openapi) => {
589
555
  }
590
556
  return { minimum, exclusiveMinimum: true };
591
557
  };
592
- var getZodNumberChecks = (zodNumber) => zodNumber._def.checks.reduce((acc, check) => {
558
+ const getZodNumberChecks = (zodNumber) => zodNumber._def.checks.reduce((acc, check) => {
593
559
  acc[check.kind] = check;
594
560
  return acc;
595
561
  }, {});
596
- var mapNumberType = (zodNumberChecks) => zodNumberChecks.int ? "integer" : "number";
597
-
598
- // src/create/schema/parsers/optional.ts
599
- var createOptionalSchema = (zodOptional, state) => createSchemaObject(zodOptional.unwrap(), state, ["optional"]);
600
- var isOptionalSchema = (zodSchema, state) => {
562
+ const mapNumberType = (zodNumberChecks) => zodNumberChecks.int ? "integer" : "number";
563
+ const createOptionalSchema = (zodOptional, state) => createSchemaObject(zodOptional.unwrap(), state, ["optional"]);
564
+ const isOptionalSchema = (zodSchema, state) => {
565
+ var _a, _b, _c;
601
566
  if (isZodType(zodSchema, "ZodOptional") || isZodType(zodSchema, "ZodNever") || isZodType(zodSchema, "ZodUndefined") || isZodType(zodSchema, "ZodLiteral") && zodSchema._def.value === void 0) {
602
567
  return { optional: true };
603
568
  }
604
569
  if (isZodType(zodSchema, "ZodDefault")) {
605
- if (zodSchema._def.openapi?.effectType === "input") {
570
+ if (((_a = zodSchema._def.openapi) == null ? void 0 : _a.effectType) === "input") {
606
571
  return { optional: true };
607
572
  }
608
- if (zodSchema._def.openapi?.effectType === "output") {
573
+ if (((_b = zodSchema._def.openapi) == null ? void 0 : _b.effectType) === "output") {
609
574
  return { optional: false };
610
575
  }
611
576
  return {
@@ -651,7 +616,7 @@ var isOptionalSchema = (zodSchema, state) => {
651
616
  );
652
617
  }
653
618
  if (isZodType(zodSchema, "ZodPipeline")) {
654
- const type = zodSchema._def.openapi?.effectType ?? state.type;
619
+ const type = ((_c = zodSchema._def.openapi) == null ? void 0 : _c.effectType) ?? state.type;
655
620
  if (type === "input") {
656
621
  return isOptionalSchema(zodSchema._def.in, state);
657
622
  }
@@ -664,12 +629,11 @@ var isOptionalSchema = (zodSchema, state) => {
664
629
  }
665
630
  return { optional: zodSchema.isOptional() };
666
631
  };
667
-
668
- // src/create/schema/parsers/object.ts
669
- var createObjectSchema = (zodObject, state) => {
632
+ const createObjectSchema = (zodObject, state) => {
633
+ var _a;
670
634
  const extendedSchema = createExtendedSchema(
671
635
  zodObject,
672
- zodObject._def.extendMetadata?.extends,
636
+ (_a = zodObject._def.extendMetadata) == null ? void 0 : _a.extends,
673
637
  state
674
638
  );
675
639
  if (extendedSchema) {
@@ -684,12 +648,13 @@ var createObjectSchema = (zodObject, state) => {
684
648
  state
685
649
  );
686
650
  };
687
- var createExtendedSchema = (zodObject, baseZodObject, state) => {
651
+ const createExtendedSchema = (zodObject, baseZodObject, state) => {
652
+ var _a;
688
653
  if (!baseZodObject) {
689
654
  return void 0;
690
655
  }
691
656
  const component = state.components.schemas.get(baseZodObject);
692
- if (component ?? baseZodObject._def.openapi?.ref) {
657
+ if (component ?? ((_a = baseZodObject._def.openapi) == null ? void 0 : _a.ref)) {
693
658
  createSchemaObject(baseZodObject, state, ["extended schema"]);
694
659
  }
695
660
  const completeComponent = state.components.schemas.get(baseZodObject);
@@ -740,7 +705,7 @@ var createExtendedSchema = (zodObject, baseZodObject, state) => {
740
705
  ])
741
706
  };
742
707
  };
743
- var createDiffOpts = (baseOpts, extendedOpts) => {
708
+ const createDiffOpts = (baseOpts, extendedOpts) => {
744
709
  if (baseOpts.unknownKeys === "strict" || !isZodType(baseOpts.catchAll, "ZodNever")) {
745
710
  return void 0;
746
711
  }
@@ -749,7 +714,7 @@ var createDiffOpts = (baseOpts, extendedOpts) => {
749
714
  unknownKeys: extendedOpts.unknownKeys
750
715
  };
751
716
  };
752
- var createShapeDiff = (baseObj, extendedObj) => {
717
+ const createShapeDiff = (baseObj, extendedObj) => {
753
718
  const acc = {};
754
719
  for (const [key, val] of Object.entries(extendedObj)) {
755
720
  const baseValue = baseObj[key];
@@ -764,7 +729,7 @@ var createShapeDiff = (baseObj, extendedObj) => {
764
729
  }
765
730
  return acc;
766
731
  };
767
- var createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state) => {
732
+ const createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state) => {
768
733
  const properties = mapProperties(shape, state);
769
734
  const required = mapRequired(shape, state);
770
735
  const additionalProperties = !isZodType(catchAll, "ZodNever") ? createSchemaObject(catchAll, state, ["additional properties"]) : void 0;
@@ -773,20 +738,20 @@ var createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state) => {
773
738
  schema: {
774
739
  type: "object",
775
740
  ...properties && { properties: properties.properties },
776
- ...required?.required.length && { required: required.required },
741
+ ...(required == null ? void 0 : required.required.length) && { required: required.required },
777
742
  ...unknownKeys === "strict" && { additionalProperties: false },
778
743
  ...additionalProperties && {
779
744
  additionalProperties: additionalProperties.schema
780
745
  }
781
746
  },
782
747
  effects: flattenEffects([
783
- ...properties?.effects ?? [],
784
- additionalProperties?.effects,
785
- required?.effects
748
+ ...(properties == null ? void 0 : properties.effects) ?? [],
749
+ additionalProperties == null ? void 0 : additionalProperties.effects,
750
+ required == null ? void 0 : required.effects
786
751
  ])
787
752
  };
788
753
  };
789
- var mapRequired = (shape, state) => {
754
+ const mapRequired = (shape, state) => {
790
755
  const { required, effects: allEffects } = Object.entries(shape).reduce(
791
756
  (acc, [key, zodSchema]) => {
792
757
  state.path.push(`property: ${key}`);
@@ -807,7 +772,7 @@ var mapRequired = (shape, state) => {
807
772
  );
808
773
  return { required, effects: flattenEffects(allEffects) };
809
774
  };
810
- var mapProperties = (shape, state) => {
775
+ const mapProperties = (shape, state) => {
811
776
  const shapeEntries = Object.entries(shape);
812
777
  if (!shapeEntries.length) {
813
778
  return void 0;
@@ -830,13 +795,12 @@ var mapProperties = (shape, state) => {
830
795
  }
831
796
  );
832
797
  };
833
-
834
- // src/create/schema/parsers/pipeline.ts
835
- var createPipelineSchema = (zodPipeline, state) => {
836
- if (zodPipeline._def.openapi?.effectType === "input" || zodPipeline._def.openapi?.effectType === "same") {
798
+ const createPipelineSchema = (zodPipeline, state) => {
799
+ var _a, _b, _c;
800
+ if (((_a = zodPipeline._def.openapi) == null ? void 0 : _a.effectType) === "input" || ((_b = zodPipeline._def.openapi) == null ? void 0 : _b.effectType) === "same") {
837
801
  return createSchemaObject(zodPipeline._def.in, state, ["pipeline input"]);
838
802
  }
839
- if (zodPipeline._def.openapi?.effectType === "output") {
803
+ if (((_c = zodPipeline._def.openapi) == null ? void 0 : _c.effectType) === "output") {
840
804
  return createSchemaObject(zodPipeline._def.out, state, ["pipeline output"]);
841
805
  }
842
806
  if (state.type === "input") {
@@ -876,18 +840,12 @@ var createPipelineSchema = (zodPipeline, state) => {
876
840
  ])
877
841
  };
878
842
  };
879
-
880
- // src/create/schema/parsers/preprocess.ts
881
- var createPreprocessSchema = (zodPreprocess, state) => createSchemaObject(zodPreprocess._def.schema, state, ["preprocess schema"]);
882
-
883
- // src/create/schema/parsers/readonly.ts
884
- var createReadonlySchema = (zodReadonly, state) => (
843
+ const createPreprocessSchema = (zodPreprocess, state) => createSchemaObject(zodPreprocess._def.schema, state, ["preprocess schema"]);
844
+ const createReadonlySchema = (zodReadonly, state) => (
885
845
  // Readonly doesn't change OpenAPI schema
886
846
  createSchemaObject(zodReadonly._def.innerType, state, ["readonly"])
887
847
  );
888
-
889
- // src/create/schema/parsers/record.ts
890
- var createRecordSchema = (zodRecord, state) => {
848
+ const createRecordSchema = (zodRecord, state) => {
891
849
  const additionalProperties = createSchemaObject(
892
850
  zodRecord.valueSchema,
893
851
  state,
@@ -942,15 +900,12 @@ var createRecordSchema = (zodRecord, state) => {
942
900
  effects: additionalProperties.effects
943
901
  };
944
902
  };
945
-
946
- // src/create/schema/parsers/refine.ts
947
- var createRefineSchema = (zodRefine, state) => createSchemaObject(zodRefine._def.schema, state, ["refine schema"]);
948
-
949
- // src/create/schema/parsers/set.ts
950
- var createSetSchema = (zodSet, state) => {
903
+ const createRefineSchema = (zodRefine, state) => createSchemaObject(zodRefine._def.schema, state, ["refine schema"]);
904
+ const createSetSchema = (zodSet, state) => {
905
+ var _a, _b;
951
906
  const schema = zodSet._def.valueType;
952
- const minItems = zodSet._def.minSize?.value;
953
- const maxItems = zodSet._def.maxSize?.value;
907
+ const minItems = (_a = zodSet._def.minSize) == null ? void 0 : _a.value;
908
+ const maxItems = (_b = zodSet._def.maxSize) == null ? void 0 : _b.value;
954
909
  const itemSchema = createSchemaObject(schema, state, ["set items"]);
955
910
  return {
956
911
  type: "schema",
@@ -964,14 +919,13 @@ var createSetSchema = (zodSet, state) => {
964
919
  effects: itemSchema.effects
965
920
  };
966
921
  };
967
-
968
- // src/create/schema/parsers/string.ts
969
- var createStringSchema = (zodString, state) => {
922
+ const createStringSchema = (zodString, state) => {
923
+ var _a, _b, _c, _d, _e, _f, _g, _h;
970
924
  const zodStringChecks = getZodStringChecks(zodString);
971
925
  const format = mapStringFormat(zodStringChecks);
972
926
  const patterns = mapPatterns(zodStringChecks);
973
- const minLength = zodStringChecks.length?.[0]?.value ?? zodStringChecks.min?.[0]?.value;
974
- const maxLength = zodStringChecks.length?.[0]?.value ?? zodStringChecks.max?.[0]?.value;
927
+ 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);
928
+ 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);
975
929
  const contentEncoding = satisfiesVersion(state.components.openapi, "3.1.0") ? mapContentEncoding(zodStringChecks) : void 0;
976
930
  if (patterns.length <= 1) {
977
931
  return {
@@ -1008,7 +962,7 @@ var createStringSchema = (zodString, state) => {
1008
962
  }
1009
963
  };
1010
964
  };
1011
- var getZodStringChecks = (zodString) => zodString._def.checks.reduce(
965
+ const getZodStringChecks = (zodString) => zodString._def.checks.reduce(
1012
966
  (acc, check) => {
1013
967
  const mapping = acc[check.kind];
1014
968
  if (mapping) {
@@ -1020,7 +974,7 @@ var getZodStringChecks = (zodString) => zodString._def.checks.reduce(
1020
974
  },
1021
975
  {}
1022
976
  );
1023
- var mapPatterns = (zodStringChecks) => {
977
+ const mapPatterns = (zodStringChecks) => {
1024
978
  const startsWith = mapStartsWith(zodStringChecks);
1025
979
  const endsWith = mapEndsWith(zodStringChecks);
1026
980
  const regex = mapRegex(zodStringChecks);
@@ -1033,29 +987,37 @@ var mapPatterns = (zodStringChecks) => {
1033
987
  ];
1034
988
  return patterns;
1035
989
  };
1036
- var mapStartsWith = (zodStringChecks) => {
1037
- if (zodStringChecks.startsWith?.[0]?.value) {
990
+ const mapStartsWith = (zodStringChecks) => {
991
+ var _a, _b;
992
+ if ((_b = (_a = zodStringChecks.startsWith) == null ? void 0 : _a[0]) == null ? void 0 : _b.value) {
1038
993
  return `^${zodStringChecks.startsWith[0].value}`;
1039
994
  }
1040
995
  return void 0;
1041
996
  };
1042
- var mapEndsWith = (zodStringChecks) => {
1043
- if (zodStringChecks.endsWith?.[0]?.value) {
997
+ const mapEndsWith = (zodStringChecks) => {
998
+ var _a, _b;
999
+ if ((_b = (_a = zodStringChecks.endsWith) == null ? void 0 : _a[0]) == null ? void 0 : _b.value) {
1044
1000
  return `${zodStringChecks.endsWith[0].value}$`;
1045
1001
  }
1046
1002
  return void 0;
1047
1003
  };
1048
- var mapRegex = (zodStringChecks) => zodStringChecks.regex?.map((regexCheck) => regexCheck.regex.source);
1049
- var mapIncludes = (zodStringChecks) => zodStringChecks.includes?.map((includeCheck) => {
1050
- if (includeCheck.position === 0) {
1051
- return `^${includeCheck.value}`;
1052
- }
1053
- if (includeCheck.position) {
1054
- return `^.{${includeCheck.position}}${includeCheck.value}`;
1055
- }
1056
- return includeCheck.value;
1057
- });
1058
- var mapStringFormat = (zodStringChecks) => {
1004
+ const mapRegex = (zodStringChecks) => {
1005
+ var _a;
1006
+ return (_a = zodStringChecks.regex) == null ? void 0 : _a.map((regexCheck) => regexCheck.regex.source);
1007
+ };
1008
+ const mapIncludes = (zodStringChecks) => {
1009
+ var _a;
1010
+ return (_a = zodStringChecks.includes) == null ? void 0 : _a.map((includeCheck) => {
1011
+ if (includeCheck.position === 0) {
1012
+ return `^${includeCheck.value}`;
1013
+ }
1014
+ if (includeCheck.position) {
1015
+ return `^.{${includeCheck.position}}${includeCheck.value}`;
1016
+ }
1017
+ return includeCheck.value;
1018
+ });
1019
+ };
1020
+ const mapStringFormat = (zodStringChecks) => {
1059
1021
  if (zodStringChecks.uuid) {
1060
1022
  return "uuid";
1061
1023
  }
@@ -1079,15 +1041,13 @@ var mapStringFormat = (zodStringChecks) => {
1079
1041
  }
1080
1042
  return void 0;
1081
1043
  };
1082
- var mapContentEncoding = (zodStringChecks) => {
1044
+ const mapContentEncoding = (zodStringChecks) => {
1083
1045
  if (zodStringChecks.base64) {
1084
1046
  return "base64";
1085
1047
  }
1086
1048
  return void 0;
1087
1049
  };
1088
-
1089
- // src/create/schema/parsers/tuple.ts
1090
- var createTupleSchema = (zodTuple, state) => {
1050
+ const createTupleSchema = (zodTuple, state) => {
1091
1051
  const items = zodTuple.items;
1092
1052
  const rest = zodTuple._def.rest;
1093
1053
  const prefixItems = mapPrefixItems(items, state);
@@ -1103,7 +1063,7 @@ var createTupleSchema = (zodTuple, state) => {
1103
1063
  prefixItems: prefixItems.schemas.map((item) => item.schema)
1104
1064
  }
1105
1065
  },
1106
- effects: prefixItems?.effects
1066
+ effects: prefixItems == null ? void 0 : prefixItems.effects
1107
1067
  };
1108
1068
  }
1109
1069
  const itemSchema = createSchemaObject(rest, state, ["tuple items"]);
@@ -1116,7 +1076,7 @@ var createTupleSchema = (zodTuple, state) => {
1116
1076
  prefixItems: prefixItems.schemas.map((item) => item.schema)
1117
1077
  }
1118
1078
  },
1119
- effects: flattenEffects([prefixItems?.effects, itemSchema.effects])
1079
+ effects: flattenEffects([prefixItems == null ? void 0 : prefixItems.effects, itemSchema.effects])
1120
1080
  };
1121
1081
  }
1122
1082
  if (!rest) {
@@ -1130,7 +1090,7 @@ var createTupleSchema = (zodTuple, state) => {
1130
1090
  items: { oneOf: prefixItems.schemas.map((item) => item.schema) }
1131
1091
  }
1132
1092
  },
1133
- effects: prefixItems?.effects
1093
+ effects: prefixItems == null ? void 0 : prefixItems.effects
1134
1094
  };
1135
1095
  }
1136
1096
  if (prefixItems) {
@@ -1156,7 +1116,7 @@ var createTupleSchema = (zodTuple, state) => {
1156
1116
  }
1157
1117
  };
1158
1118
  };
1159
- var mapPrefixItems = (items, state) => {
1119
+ const mapPrefixItems = (items, state) => {
1160
1120
  if (items.length) {
1161
1121
  const schemas = items.map(
1162
1122
  (item, index) => createSchemaObject(item, state, [`tuple item ${index}`])
@@ -1168,13 +1128,12 @@ var mapPrefixItems = (items, state) => {
1168
1128
  }
1169
1129
  return void 0;
1170
1130
  };
1171
-
1172
- // src/create/schema/parsers/union.ts
1173
- var createUnionSchema = (zodUnion, state) => {
1131
+ const createUnionSchema = (zodUnion, state) => {
1132
+ var _a;
1174
1133
  const schemas = zodUnion.options.map(
1175
1134
  (option, index) => createSchemaObject(option, state, [`union option ${index}`])
1176
1135
  );
1177
- if (zodUnion._def.openapi?.unionOneOf) {
1136
+ if ((_a = zodUnion._def.openapi) == null ? void 0 : _a.unionOneOf) {
1178
1137
  return {
1179
1138
  type: "schema",
1180
1139
  schema: {
@@ -1191,16 +1150,13 @@ var createUnionSchema = (zodUnion, state) => {
1191
1150
  effects: flattenEffects(schemas.map((s) => s.effects))
1192
1151
  };
1193
1152
  };
1194
-
1195
- // src/create/schema/parsers/unknown.ts
1196
- var createUnknownSchema = (_zodUnknown) => ({
1153
+ const createUnknownSchema = (_zodUnknown) => ({
1197
1154
  type: "schema",
1198
1155
  schema: {}
1199
1156
  });
1200
-
1201
- // src/create/schema/parsers/index.ts
1202
- var createSchemaSwitch = (zodSchema, state) => {
1203
- if (zodSchema._def.openapi?.type) {
1157
+ const createSchemaSwitch = (zodSchema, state) => {
1158
+ var _a;
1159
+ if ((_a = zodSchema._def.openapi) == null ? void 0 : _a.type) {
1204
1160
  return createManualTypeSchema(zodSchema, state);
1205
1161
  }
1206
1162
  if (isZodType(zodSchema, "ZodString")) {
@@ -1210,7 +1166,7 @@ var createSchemaSwitch = (zodSchema, state) => {
1210
1166
  return createNumberSchema(zodSchema, state);
1211
1167
  }
1212
1168
  if (isZodType(zodSchema, "ZodBoolean")) {
1213
- return createBooleanSchema(zodSchema);
1169
+ return createBooleanSchema();
1214
1170
  }
1215
1171
  if (isZodType(zodSchema, "ZodEnum")) {
1216
1172
  return createEnumSchema(zodSchema);
@@ -1255,7 +1211,7 @@ var createSchemaSwitch = (zodSchema, state) => {
1255
1211
  return createTupleSchema(zodSchema, state);
1256
1212
  }
1257
1213
  if (isZodType(zodSchema, "ZodDate")) {
1258
- return createDateSchema(zodSchema);
1214
+ return createDateSchema();
1259
1215
  }
1260
1216
  if (isZodType(zodSchema, "ZodPipeline")) {
1261
1217
  return createPipelineSchema(zodSchema, state);
@@ -1279,7 +1235,7 @@ var createSchemaSwitch = (zodSchema, state) => {
1279
1235
  return createCatchSchema(zodSchema, state);
1280
1236
  }
1281
1237
  if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) {
1282
- return createUnknownSchema(zodSchema);
1238
+ return createUnknownSchema();
1283
1239
  }
1284
1240
  if (isZodType(zodSchema, "ZodLazy")) {
1285
1241
  return createLazySchema(zodSchema, state);
@@ -1292,10 +1248,8 @@ var createSchemaSwitch = (zodSchema, state) => {
1292
1248
  }
1293
1249
  return createManualTypeSchema(zodSchema, state);
1294
1250
  };
1295
-
1296
- // src/create/schema/index.ts
1297
- var isDescriptionEqual = (schema, zodSchema) => schema.type === "ref" && zodSchema.description === schema.zodType.description;
1298
- var createNewSchema = (zodSchema, state) => {
1251
+ const isDescriptionEqual = (schema, zodSchema) => schema.type === "ref" && zodSchema.description === schema.zodType.description;
1252
+ const createNewSchema = (zodSchema, state) => {
1299
1253
  if (state.visited.has(zodSchema)) {
1300
1254
  throw new Error(
1301
1255
  `The schema at ${state.path.join(
@@ -1322,7 +1276,7 @@ var createNewSchema = (zodSchema, state) => {
1322
1276
  state.visited.delete(zodSchema);
1323
1277
  return schemaWithMetadata;
1324
1278
  };
1325
- var createNewRef = (ref, zodSchema, state) => {
1279
+ const createNewRef = (ref, zodSchema, state) => {
1326
1280
  state.components.schemas.set(zodSchema, {
1327
1281
  type: "in-progress",
1328
1282
  ref
@@ -1350,7 +1304,7 @@ var createNewRef = (ref, zodSchema, state) => {
1350
1304
  zodType: zodSchema
1351
1305
  };
1352
1306
  };
1353
- var createExistingRef = (zodSchema, component, state) => {
1307
+ const createExistingRef = (zodSchema, component, state) => {
1354
1308
  if (component && component.type === "complete") {
1355
1309
  return {
1356
1310
  type: "ref",
@@ -1381,34 +1335,33 @@ var createExistingRef = (zodSchema, component, state) => {
1381
1335
  }
1382
1336
  return;
1383
1337
  };
1384
- var createSchemaOrRef = (zodSchema, state) => {
1338
+ const createSchemaOrRef = (zodSchema, state) => {
1339
+ var _a;
1385
1340
  const component = state.components.schemas.get(zodSchema);
1386
1341
  const existingRef = createExistingRef(zodSchema, component, state);
1387
1342
  if (existingRef) {
1388
1343
  return existingRef;
1389
1344
  }
1390
- const ref = zodSchema._def.openapi?.ref ?? component?.ref;
1345
+ const ref = ((_a = zodSchema._def.openapi) == null ? void 0 : _a.ref) ?? (component == null ? void 0 : component.ref);
1391
1346
  if (ref) {
1392
1347
  return createNewRef(ref, zodSchema, state);
1393
1348
  }
1394
1349
  return createNewSchema(zodSchema, state);
1395
1350
  };
1396
- var createSchemaObject = (zodSchema, state, subpath) => {
1351
+ const createSchemaObject = (zodSchema, state, subpath) => {
1397
1352
  state.path.push(...subpath);
1398
1353
  const schema = createSchemaOrRef(zodSchema, state);
1399
1354
  state.path.pop();
1400
1355
  return schema;
1401
1356
  };
1402
- var createSchema = (zodSchema, state, subpath) => {
1357
+ const createSchema = (zodSchema, state, subpath) => {
1403
1358
  const schema = createSchemaObject(zodSchema, state, subpath);
1404
1359
  if (schema.effects) {
1405
1360
  verifyEffects(schema.effects, state);
1406
1361
  }
1407
1362
  return schema.schema;
1408
1363
  };
1409
-
1410
- // src/create/content.ts
1411
- var createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1364
+ const createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1412
1365
  if (!schemaObject) {
1413
1366
  return void 0;
1414
1367
  }
@@ -1426,7 +1379,7 @@ var createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1426
1379
  subpath
1427
1380
  );
1428
1381
  };
1429
- var createMediaTypeObject = (mediaTypeObject, components, type, subpath) => {
1382
+ const createMediaTypeObject = (mediaTypeObject, components, type, subpath) => {
1430
1383
  if (!mediaTypeObject) {
1431
1384
  return void 0;
1432
1385
  }
@@ -1438,7 +1391,7 @@ var createMediaTypeObject = (mediaTypeObject, components, type, subpath) => {
1438
1391
  ])
1439
1392
  };
1440
1393
  };
1441
- var createContent = (contentObject, components, type, subpath) => Object.entries(contentObject).reduce(
1394
+ const createContent = (contentObject, components, type, subpath) => Object.entries(contentObject).reduce(
1442
1395
  (acc, [mediaType, zodOpenApiMediaTypeObject]) => {
1443
1396
  const mediaTypeObject = createMediaTypeObject(
1444
1397
  zodOpenApiMediaTypeObject,
@@ -1453,11 +1406,10 @@ var createContent = (contentObject, components, type, subpath) => Object.entries
1453
1406
  },
1454
1407
  {}
1455
1408
  );
1456
-
1457
- // src/create/parameters.ts
1458
- var createComponentParamRef = (ref) => `#/components/parameters/${ref}`;
1459
- var createBaseParameter = (schema, components, subpath) => {
1460
- const { ref, ...rest } = schema._def.openapi?.param ?? {};
1409
+ const createComponentParamRef = (ref) => `#/components/parameters/${ref}`;
1410
+ const createBaseParameter = (schema, components, subpath) => {
1411
+ var _a, _b, _c;
1412
+ const { ref, ...rest } = ((_a = schema._def.openapi) == null ? void 0 : _a.param) ?? {};
1461
1413
  const state = {
1462
1414
  components,
1463
1415
  type: "input",
@@ -1465,8 +1417,8 @@ var createBaseParameter = (schema, components, subpath) => {
1465
1417
  visited: /* @__PURE__ */ new Set()
1466
1418
  };
1467
1419
  const schemaObject = createSchema(schema, state, [...subpath, "schema"]);
1468
- const required = !isOptionalSchema(schema, state)?.optional;
1469
- const description = schema._def.openapi?.description ?? schema._def.description;
1420
+ const required = !((_b = isOptionalSchema(schema, state)) == null ? void 0 : _b.optional);
1421
+ const description = ((_c = schema._def.openapi) == null ? void 0 : _c.description) ?? schema._def.description;
1470
1422
  return {
1471
1423
  ...description && { description },
1472
1424
  ...rest,
@@ -1474,10 +1426,11 @@ var createBaseParameter = (schema, components, subpath) => {
1474
1426
  ...required && { required }
1475
1427
  };
1476
1428
  };
1477
- var createParamOrRef = (zodSchema, components, subpath, type, name) => {
1429
+ const createParamOrRef = (zodSchema, components, subpath, type, name) => {
1430
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1478
1431
  const component = components.parameters.get(zodSchema);
1479
- const paramType = zodSchema._def?.openapi?.param?.in ?? component?.in ?? type;
1480
- const paramName = zodSchema._def?.openapi?.param?.name ?? component?.name ?? name;
1432
+ 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;
1433
+ 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;
1481
1434
  if (!paramType) {
1482
1435
  throw new Error("Parameter type missing");
1483
1436
  }
@@ -1496,7 +1449,7 @@ var createParamOrRef = (zodSchema, components, subpath, type, name) => {
1496
1449
  if ("$ref" in baseParamOrRef) {
1497
1450
  throw new Error("Unexpected Error: received a reference object");
1498
1451
  }
1499
- const ref = zodSchema?._def?.openapi?.param?.ref ?? component?.ref;
1452
+ 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);
1500
1453
  const paramObject = {
1501
1454
  in: paramType,
1502
1455
  name: paramName,
@@ -1516,16 +1469,16 @@ var createParamOrRef = (zodSchema, components, subpath, type, name) => {
1516
1469
  }
1517
1470
  return paramObject;
1518
1471
  };
1519
- var createParameters = (type, zodObjectType, components, subpath) => {
1472
+ const createParameters = (type, zodObjectType, components, subpath) => {
1520
1473
  if (!zodObjectType) {
1521
1474
  return [];
1522
1475
  }
1523
- const zodObject = getZodObject(zodObjectType, "input").shape;
1476
+ const zodObject = getZodObject(zodObjectType).shape;
1524
1477
  return Object.entries(zodObject).map(
1525
1478
  ([key, zodSchema]) => createParamOrRef(zodSchema, components, [...subpath, key], type, key)
1526
1479
  );
1527
1480
  };
1528
- var createRequestParams = (requestParams, components, subpath) => {
1481
+ const createRequestParams = (requestParams, components, subpath) => {
1529
1482
  if (!requestParams) {
1530
1483
  return [];
1531
1484
  }
@@ -1553,7 +1506,7 @@ var createRequestParams = (requestParams, components, subpath) => {
1553
1506
  );
1554
1507
  return [...pathParams, ...queryParams, ...cookieParams, ...headerParams];
1555
1508
  };
1556
- var createManualParameters = (parameters, components, subpath) => parameters?.map((param, index) => {
1509
+ const createManualParameters = (parameters, components, subpath) => (parameters == null ? void 0 : parameters.map((param, index) => {
1557
1510
  if (isAnyZodType(param)) {
1558
1511
  return createParamOrRef(param, components, [
1559
1512
  ...subpath,
@@ -1561,8 +1514,8 @@ var createManualParameters = (parameters, components, subpath) => parameters?.ma
1561
1514
  ]);
1562
1515
  }
1563
1516
  return param;
1564
- }) ?? [];
1565
- var createParametersObject = (parameters, requestParams, components, subpath) => {
1517
+ })) ?? [];
1518
+ const createParametersObject = (parameters, requestParams, components, subpath) => {
1566
1519
  const manualParameters = createManualParameters(
1567
1520
  parameters,
1568
1521
  components,
@@ -1575,33 +1528,28 @@ var createParametersObject = (parameters, requestParams, components, subpath) =>
1575
1528
  ];
1576
1529
  return combinedParameters.length ? combinedParameters : void 0;
1577
1530
  };
1578
- var getZodObject = (schema, type) => {
1531
+ const getZodObject = (schema, type) => {
1579
1532
  if (isZodType(schema, "ZodObject")) {
1580
1533
  return schema;
1581
1534
  }
1582
1535
  if (isZodType(schema, "ZodLazy")) {
1583
- return getZodObject(schema.schema, type);
1536
+ return getZodObject(schema.schema);
1584
1537
  }
1585
1538
  if (isZodType(schema, "ZodEffects")) {
1586
- return getZodObject(schema.innerType(), type);
1539
+ return getZodObject(schema.innerType());
1587
1540
  }
1588
1541
  if (isZodType(schema, "ZodBranded")) {
1589
- return getZodObject(schema.unwrap(), type);
1542
+ return getZodObject(schema.unwrap());
1590
1543
  }
1591
1544
  if (isZodType(schema, "ZodPipeline")) {
1592
- if (type === "input") {
1593
- return getZodObject(schema._def.in, type);
1545
+ {
1546
+ return getZodObject(schema._def.in);
1594
1547
  }
1595
- return getZodObject(schema._def.out, type);
1596
1548
  }
1597
1549
  throw new Error("failed to find ZodObject in schema");
1598
1550
  };
1599
-
1600
- // src/create/specificationExtension.ts
1601
- var isISpecificationExtension = (key) => key.startsWith("x-");
1602
-
1603
- // src/create/responses.ts
1604
- var createResponseHeaders = (responseHeaders, components) => {
1551
+ const isISpecificationExtension = (key) => key.startsWith("x-");
1552
+ const createResponseHeaders = (responseHeaders, components) => {
1605
1553
  if (!responseHeaders) {
1606
1554
  return void 0;
1607
1555
  }
@@ -1613,7 +1561,8 @@ var createResponseHeaders = (responseHeaders, components) => {
1613
1561
  }
1614
1562
  return responseHeaders;
1615
1563
  };
1616
- var createHeaderOrRef = (schema, components) => {
1564
+ const createHeaderOrRef = (schema, components) => {
1565
+ var _a, _b, _c;
1617
1566
  const component = components.headers.get(schema);
1618
1567
  if (component && component.type === "complete") {
1619
1568
  return {
@@ -1624,7 +1573,7 @@ var createHeaderOrRef = (schema, components) => {
1624
1573
  if ("$ref" in baseHeader) {
1625
1574
  throw new Error("Unexpected Error: received a reference object");
1626
1575
  }
1627
- const ref = schema._def?.openapi?.header?.ref ?? component?.ref;
1576
+ 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);
1628
1577
  if (ref) {
1629
1578
  components.headers.set(schema, {
1630
1579
  type: "complete",
@@ -1637,8 +1586,9 @@ var createHeaderOrRef = (schema, components) => {
1637
1586
  }
1638
1587
  return baseHeader;
1639
1588
  };
1640
- var createBaseHeader = (schema, components) => {
1641
- const { ref, ...rest } = schema._def.openapi?.header ?? {};
1589
+ const createBaseHeader = (schema, components) => {
1590
+ var _a, _b;
1591
+ const { ref, ...rest } = ((_a = schema._def.openapi) == null ? void 0 : _a.header) ?? {};
1642
1592
  const state = {
1643
1593
  components,
1644
1594
  type: "output",
@@ -1646,15 +1596,15 @@ var createBaseHeader = (schema, components) => {
1646
1596
  visited: /* @__PURE__ */ new Set()
1647
1597
  };
1648
1598
  const schemaObject = createSchema(schema, state, ["header"]);
1649
- const required = !isOptionalSchema(schema, state)?.optional;
1599
+ const required = !((_b = isOptionalSchema(schema, state)) == null ? void 0 : _b.optional);
1650
1600
  return {
1651
1601
  ...rest,
1652
1602
  ...schema && { schema: schemaObject },
1653
1603
  ...required && { required }
1654
1604
  };
1655
1605
  };
1656
- var createComponentHeaderRef = (ref) => `#/components/headers/${ref}`;
1657
- var createResponse = (responseObject, components, subpath) => {
1606
+ const createComponentHeaderRef = (ref) => `#/components/headers/${ref}`;
1607
+ const createResponse = (responseObject, components, subpath) => {
1658
1608
  if ("$ref" in responseObject) {
1659
1609
  return responseObject;
1660
1610
  }
@@ -1674,7 +1624,7 @@ var createResponse = (responseObject, components, subpath) => {
1674
1624
  ])
1675
1625
  }
1676
1626
  };
1677
- const responseRef = ref ?? component?.ref;
1627
+ const responseRef = ref ?? (component == null ? void 0 : component.ref);
1678
1628
  if (responseRef) {
1679
1629
  components.responses.set(responseObject, {
1680
1630
  responseObject: response,
@@ -1687,7 +1637,7 @@ var createResponse = (responseObject, components, subpath) => {
1687
1637
  }
1688
1638
  return response;
1689
1639
  };
1690
- var createResponses = (responsesObject, components, subpath) => Object.entries(responsesObject).reduce(
1640
+ const createResponses = (responsesObject, components, subpath) => Object.entries(responsesObject).reduce(
1691
1641
  (acc, [statusCode, responseObject]) => {
1692
1642
  if (isISpecificationExtension(statusCode)) {
1693
1643
  acc[statusCode] = responseObject;
@@ -1701,9 +1651,7 @@ var createResponses = (responsesObject, components, subpath) => Object.entries(r
1701
1651
  },
1702
1652
  {}
1703
1653
  );
1704
-
1705
- // src/create/paths.ts
1706
- var createRequestBody = (requestBodyObject, components, subpath) => {
1654
+ const createRequestBody = (requestBodyObject, components, subpath) => {
1707
1655
  if (!requestBodyObject) {
1708
1656
  return void 0;
1709
1657
  }
@@ -1713,7 +1661,7 @@ var createRequestBody = (requestBodyObject, components, subpath) => {
1713
1661
  $ref: createComponentRequestBodyRef(component.ref)
1714
1662
  };
1715
1663
  }
1716
- const ref = requestBodyObject.ref ?? component?.ref;
1664
+ const ref = requestBodyObject.ref ?? (component == null ? void 0 : component.ref);
1717
1665
  const requestBody = {
1718
1666
  ...requestBodyObject,
1719
1667
  content: createContent(requestBodyObject.content, components, "input", [
@@ -1733,7 +1681,7 @@ var createRequestBody = (requestBodyObject, components, subpath) => {
1733
1681
  }
1734
1682
  return requestBody;
1735
1683
  };
1736
- var createOperation = (operationObject, components, subpath) => {
1684
+ const createOperation = (operationObject, components, subpath) => {
1737
1685
  const { parameters, requestParams, requestBody, responses, ...rest } = operationObject;
1738
1686
  const maybeParameters = createParametersObject(
1739
1687
  parameters,
@@ -1764,7 +1712,7 @@ var createOperation = (operationObject, components, subpath) => {
1764
1712
  ...maybeCallbacks && { callbacks: maybeCallbacks }
1765
1713
  };
1766
1714
  };
1767
- var createPathItem = (pathObject, components, path) => Object.entries(pathObject).reduce(
1715
+ const createPathItem = (pathObject, components, path) => Object.entries(pathObject).reduce(
1768
1716
  (acc, [key, value]) => {
1769
1717
  if (!value) {
1770
1718
  return acc;
@@ -1782,7 +1730,7 @@ var createPathItem = (pathObject, components, path) => Object.entries(pathObject
1782
1730
  },
1783
1731
  {}
1784
1732
  );
1785
- var createPaths = (pathsObject, components) => {
1733
+ const createPaths = (pathsObject, components) => {
1786
1734
  if (!pathsObject) {
1787
1735
  return void 0;
1788
1736
  }
@@ -1798,9 +1746,7 @@ var createPaths = (pathsObject, components) => {
1798
1746
  {}
1799
1747
  );
1800
1748
  };
1801
-
1802
- // src/create/callbacks.ts
1803
- var createCallback = (callbackObject, components, subpath) => {
1749
+ const createCallback = (callbackObject, components, subpath) => {
1804
1750
  const { ref, ...callbacks } = callbackObject;
1805
1751
  const callback = Object.entries(
1806
1752
  callbacks
@@ -1827,7 +1773,7 @@ var createCallback = (callbackObject, components, subpath) => {
1827
1773
  }
1828
1774
  return callback;
1829
1775
  };
1830
- var createCallbacks = (callbacksObject, components, subpath) => {
1776
+ const createCallbacks = (callbacksObject, components, subpath) => {
1831
1777
  if (!callbacksObject) {
1832
1778
  return void 0;
1833
1779
  }
@@ -1846,9 +1792,7 @@ var createCallbacks = (callbacksObject, components, subpath) => {
1846
1792
  {}
1847
1793
  );
1848
1794
  };
1849
-
1850
- // src/create/components.ts
1851
- var getDefaultComponents = (componentsObject, openapi = "3.1.0") => {
1795
+ const getDefaultComponents = (componentsObject, openapi = "3.1.0") => {
1852
1796
  const defaultComponents = {
1853
1797
  schemas: /* @__PURE__ */ new Map(),
1854
1798
  parameters: /* @__PURE__ */ new Map(),
@@ -1869,18 +1813,19 @@ var getDefaultComponents = (componentsObject, openapi = "3.1.0") => {
1869
1813
  getCallbacks(componentsObject.callbacks, defaultComponents);
1870
1814
  return defaultComponents;
1871
1815
  };
1872
- var getSchemas = (schemas, components) => {
1816
+ const getSchemas = (schemas, components) => {
1873
1817
  if (!schemas) {
1874
1818
  return;
1875
1819
  }
1876
1820
  Object.entries(schemas).forEach(([key, schema]) => {
1821
+ var _a;
1877
1822
  if (isAnyZodType(schema)) {
1878
1823
  if (components.schemas.has(schema)) {
1879
1824
  throw new Error(
1880
1825
  `Schema ${JSON.stringify(schema._def)} is already registered`
1881
1826
  );
1882
1827
  }
1883
- const ref = schema._def.openapi?.ref ?? key;
1828
+ const ref = ((_a = schema._def.openapi) == null ? void 0 : _a.ref) ?? key;
1884
1829
  components.schemas.set(schema, {
1885
1830
  type: "manual",
1886
1831
  ref
@@ -1888,20 +1833,21 @@ var getSchemas = (schemas, components) => {
1888
1833
  }
1889
1834
  });
1890
1835
  };
1891
- var getParameters = (parameters, components) => {
1836
+ const getParameters = (parameters, components) => {
1892
1837
  if (!parameters) {
1893
1838
  return;
1894
1839
  }
1895
1840
  Object.entries(parameters).forEach(([key, schema]) => {
1841
+ var _a, _b, _c, _d, _e, _f;
1896
1842
  if (isAnyZodType(schema)) {
1897
1843
  if (components.parameters.has(schema)) {
1898
1844
  throw new Error(
1899
1845
  `Parameter ${JSON.stringify(schema._def)} is already registered`
1900
1846
  );
1901
1847
  }
1902
- const ref = schema._def.openapi?.param?.ref ?? key;
1903
- const name = schema._def.openapi?.param?.name;
1904
- const location = schema._def.openapi?.param?.in;
1848
+ const ref = ((_b = (_a = schema._def.openapi) == null ? void 0 : _a.param) == null ? void 0 : _b.ref) ?? key;
1849
+ const name = (_d = (_c = schema._def.openapi) == null ? void 0 : _c.param) == null ? void 0 : _d.name;
1850
+ const location = (_f = (_e = schema._def.openapi) == null ? void 0 : _e.param) == null ? void 0 : _f.in;
1905
1851
  if (!name || !location) {
1906
1852
  throw new Error("`name` or `in` missing in .openapi()");
1907
1853
  }
@@ -1914,18 +1860,19 @@ var getParameters = (parameters, components) => {
1914
1860
  }
1915
1861
  });
1916
1862
  };
1917
- var getHeaders = (responseHeaders, components) => {
1863
+ const getHeaders = (responseHeaders, components) => {
1918
1864
  if (!responseHeaders) {
1919
1865
  return;
1920
1866
  }
1921
1867
  Object.entries(responseHeaders).forEach(([key, schema]) => {
1868
+ var _a, _b;
1922
1869
  if (isAnyZodType(schema)) {
1923
1870
  if (components.parameters.has(schema)) {
1924
1871
  throw new Error(
1925
1872
  `Header ${JSON.stringify(schema._def)} is already registered`
1926
1873
  );
1927
1874
  }
1928
- const ref = schema._def.openapi?.param?.ref ?? key;
1875
+ const ref = ((_b = (_a = schema._def.openapi) == null ? void 0 : _a.param) == null ? void 0 : _b.ref) ?? key;
1929
1876
  components.headers.set(schema, {
1930
1877
  type: "manual",
1931
1878
  ref
@@ -1933,7 +1880,7 @@ var getHeaders = (responseHeaders, components) => {
1933
1880
  }
1934
1881
  });
1935
1882
  };
1936
- var getResponses = (responses, components) => {
1883
+ const getResponses = (responses, components) => {
1937
1884
  if (!responses) {
1938
1885
  return;
1939
1886
  }
@@ -1943,14 +1890,14 @@ var getResponses = (responses, components) => {
1943
1890
  `Header ${JSON.stringify(responseObject)} is already registered`
1944
1891
  );
1945
1892
  }
1946
- const ref = responseObject?.ref ?? key;
1893
+ const ref = (responseObject == null ? void 0 : responseObject.ref) ?? key;
1947
1894
  components.responses.set(responseObject, {
1948
1895
  type: "manual",
1949
1896
  ref
1950
1897
  });
1951
1898
  });
1952
1899
  };
1953
- var getRequestBodies = (requestBodies, components) => {
1900
+ const getRequestBodies = (requestBodies, components) => {
1954
1901
  if (!requestBodies) {
1955
1902
  return;
1956
1903
  }
@@ -1960,14 +1907,14 @@ var getRequestBodies = (requestBodies, components) => {
1960
1907
  `Header ${JSON.stringify(requestBody)} is already registered`
1961
1908
  );
1962
1909
  }
1963
- const ref = requestBody?.ref ?? key;
1910
+ const ref = (requestBody == null ? void 0 : requestBody.ref) ?? key;
1964
1911
  components.requestBodies.set(requestBody, {
1965
1912
  type: "manual",
1966
1913
  ref
1967
1914
  });
1968
1915
  });
1969
1916
  };
1970
- var getCallbacks = (callbacks, components) => {
1917
+ const getCallbacks = (callbacks, components) => {
1971
1918
  if (!callbacks) {
1972
1919
  return;
1973
1920
  }
@@ -1977,18 +1924,18 @@ var getCallbacks = (callbacks, components) => {
1977
1924
  `Callback ${JSON.stringify(callback)} is already registered`
1978
1925
  );
1979
1926
  }
1980
- const ref = callback?.ref ?? key;
1927
+ const ref = (callback == null ? void 0 : callback.ref) ?? key;
1981
1928
  components.callbacks.set(callback, {
1982
1929
  type: "manual",
1983
1930
  ref
1984
1931
  });
1985
1932
  });
1986
1933
  };
1987
- var createComponentSchemaRef = (schemaRef) => `#/components/schemas/${schemaRef}`;
1988
- var createComponentResponseRef = (responseRef) => `#/components/responses/${responseRef}`;
1989
- var createComponentRequestBodyRef = (requestBodyRef) => `#/components/requestBodies/${requestBodyRef}`;
1990
- var createComponentCallbackRef = (callbackRef) => `#/components/callbacks/${callbackRef}`;
1991
- var createComponents = (componentsObject, components) => {
1934
+ const createComponentSchemaRef = (schemaRef) => `#/components/schemas/${schemaRef}`;
1935
+ const createComponentResponseRef = (responseRef) => `#/components/responses/${responseRef}`;
1936
+ const createComponentRequestBodyRef = (requestBodyRef) => `#/components/requestBodies/${requestBodyRef}`;
1937
+ const createComponentCallbackRef = (callbackRef) => `#/components/callbacks/${callbackRef}`;
1938
+ const createComponents = (componentsObject, components) => {
1992
1939
  const combinedSchemas = createSchemaComponents(componentsObject, components);
1993
1940
  const combinedParameters = createParamComponents(
1994
1941
  componentsObject,
@@ -2010,12 +1957,13 @@ var createComponents = (componentsObject, components) => {
2010
1957
  };
2011
1958
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2012
1959
  };
2013
- var createSchemaComponents = (componentsObject, components) => {
1960
+ const createSchemaComponents = (componentsObject, components) => {
2014
1961
  Array.from(components.schemas).forEach(([schema, { type }], index) => {
1962
+ var _a;
2015
1963
  if (type === "manual") {
2016
1964
  const state = {
2017
1965
  components,
2018
- type: schema._def.openapi?.refType ?? "output",
1966
+ type: ((_a = schema._def.openapi) == null ? void 0 : _a.refType) ?? "output",
2019
1967
  path: [],
2020
1968
  visited: /* @__PURE__ */ new Set()
2021
1969
  };
@@ -2048,7 +1996,7 @@ var createSchemaComponents = (componentsObject, components) => {
2048
1996
  }, customComponents);
2049
1997
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2050
1998
  };
2051
- var createParamComponents = (componentsObject, components) => {
1999
+ const createParamComponents = (componentsObject, components) => {
2052
2000
  Array.from(components.parameters).forEach(([schema, component], index) => {
2053
2001
  if (component.type === "manual") {
2054
2002
  createParamOrRef(
@@ -2085,7 +2033,7 @@ var createParamComponents = (componentsObject, components) => {
2085
2033
  }, customComponents);
2086
2034
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2087
2035
  };
2088
- var createHeaderComponents = (componentsObject, components) => {
2036
+ const createHeaderComponents = (componentsObject, components) => {
2089
2037
  Array.from(components.headers).forEach(([schema, component]) => {
2090
2038
  if (component.type === "manual") {
2091
2039
  createHeaderOrRef(schema, components);
@@ -2112,7 +2060,7 @@ var createHeaderComponents = (componentsObject, components) => {
2112
2060
  }, customComponents);
2113
2061
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2114
2062
  };
2115
- var createResponseComponents = (components) => {
2063
+ const createResponseComponents = (components) => {
2116
2064
  Array.from(components.responses).forEach(([schema, component], index) => {
2117
2065
  if (component.type === "manual") {
2118
2066
  createResponse(schema, components, [`component response index ${index}`]);
@@ -2129,7 +2077,7 @@ var createResponseComponents = (components) => {
2129
2077
  }, {});
2130
2078
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2131
2079
  };
2132
- var createRequestBodiesComponents = (components) => {
2080
+ const createRequestBodiesComponents = (components) => {
2133
2081
  Array.from(components.requestBodies).forEach(([schema, component], index) => {
2134
2082
  if (component.type === "manual") {
2135
2083
  createRequestBody(schema, components, [
@@ -2148,7 +2096,7 @@ var createRequestBodiesComponents = (components) => {
2148
2096
  }, {});
2149
2097
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2150
2098
  };
2151
- var createCallbackComponents = (components) => {
2099
+ const createCallbackComponents = (components) => {
2152
2100
  Array.from(components.callbacks).forEach(([schema, component], index) => {
2153
2101
  if (component.type === "manual") {
2154
2102
  createCallback(schema, components, [`component callback ${index}`]);
@@ -2165,9 +2113,7 @@ var createCallbackComponents = (components) => {
2165
2113
  }, {});
2166
2114
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2167
2115
  };
2168
-
2169
- // src/create/document.ts
2170
- var createDocument = (zodOpenApiObject) => {
2116
+ const createDocument = (zodOpenApiObject) => {
2171
2117
  const { paths, webhooks, components = {}, ...rest } = zodOpenApiObject;
2172
2118
  const defaultComponents = getDefaultComponents(
2173
2119
  components,
@@ -2183,62 +2129,23 @@ var createDocument = (zodOpenApiObject) => {
2183
2129
  ...createdComponents && { components: createdComponents }
2184
2130
  };
2185
2131
  };
2186
-
2187
- // src/extendZod.ts
2188
- function extendZodWithOpenApi(zod) {
2189
- if (typeof zod.ZodType.prototype.openapi !== "undefined") {
2190
- return;
2191
- }
2192
- zod.ZodType.prototype.openapi = function(openapi) {
2193
- const result = new this.constructor({
2194
- ...this._def,
2195
- openapi
2196
- });
2197
- return result;
2198
- };
2199
- const zodObjectExtend = zod.ZodObject.prototype.extend;
2200
- zod.ZodObject.prototype.extend = function(...args) {
2201
- const extendResult = zodObjectExtend.apply(this, args);
2202
- extendResult._def.extendMetadata = {
2203
- extends: this
2204
- };
2205
- delete extendResult._def.openapi;
2206
- return extendResult;
2207
- };
2208
- const zodObjectOmit = zod.ZodObject.prototype.omit;
2209
- zod.ZodObject.prototype.omit = function(...args) {
2210
- const omitResult = zodObjectOmit.apply(this, args);
2211
- delete omitResult._def.extendMetadata;
2212
- delete omitResult._def.openapi;
2213
- return omitResult;
2214
- };
2215
- const zodObjectPick = zod.ZodObject.prototype.pick;
2216
- zod.ZodObject.prototype.pick = function(...args) {
2217
- const pickResult = zodObjectPick.apply(this, args);
2218
- delete pickResult._def.extendMetadata;
2219
- delete pickResult._def.openapi;
2220
- return pickResult;
2221
- };
2222
- }
2223
-
2224
- // src/openapi3-ts/dist/oas30.ts
2225
- var oas30_exports = {};
2226
-
2227
- // src/openapi3-ts/dist/oas31.ts
2228
- var oas31_exports = {};
2229
-
2230
- // src/api.ts
2231
- var api_exports = {};
2232
- __export(api_exports, {
2233
- createComponents: () => createComponents,
2234
- createMediaTypeSchema: () => createMediaTypeSchema,
2235
- createParamOrRef: () => createParamOrRef,
2236
- getDefaultComponents: () => getDefaultComponents
2237
- });
2132
+ const oas30 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2133
+ __proto__: null
2134
+ }, Symbol.toStringTag, { value: "Module" }));
2135
+ const oas31 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2136
+ __proto__: null
2137
+ }, Symbol.toStringTag, { value: "Module" }));
2138
+ const api = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2139
+ __proto__: null,
2140
+ createComponents,
2141
+ createMediaTypeSchema,
2142
+ createParamOrRef,
2143
+ getDefaultComponents
2144
+ }, Symbol.toStringTag, { value: "Module" }));
2238
2145
  export {
2239
- api_exports as api,
2146
+ api,
2240
2147
  createDocument,
2241
2148
  extendZodWithOpenApi,
2242
- oas30_exports as oas30,
2243
- oas31_exports as oas31
2149
+ oas30,
2150
+ oas31
2244
2151
  };