zod-openapi 5.2.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,9 @@ pnpm install zod zod-openapi
31
31
 
32
32
  ### `.meta()`
33
33
 
34
- Use the `.meta()` method to add OpenAPI metadata to a Zod schema. It accepts an object with the following options:
34
+ Use Zod's native `.meta()` method to add OpenAPI metadata to your schemas. This library leverages Zod's built-in metadata functionality - no monkey patching or additional setup is required. Simply call `.meta()` on any Zod schema and it accepts an object with the following options:
35
+
36
+ > **Note:** To get full TypeScript support for the OpenAPI-specific properties in `.meta()`, you need to import `zod-openapi` somewhere in your project. This import provides TypeScript type definitions that extend Zod's `.meta()` interface at compile-time (no runtime changes), enabling your IDE and TypeScript compiler to recognize the additional properties (like `id`, `param`, `header`, etc.). In most cases this will be done where you call `createDocument` or other zod-openapi functions.
35
37
 
36
38
  | Option | Description |
37
39
  | ---------- | ---------------------------------------------------------------------------------------------------------------- |
@@ -42,7 +44,7 @@ Use the `.meta()` method to add OpenAPI metadata to a Zod schema. It accepts an
42
44
  | `outputId` | Allows you to set a different ID for the output schema. This is useful when the input and output schemas differ. |
43
45
  | `unusedIO` | Allows you to set the `io` for an unused schema added to the components section. Defaults to `output`. |
44
46
 
45
- You can also set standard OpenAPI properties directly in the `.meta()` method, such as:
47
+ You can also set standard OpenAPI properties directly in Zod's native `.meta()` method, such as:
46
48
 
47
49
  ```typescript
48
50
  z.string().meta({
@@ -51,7 +53,7 @@ z.string().meta({
51
53
  });
52
54
  ```
53
55
 
54
- You can set additional metadata to the rendered schema in a few different ways. Zod's `.meta()` method allows you to directly set OpenAPI directly to the schema. However, if you wanted to override any field that Zod generates, this may not work as expected. In this case, you can use the `override` option to customize the rendered OpenAPI schema.
56
+ You can set additional metadata to the rendered schema in a few different ways. Zod's native `.meta()` method allows you to directly set OpenAPI properties to the schema. However, if you wanted to override any field that Zod generates, this may not work as expected. In this case, you can use the `override` option to customize the rendered OpenAPI schema.
55
57
 
56
58
  eg.
57
59
 
@@ -74,7 +76,7 @@ Would render the following OpenAPI schema. Note that format is not overridden wi
74
76
  }
75
77
  ```
76
78
 
77
- In order to override fields which are generated by Zod or this library, you can use the `override` option in the `.meta()` method. This allows you to customize the rendered OpenAPI schema after we have both processed it.
79
+ In order to override fields which are generated by Zod or this library, you can use the `override` option in Zod's `.meta()` method. This allows you to customize the rendered OpenAPI schema after we have both processed it.
78
80
 
79
81
  ##### override object
80
82
 
@@ -109,6 +111,8 @@ Generates an OpenAPI documentation object.
109
111
 
110
112
  ```typescript
111
113
  import * as z from 'zod/v4';
114
+ // or import * as z from 'zod'; if using Zod 4.0.0+
115
+
112
116
  import { createDocument } from 'zod-openapi';
113
117
 
114
118
  const jobId = z.string().meta({
@@ -0,0 +1 @@
1
+ export * from '../dist/api.cjs';
package/api/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '../dist/api';
1
+ export * from '../dist/api.js';
package/api/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "main": "../dist/api.js",
3
- "module": "../dist/api.mjs",
4
- "types": "./index.d.ts"
2
+ "main": "../dist/api.cjs",
3
+ "module": "../dist/api.js",
4
+ "types": "./index.d.cts"
5
5
  }
package/dist/api.cjs ADDED
@@ -0,0 +1,6 @@
1
+ const require_components = require('./components-Bgg6LgwE.cjs');
2
+
3
+ exports.createComponents = require_components.createComponents;
4
+ exports.createRegistry = require_components.createRegistry;
5
+ exports.isAnyZodType = require_components.isAnyZodType;
6
+ exports.unwrapZodObject = require_components.unwrapZodObject;
package/dist/api.d.cts ADDED
@@ -0,0 +1,11 @@
1
+ import { ComponentRegistry, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, createComponents, createRegistry } from "./components-CJtL_UCT.cjs";
2
+ import * as core from "zod/v4/core";
3
+ import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
4
+
5
+ //#region src/create/object.d.ts
6
+ declare const unwrapZodObject: (zodType: $ZodTypes, io: "input" | "output", path: string[]) => $ZodObject;
7
+ //#endregion
8
+ //#region src/zod.d.ts
9
+ declare const isAnyZodType: (schema: unknown) => schema is core.$ZodTypes;
10
+ //#endregion
11
+ export { type ComponentRegistry, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, createComponents, createRegistry, isAnyZodType, unwrapZodObject };
package/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ComponentRegistry, Override, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverrideContext, createComponents, createRegistry } from "./components-Ddt0DmKC.js";
1
+ import { ComponentRegistry, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, createComponents, createRegistry } from "./components-BYHzS0hV.js";
2
2
  import * as core from "zod/v4/core";
3
3
  import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
4
4
 
@@ -8,4 +8,4 @@ declare const unwrapZodObject: (zodType: $ZodTypes, io: "input" | "output", path
8
8
  //#region src/zod.d.ts
9
9
  declare const isAnyZodType: (schema: unknown) => schema is core.$ZodTypes;
10
10
  //#endregion
11
- export { ComponentRegistry, Override, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverrideContext, createComponents, createRegistry, isAnyZodType, unwrapZodObject };
11
+ export { type ComponentRegistry, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, createComponents, createRegistry, isAnyZodType, unwrapZodObject };
package/dist/api.js CHANGED
@@ -1,6 +1,3 @@
1
- const require_components = require('./components-BAZgpKwe.js');
1
+ import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-B6MpvUFu.js";
2
2
 
3
- exports.createComponents = require_components.createComponents;
4
- exports.createRegistry = require_components.createRegistry;
5
- exports.isAnyZodType = require_components.isAnyZodType;
6
- exports.unwrapZodObject = require_components.unwrapZodObject;
3
+ export { createComponents, createRegistry, isAnyZodType, unwrapZodObject };
@@ -1,5 +1,5 @@
1
1
  import { globalRegistry } from "zod/v4/core";
2
- import { object, registry, toJSONSchema } from "zod/v4";
2
+ import { object, registry, toJSONSchema as toJSONSchema$1 } from "zod/v4";
3
3
 
4
4
  //#region src/zod.ts
5
5
  const isAnyZodType = (schema) => typeof schema === "object" && schema !== null && "_zod" in schema;
@@ -44,10 +44,9 @@ const unwrapZodObject = (zodType, io, path) => {
44
44
  switch (def.type) {
45
45
  case "object": return zodType;
46
46
  case "lazy": return unwrapZodObject(def.getter(), io, path);
47
- case "pipe": {
47
+ case "pipe":
48
48
  if (io === "input") return unwrapZodObject(def.in, io, path);
49
49
  return unwrapZodObject(def.out, io, path);
50
- }
51
50
  }
52
51
  throw new Error(`Failed to unwrap ZodObject from type: ${zodType._zod.def.type} at ${path.join(" > ")}`);
53
52
  };
@@ -193,11 +192,10 @@ const createPaths = (paths, registry$1, path) => {
193
192
  const override = (ctx) => {
194
193
  const def = ctx.zodSchema._zod.def;
195
194
  switch (def.type) {
196
- case "bigint": {
195
+ case "bigint":
197
196
  ctx.jsonSchema.type = "integer";
198
197
  ctx.jsonSchema.format = "int64";
199
198
  break;
200
- }
201
199
  case "union": {
202
200
  if ("discriminator" in def && typeof def.discriminator === "string") {
203
201
  ctx.jsonSchema.oneOf = ctx.jsonSchema.anyOf;
@@ -230,18 +228,15 @@ const override = (ctx) => {
230
228
  }
231
229
  break;
232
230
  }
233
- case "date": {
231
+ case "date":
234
232
  ctx.jsonSchema.type = "string";
235
233
  break;
236
- }
237
- case "literal": {
234
+ case "literal":
238
235
  if (def.values.includes(void 0)) break;
239
236
  break;
240
- }
241
- case "undefined": {
237
+ case "undefined":
242
238
  ctx.jsonSchema.not = {};
243
239
  break;
244
- }
245
240
  }
246
241
  };
247
242
  const validate = (ctx, opts) => {
@@ -250,27 +245,23 @@ const validate = (ctx, opts) => {
250
245
  const allowEmptySchema = opts.allowEmptySchema?.[def.type];
251
246
  if (allowEmptySchema === true || allowEmptySchema?.[ctx.io]) return;
252
247
  switch (def.type) {
253
- case "optional": {
248
+ case "optional":
254
249
  validate({
255
250
  ...ctx,
256
251
  zodSchema: def.innerType
257
252
  }, opts);
258
253
  return;
259
- }
260
254
  case "any": return;
261
255
  case "unknown": return;
262
- case "pipe": {
256
+ case "pipe":
263
257
  if (ctx.io === "output") throw new Error(`Zod transform found at ${ctx.path.join(" > ")} are not supported in output schemas. Please use \`.overwrite()\` or wrap the schema in a \`.pipe()\` or assign it manual metadata with \`.meta()\``);
264
258
  return;
265
- }
266
- case "transform": {
259
+ case "transform":
267
260
  if (ctx.io === "output") return;
268
261
  break;
269
- }
270
- case "literal": {
262
+ case "literal":
271
263
  if (def.values.includes(void 0)) throw new Error(`Zod literal at ${ctx.path.join(" > ")} cannot include \`undefined\` as a value. Please use \`z.undefined()\` or \`.optional()\` instead.`);
272
264
  return;
273
- }
274
265
  }
275
266
  throw new Error(`Zod schema of type \`${def.type}\` at ${ctx.path.join(" > ")} cannot be represented in OpenAPI. Please assign it metadata with \`.meta()\``);
276
267
  };
@@ -373,7 +364,7 @@ const createSchemas = (schemas, ctx) => {
373
364
  zodRegistry.add(object(entries), { id: "zodOpenApiCreateSchema" });
374
365
  for (const [id, { zodType }] of ctx.registry.components.schemas.manual) zodRegistry.add(zodType, { id });
375
366
  const outputIds = /* @__PURE__ */ new Map();
376
- const jsonSchema = toJSONSchema(zodRegistry, {
367
+ const jsonSchema = toJSONSchema$1(zodRegistry, {
377
368
  override(context) {
378
369
  const meta = context.zodSchema.meta();
379
370
  if (meta?.outputId && meta?.id) outputIds.set(meta.id, meta.outputId);
@@ -572,6 +563,7 @@ const createRegistry = (components) => {
572
563
  const ref = { $ref: `#/components/parameters/${id}` };
573
564
  registry$1.components.parameters.seen.set(parameter, ref);
574
565
  registry$1.components.parameters.ids.set(id, parameterObject);
566
+ if (opts?.manualId) return parameterObject;
575
567
  return ref;
576
568
  }
577
569
  if (opts?.location?.name || opts?.location?.in) return parameterObject;
@@ -596,6 +588,7 @@ const createRegistry = (components) => {
596
588
  const ref = { $ref: `#/components/headers/${id}` };
597
589
  registry$1.components.headers.ids.set(id, headerObject);
598
590
  registry$1.components.headers.seen.set(header, ref);
591
+ if (opts?.manualId) return headerObject;
599
592
  return ref;
600
593
  }
601
594
  registry$1.components.headers.seen.set(header, headerObject);
@@ -618,6 +611,7 @@ const createRegistry = (components) => {
618
611
  const ref = { $ref: `#/components/requestBodies/${id}` };
619
612
  registry$1.components.requestBodies.ids.set(id, requestBodyObject);
620
613
  registry$1.components.requestBodies.seen.set(requestBody, ref);
614
+ if (opts?.manualId) return requestBodyObject;
621
615
  return ref;
622
616
  }
623
617
  registry$1.components.requestBodies.seen.set(requestBody, requestBodyObject);
@@ -649,6 +643,7 @@ const createRegistry = (components) => {
649
643
  const ref = { $ref: `#/components/pathItems/${id}` };
650
644
  registry$1.components.pathItems.ids.set(id, pathItemObject);
651
645
  registry$1.components.pathItems.seen.set(pathItem, ref);
646
+ if (opts?.manualId) return pathItemObject;
652
647
  return ref;
653
648
  }
654
649
  registry$1.components.pathItems.seen.set(pathItem, pathItemObject);
@@ -672,6 +667,7 @@ const createRegistry = (components) => {
672
667
  const ref = { $ref: `#/components/responses/${id}` };
673
668
  registry$1.components.responses.ids.set(id, responseObject);
674
669
  registry$1.components.responses.seen.set(response, ref);
670
+ if (opts?.manualId) return responseObject;
675
671
  return ref;
676
672
  }
677
673
  registry$1.components.responses.seen.set(response, responseObject);
@@ -695,6 +691,7 @@ const createRegistry = (components) => {
695
691
  const ref = { $ref: `#/components/callbacks/${id}` };
696
692
  registry$1.components.callbacks.ids.set(id, callbackObject);
697
693
  registry$1.components.callbacks.seen.set(callback, ref);
694
+ if (opts?.manualId) return callbackObject;
698
695
  return ref;
699
696
  }
700
697
  registry$1.components.callbacks.seen.set(callback, callbackObject);
@@ -711,6 +708,7 @@ const createRegistry = (components) => {
711
708
  const ref = { $ref: `#/components/securitySchemes/${id}` };
712
709
  registry$1.components.securitySchemes.ids.set(id, securitySchemeObject);
713
710
  registry$1.components.securitySchemes.seen.set(securityScheme, ref);
711
+ if (opts?.manualId) return securitySchemeObject;
714
712
  return ref;
715
713
  }
716
714
  registry$1.components.securitySchemes.seen.set(securityScheme, securitySchemeObject);
@@ -727,6 +725,7 @@ const createRegistry = (components) => {
727
725
  const ref = { $ref: `#/components/links/${id}` };
728
726
  registry$1.components.links.ids.set(id, linkObject);
729
727
  registry$1.components.links.seen.set(link, ref);
728
+ if (opts?.manualId) return linkObject;
730
729
  return ref;
731
730
  }
732
731
  registry$1.components.links.seen.set(link, linkObject);
@@ -743,6 +742,7 @@ const createRegistry = (components) => {
743
742
  const ref = { $ref: `#/components/examples/${id}` };
744
743
  registry$1.components.examples.ids.set(id, exampleObject);
745
744
  registry$1.components.examples.seen.set(example, ref);
745
+ if (opts?.manualId) return exampleObject;
746
746
  return ref;
747
747
  }
748
748
  registry$1.components.examples.seen.set(example, exampleObject);
@@ -1,14 +1,17 @@
1
- import * as core from "zod/v4/core";
2
- import { $ZodType, $ZodTypes } from "zod/v4/core";
1
+ import { $ZodType, $ZodTypes, JSONSchemaMeta, toJSONSchema } from "zod/v4/core";
3
2
 
4
- //#region src/openapi3-ts/dist/model/specification-extension.d.ts
3
+ //#region src/openapi.d.ts
4
+ declare const openApiVersions: readonly ["3.1.0", "3.1.1"];
5
+ type OpenApiVersion = (typeof openApiVersions)[number];
6
+ //#endregion
7
+ //#region packages/openapi3-ts/lib-types/dist/model/specification-extension.d.ts
5
8
  type IExtensionName = `x-${string}`;
6
9
  type IExtensionType = any;
7
10
  type ISpecificationExtension = {
8
11
  [extensionName: IExtensionName]: IExtensionType;
9
12
  };
10
13
  //#endregion
11
- //#region src/openapi3-ts/dist/model/oas-common.d.ts
14
+ //#region packages/openapi3-ts/lib-types/dist/model/oas-common.d.ts
12
15
  interface ServerObject extends ISpecificationExtension {
13
16
  url: string;
14
17
  description?: string;
@@ -22,7 +25,7 @@ interface ServerVariableObject extends ISpecificationExtension {
22
25
  description?: string;
23
26
  }
24
27
  //#endregion
25
- //#region src/openapi3-ts/dist/model/openapi31.d.ts
28
+ //#region packages/openapi3-ts/lib-types/dist/model/openapi31.d.ts
26
29
  interface OpenAPIObject extends ISpecificationExtension {
27
30
  openapi: string;
28
31
  info: InfoObject;
@@ -319,16 +322,15 @@ interface SecurityRequirementObject {
319
322
  [name: string]: string[];
320
323
  }
321
324
  //#endregion
322
- //#region src/openapi.d.ts
323
- declare const openApiVersions: readonly ["3.1.0", "3.1.1"];
324
- type OpenApiVersion = (typeof openApiVersions)[number];
325
- //#endregion
326
325
  //#region src/types.d.ts
327
- type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof core.toJSONSchema>[1]>['override']>>[0];
326
+ type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof toJSONSchema>[1]>['override']>>[0];
327
+ type OverrideSchemaParameters = Omit<OverrideParameters, 'zodSchema'>;
328
328
  type ZodOpenApiOverrideContext = OverrideParameters & {
329
329
  io: 'input' | 'output';
330
330
  };
331
- type Override = (ctx: ZodOpenApiOverrideContext) => void;
331
+ type ZodOpenApiOverrideMetaContext = OverrideSchemaParameters;
332
+ type ZodOpenApiOverrideMeta = (ctx: ZodOpenApiOverrideMetaContext) => void;
333
+ type ZodOpenApiOverride = (ctx: ZodOpenApiOverrideContext) => void;
332
334
  interface ZodOpenApiBaseMetadata {
333
335
  /**
334
336
  * Used to set metadata for a parameter
@@ -351,7 +353,7 @@ interface ZodOpenApiBaseMetadata {
351
353
  /**
352
354
  * Use to override the rendered schema
353
355
  */
354
- override?: SchemaObject | Override;
356
+ override?: SchemaObject | ZodOpenApiOverrideMeta;
355
357
  /**
356
358
  * For use only if this Zod Schema is manually registered in the `components` section
357
359
  * and is not used anywhere else in the document.
@@ -364,7 +366,7 @@ interface ZodOpenApiBaseMetadata {
364
366
  */
365
367
  outputId?: string;
366
368
  }
367
- interface ZodOpenApiMetadata extends ZodOpenApiBaseMetadata, core.JSONSchemaMeta {
369
+ interface ZodOpenApiMetadata extends ZodOpenApiBaseMetadata, JSONSchemaMeta {
368
370
  examples?: unknown[];
369
371
  /**
370
372
  * @deprecated - Use `examples` instead.
@@ -491,7 +493,7 @@ interface CreateDocumentOptions {
491
493
  * - `{ type: 'string' }` — Override the schema type to be a string using an object
492
494
  * - `(ctx) => { ctx.jsonSchema.type = 'string'; }` — Override the schema type to be a string using a function
493
495
  */
494
- override?: Override;
496
+ override?: ZodOpenApiOverride;
495
497
  /**
496
498
  * Suffix to append to the output ID of the schema.
497
499
  * This is useful to avoid conflicts with other schemas that may have the same name.
@@ -630,4 +632,4 @@ interface ComponentRegistry {
630
632
  declare const createRegistry: (components?: ZodOpenApiComponentsObject) => ComponentRegistry;
631
633
  declare const createComponents: (registry: ComponentRegistry, opts: CreateDocumentOptions) => ComponentsObject;
632
634
  //#endregion
633
- export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverrideContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
635
+ export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, type ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
@@ -67,10 +67,9 @@ const unwrapZodObject = (zodType, io, path) => {
67
67
  switch (def.type) {
68
68
  case "object": return zodType;
69
69
  case "lazy": return unwrapZodObject(def.getter(), io, path);
70
- case "pipe": {
70
+ case "pipe":
71
71
  if (io === "input") return unwrapZodObject(def.in, io, path);
72
72
  return unwrapZodObject(def.out, io, path);
73
- }
74
73
  }
75
74
  throw new Error(`Failed to unwrap ZodObject from type: ${zodType._zod.def.type} at ${path.join(" > ")}`);
76
75
  };
@@ -216,11 +215,10 @@ const createPaths = (paths, registry$1, path) => {
216
215
  const override = (ctx) => {
217
216
  const def = ctx.zodSchema._zod.def;
218
217
  switch (def.type) {
219
- case "bigint": {
218
+ case "bigint":
220
219
  ctx.jsonSchema.type = "integer";
221
220
  ctx.jsonSchema.format = "int64";
222
221
  break;
223
- }
224
222
  case "union": {
225
223
  if ("discriminator" in def && typeof def.discriminator === "string") {
226
224
  ctx.jsonSchema.oneOf = ctx.jsonSchema.anyOf;
@@ -253,18 +251,15 @@ const override = (ctx) => {
253
251
  }
254
252
  break;
255
253
  }
256
- case "date": {
254
+ case "date":
257
255
  ctx.jsonSchema.type = "string";
258
256
  break;
259
- }
260
- case "literal": {
257
+ case "literal":
261
258
  if (def.values.includes(void 0)) break;
262
259
  break;
263
- }
264
- case "undefined": {
260
+ case "undefined":
265
261
  ctx.jsonSchema.not = {};
266
262
  break;
267
- }
268
263
  }
269
264
  };
270
265
  const validate = (ctx, opts) => {
@@ -273,27 +268,23 @@ const validate = (ctx, opts) => {
273
268
  const allowEmptySchema = opts.allowEmptySchema?.[def.type];
274
269
  if (allowEmptySchema === true || allowEmptySchema?.[ctx.io]) return;
275
270
  switch (def.type) {
276
- case "optional": {
271
+ case "optional":
277
272
  validate({
278
273
  ...ctx,
279
274
  zodSchema: def.innerType
280
275
  }, opts);
281
276
  return;
282
- }
283
277
  case "any": return;
284
278
  case "unknown": return;
285
- case "pipe": {
279
+ case "pipe":
286
280
  if (ctx.io === "output") throw new Error(`Zod transform found at ${ctx.path.join(" > ")} are not supported in output schemas. Please use \`.overwrite()\` or wrap the schema in a \`.pipe()\` or assign it manual metadata with \`.meta()\``);
287
281
  return;
288
- }
289
- case "transform": {
282
+ case "transform":
290
283
  if (ctx.io === "output") return;
291
284
  break;
292
- }
293
- case "literal": {
285
+ case "literal":
294
286
  if (def.values.includes(void 0)) throw new Error(`Zod literal at ${ctx.path.join(" > ")} cannot include \`undefined\` as a value. Please use \`z.undefined()\` or \`.optional()\` instead.`);
295
287
  return;
296
- }
297
288
  }
298
289
  throw new Error(`Zod schema of type \`${def.type}\` at ${ctx.path.join(" > ")} cannot be represented in OpenAPI. Please assign it metadata with \`.meta()\``);
299
290
  };
@@ -595,6 +586,7 @@ const createRegistry = (components) => {
595
586
  const ref = { $ref: `#/components/parameters/${id}` };
596
587
  registry$1.components.parameters.seen.set(parameter, ref);
597
588
  registry$1.components.parameters.ids.set(id, parameterObject);
589
+ if (opts?.manualId) return parameterObject;
598
590
  return ref;
599
591
  }
600
592
  if (opts?.location?.name || opts?.location?.in) return parameterObject;
@@ -619,6 +611,7 @@ const createRegistry = (components) => {
619
611
  const ref = { $ref: `#/components/headers/${id}` };
620
612
  registry$1.components.headers.ids.set(id, headerObject);
621
613
  registry$1.components.headers.seen.set(header, ref);
614
+ if (opts?.manualId) return headerObject;
622
615
  return ref;
623
616
  }
624
617
  registry$1.components.headers.seen.set(header, headerObject);
@@ -641,6 +634,7 @@ const createRegistry = (components) => {
641
634
  const ref = { $ref: `#/components/requestBodies/${id}` };
642
635
  registry$1.components.requestBodies.ids.set(id, requestBodyObject);
643
636
  registry$1.components.requestBodies.seen.set(requestBody, ref);
637
+ if (opts?.manualId) return requestBodyObject;
644
638
  return ref;
645
639
  }
646
640
  registry$1.components.requestBodies.seen.set(requestBody, requestBodyObject);
@@ -672,6 +666,7 @@ const createRegistry = (components) => {
672
666
  const ref = { $ref: `#/components/pathItems/${id}` };
673
667
  registry$1.components.pathItems.ids.set(id, pathItemObject);
674
668
  registry$1.components.pathItems.seen.set(pathItem, ref);
669
+ if (opts?.manualId) return pathItemObject;
675
670
  return ref;
676
671
  }
677
672
  registry$1.components.pathItems.seen.set(pathItem, pathItemObject);
@@ -695,6 +690,7 @@ const createRegistry = (components) => {
695
690
  const ref = { $ref: `#/components/responses/${id}` };
696
691
  registry$1.components.responses.ids.set(id, responseObject);
697
692
  registry$1.components.responses.seen.set(response, ref);
693
+ if (opts?.manualId) return responseObject;
698
694
  return ref;
699
695
  }
700
696
  registry$1.components.responses.seen.set(response, responseObject);
@@ -718,6 +714,7 @@ const createRegistry = (components) => {
718
714
  const ref = { $ref: `#/components/callbacks/${id}` };
719
715
  registry$1.components.callbacks.ids.set(id, callbackObject);
720
716
  registry$1.components.callbacks.seen.set(callback, ref);
717
+ if (opts?.manualId) return callbackObject;
721
718
  return ref;
722
719
  }
723
720
  registry$1.components.callbacks.seen.set(callback, callbackObject);
@@ -734,6 +731,7 @@ const createRegistry = (components) => {
734
731
  const ref = { $ref: `#/components/securitySchemes/${id}` };
735
732
  registry$1.components.securitySchemes.ids.set(id, securitySchemeObject);
736
733
  registry$1.components.securitySchemes.seen.set(securityScheme, ref);
734
+ if (opts?.manualId) return securitySchemeObject;
737
735
  return ref;
738
736
  }
739
737
  registry$1.components.securitySchemes.seen.set(securityScheme, securitySchemeObject);
@@ -750,6 +748,7 @@ const createRegistry = (components) => {
750
748
  const ref = { $ref: `#/components/links/${id}` };
751
749
  registry$1.components.links.ids.set(id, linkObject);
752
750
  registry$1.components.links.seen.set(link, ref);
751
+ if (opts?.manualId) return linkObject;
753
752
  return ref;
754
753
  }
755
754
  registry$1.components.links.seen.set(link, linkObject);
@@ -766,6 +765,7 @@ const createRegistry = (components) => {
766
765
  const ref = { $ref: `#/components/examples/${id}` };
767
766
  registry$1.components.examples.ids.set(id, exampleObject);
768
767
  registry$1.components.examples.seen.set(example, ref);
768
+ if (opts?.manualId) return exampleObject;
769
769
  return ref;
770
770
  }
771
771
  registry$1.components.examples.seen.set(example, exampleObject);
@@ -1,14 +1,17 @@
1
- import * as core from "zod/v4/core";
2
- import { $ZodType, $ZodTypes } from "zod/v4/core";
1
+ import { $ZodType, $ZodTypes, JSONSchemaMeta, toJSONSchema } from "zod/v4/core";
3
2
 
4
- //#region src/openapi3-ts/dist/model/specification-extension.d.ts
3
+ //#region src/openapi.d.ts
4
+ declare const openApiVersions: readonly ["3.1.0", "3.1.1"];
5
+ type OpenApiVersion = (typeof openApiVersions)[number];
6
+ //#endregion
7
+ //#region packages/openapi3-ts/lib-types/dist/model/specification-extension.d.ts
5
8
  type IExtensionName = `x-${string}`;
6
9
  type IExtensionType = any;
7
10
  type ISpecificationExtension = {
8
11
  [extensionName: IExtensionName]: IExtensionType;
9
12
  };
10
13
  //#endregion
11
- //#region src/openapi3-ts/dist/model/oas-common.d.ts
14
+ //#region packages/openapi3-ts/lib-types/dist/model/oas-common.d.ts
12
15
  interface ServerObject extends ISpecificationExtension {
13
16
  url: string;
14
17
  description?: string;
@@ -22,7 +25,7 @@ interface ServerVariableObject extends ISpecificationExtension {
22
25
  description?: string;
23
26
  }
24
27
  //#endregion
25
- //#region src/openapi3-ts/dist/model/openapi31.d.ts
28
+ //#region packages/openapi3-ts/lib-types/dist/model/openapi31.d.ts
26
29
  interface OpenAPIObject extends ISpecificationExtension {
27
30
  openapi: string;
28
31
  info: InfoObject;
@@ -319,16 +322,15 @@ interface SecurityRequirementObject {
319
322
  [name: string]: string[];
320
323
  }
321
324
  //#endregion
322
- //#region src/openapi.d.ts
323
- declare const openApiVersions: readonly ["3.1.0", "3.1.1"];
324
- type OpenApiVersion = (typeof openApiVersions)[number];
325
- //#endregion
326
325
  //#region src/types.d.ts
327
- type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof core.toJSONSchema>[1]>['override']>>[0];
326
+ type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof toJSONSchema>[1]>['override']>>[0];
327
+ type OverrideSchemaParameters = Omit<OverrideParameters, 'zodSchema'>;
328
328
  type ZodOpenApiOverrideContext = OverrideParameters & {
329
329
  io: 'input' | 'output';
330
330
  };
331
- type Override = (ctx: ZodOpenApiOverrideContext) => void;
331
+ type ZodOpenApiOverrideMetaContext = OverrideSchemaParameters;
332
+ type ZodOpenApiOverrideMeta = (ctx: ZodOpenApiOverrideMetaContext) => void;
333
+ type ZodOpenApiOverride = (ctx: ZodOpenApiOverrideContext) => void;
332
334
  interface ZodOpenApiBaseMetadata {
333
335
  /**
334
336
  * Used to set metadata for a parameter
@@ -351,7 +353,7 @@ interface ZodOpenApiBaseMetadata {
351
353
  /**
352
354
  * Use to override the rendered schema
353
355
  */
354
- override?: SchemaObject | Override;
356
+ override?: SchemaObject | ZodOpenApiOverrideMeta;
355
357
  /**
356
358
  * For use only if this Zod Schema is manually registered in the `components` section
357
359
  * and is not used anywhere else in the document.
@@ -364,7 +366,7 @@ interface ZodOpenApiBaseMetadata {
364
366
  */
365
367
  outputId?: string;
366
368
  }
367
- interface ZodOpenApiMetadata extends ZodOpenApiBaseMetadata, core.JSONSchemaMeta {
369
+ interface ZodOpenApiMetadata extends ZodOpenApiBaseMetadata, JSONSchemaMeta {
368
370
  examples?: unknown[];
369
371
  /**
370
372
  * @deprecated - Use `examples` instead.
@@ -491,7 +493,7 @@ interface CreateDocumentOptions {
491
493
  * - `{ type: 'string' }` — Override the schema type to be a string using an object
492
494
  * - `(ctx) => { ctx.jsonSchema.type = 'string'; }` — Override the schema type to be a string using a function
493
495
  */
494
- override?: Override;
496
+ override?: ZodOpenApiOverride;
495
497
  /**
496
498
  * Suffix to append to the output ID of the schema.
497
499
  * This is useful to avoid conflicts with other schemas that may have the same name.
@@ -630,4 +632,4 @@ interface ComponentRegistry {
630
632
  declare const createRegistry: (components?: ZodOpenApiComponentsObject) => ComponentRegistry;
631
633
  declare const createComponents: (registry: ComponentRegistry, opts: CreateDocumentOptions) => ComponentsObject;
632
634
  //#endregion
633
- export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverrideContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
635
+ export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, type ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
package/dist/index.cjs ADDED
@@ -0,0 +1,29 @@
1
+ const require_components = require('./components-Bgg6LgwE.cjs');
2
+
3
+ //#region src/create/document.ts
4
+ const createDocument = (zodOpenApiObject, opts = {}) => {
5
+ const { paths, webhooks, components,...rest } = zodOpenApiObject;
6
+ const document = rest;
7
+ const registry = require_components.createRegistry(components);
8
+ const createdPaths = require_components.createPaths(paths, registry, ["paths"]);
9
+ if (createdPaths) document.paths = createdPaths;
10
+ const createdWebhooks = require_components.createPaths(webhooks, registry, ["webhooks"]);
11
+ if (createdWebhooks) document.webhooks = createdWebhooks;
12
+ const createdComponents = require_components.createComponents(registry, opts);
13
+ if (Object.keys(createdComponents).length > 0) document.components = createdComponents;
14
+ return document;
15
+ };
16
+
17
+ //#endregion
18
+ //#region packages/openapi3-ts/src/dist/oas31.ts
19
+ var oas31_exports = {};
20
+
21
+ //#endregion
22
+ exports.createDocument = createDocument;
23
+ exports.createSchema = require_components.createSchema;
24
+ Object.defineProperty(exports, 'oas31', {
25
+ enumerable: true,
26
+ get: function () {
27
+ return oas31_exports;
28
+ }
29
+ });
@@ -1,7 +1,10 @@
1
- import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverrideContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument } from "./components-CERE3LYU.mjs";
1
+ import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument } from "./components-CJtL_UCT.cjs";
2
2
  import * as core from "zod/v4/core";
3
3
 
4
4
  //#region rolldown:runtime
5
+ declare namespace oas31_d_exports {
6
+ export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject };
7
+ }
5
8
  //#endregion
6
9
  //#region src/create/schema/schema.d.ts
7
10
  interface SchemaResult {
@@ -24,8 +27,5 @@ declare const createSchema: (schema: core.$ZodType, ctx?: {
24
27
  schema: SchemaObject | ReferenceObject;
25
28
  components: Record<string, SchemaObject>;
26
29
  };
27
- declare namespace oas31_d_exports {
28
- export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject };
29
- }
30
30
  //#endregion
31
- export { CreateDocumentOptions, Override, SchemaResult, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverrideContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
31
+ export { CreateDocumentOptions, type SchemaResult, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverrideContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument } from "./components-Ddt0DmKC.js";
1
+ import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument } from "./components-BYHzS0hV.js";
2
2
  import * as core from "zod/v4/core";
3
3
 
4
4
  //#region rolldown:runtime
5
+ declare namespace oas31_d_exports {
6
+ export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject };
7
+ }
5
8
  //#endregion
6
9
  //#region src/create/schema/schema.d.ts
7
10
  interface SchemaResult {
@@ -24,8 +27,5 @@ declare const createSchema: (schema: core.$ZodType, ctx?: {
24
27
  schema: SchemaObject | ReferenceObject;
25
28
  components: Record<string, SchemaObject>;
26
29
  };
27
- declare namespace oas31_d_exports {
28
- export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject };
29
- }
30
30
  //#endregion
31
- export { CreateDocumentOptions, Override, SchemaResult, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverrideContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
31
+ export { CreateDocumentOptions, type SchemaResult, ZodObjectInput, ZodOpenApiBaseMetadata, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiMetadata, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
package/dist/index.js CHANGED
@@ -1,19 +1,22 @@
1
- const require_components = require('./components-BAZgpKwe.js');
1
+ import { createComponents, createPaths, createRegistry, createSchema } from "./components-B6MpvUFu.js";
2
2
 
3
3
  //#region src/create/document.ts
4
4
  const createDocument = (zodOpenApiObject, opts = {}) => {
5
5
  const { paths, webhooks, components,...rest } = zodOpenApiObject;
6
6
  const document = rest;
7
- const registry = require_components.createRegistry(components);
8
- const createdPaths = require_components.createPaths(paths, registry, ["paths"]);
7
+ const registry = createRegistry(components);
8
+ const createdPaths = createPaths(paths, registry, ["paths"]);
9
9
  if (createdPaths) document.paths = createdPaths;
10
- const createdWebhooks = require_components.createPaths(webhooks, registry, ["webhooks"]);
10
+ const createdWebhooks = createPaths(webhooks, registry, ["webhooks"]);
11
11
  if (createdWebhooks) document.webhooks = createdWebhooks;
12
- const createdComponents = require_components.createComponents(registry, opts);
12
+ const createdComponents = createComponents(registry, opts);
13
13
  if (Object.keys(createdComponents).length > 0) document.components = createdComponents;
14
14
  return document;
15
15
  };
16
16
 
17
17
  //#endregion
18
- exports.createDocument = createDocument;
19
- exports.createSchema = require_components.createSchema;
18
+ //#region packages/openapi3-ts/src/dist/oas31.ts
19
+ var oas31_exports = {};
20
+
21
+ //#endregion
22
+ export { createDocument, createSchema, oas31_exports as oas31 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "5.2.0",
3
+ "version": "5.3.1",
4
4
  "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
5
5
  "keywords": [
6
6
  "typescript",
@@ -22,20 +22,21 @@
22
22
  "funding": "https://github.com/samchungy/zod-openapi?sponsor=1",
23
23
  "license": "MIT",
24
24
  "sideEffects": false,
25
+ "type": "module",
25
26
  "exports": {
26
27
  ".": {
27
- "import": "./dist/index.mjs",
28
- "require": "./dist/index.js"
28
+ "import": "./dist/index.js",
29
+ "require": "./dist/index.cjs"
29
30
  },
30
31
  "./api": {
31
- "import": "./dist/api.mjs",
32
- "require": "./dist/api.js"
32
+ "import": "./dist/api.js",
33
+ "require": "./dist/api.cjs"
33
34
  },
34
35
  "./package.json": "./package.json"
35
36
  },
36
- "main": "./dist/index.js",
37
- "module": "./dist/index.mjs",
38
- "types": "./dist/index.d.ts",
37
+ "main": "./dist/index.cjs",
38
+ "module": "./dist/index.js",
39
+ "types": "./dist/index.d.cts",
39
40
  "files": [
40
41
  "dist",
41
42
  "api"
@@ -44,16 +45,18 @@
44
45
  "@arethetypeswrong/cli": "0.18.2",
45
46
  "@changesets/changelog-github": "0.5.1",
46
47
  "@changesets/cli": "2.29.5",
47
- "@redocly/cli": "1.34.4",
48
+ "@redocly/cli": "2.0.2",
48
49
  "@types/node": "22.15.21",
50
+ "@vitest/coverage-v8": "3.2.4",
51
+ "@zod-openapi/openapi3-ts": "1.0.0",
49
52
  "ajv": "8.17.1",
50
- "eslint-plugin-import-zod": "1.1.0",
53
+ "eslint-plugin-import-zod": "1.2.0",
51
54
  "eslint-plugin-zod-openapi": "2.0.0",
52
- "openapi3-ts": "4.5.0",
53
- "skuba": "11.1.0",
54
- "tsdown": "0.12.9",
55
+ "skuba": "12.0.2",
56
+ "tsdown": "0.13.2",
57
+ "vitest": "3.2.4",
55
58
  "yaml": "2.8.0",
56
- "zod": "4.0.5"
59
+ "zod": "4.0.14"
57
60
  },
58
61
  "peerDependencies": {
59
62
  "zod": "^3.25.74 || ^4.0.0"
@@ -72,14 +75,14 @@
72
75
  "version": "11.0.0"
73
76
  },
74
77
  "scripts": {
75
- "build": "pnpm copy:types && tsdown",
78
+ "build": "pnpm -r build && tsdown",
76
79
  "copy:types": "skuba node scripts/copyTypes.ts",
77
80
  "create:docs": " skuba node examples/simple/createSchema.ts && redocly build-docs examples/simple/openapi.yml --output=examples/simple/redoc-static.html",
78
81
  "format": "skuba format",
79
82
  "lint": "skuba lint",
80
83
  "release": "pnpm build && changeset publish",
81
- "test": "skuba test",
82
- "test:ci": "skuba test --coverage",
83
- "test:watch": "skuba test --watch"
84
+ "test": "vitest run",
85
+ "test:ci": "vitest run --coverage",
86
+ "test:watch": "vitest"
84
87
  }
85
88
  }
package/dist/api.d.mts DELETED
@@ -1,11 +0,0 @@
1
- import { ComponentRegistry, Override, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverrideContext, createComponents, createRegistry } from "./components-CERE3LYU.mjs";
2
- import * as core from "zod/v4/core";
3
- import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
4
-
5
- //#region src/create/object.d.ts
6
- declare const unwrapZodObject: (zodType: $ZodTypes, io: "input" | "output", path: string[]) => $ZodObject;
7
- //#endregion
8
- //#region src/zod.d.ts
9
- declare const isAnyZodType: (schema: unknown) => schema is core.$ZodTypes;
10
- //#endregion
11
- export { ComponentRegistry, Override, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverrideContext, createComponents, createRegistry, isAnyZodType, unwrapZodObject };
package/dist/api.mjs DELETED
@@ -1,3 +0,0 @@
1
- import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-DPhhXqww.mjs";
2
-
3
- export { createComponents, createRegistry, isAnyZodType, unwrapZodObject };
package/dist/index.mjs DELETED
@@ -1,18 +0,0 @@
1
- import { createComponents, createPaths, createRegistry, createSchema } from "./components-DPhhXqww.mjs";
2
-
3
- //#region src/create/document.ts
4
- const createDocument = (zodOpenApiObject, opts = {}) => {
5
- const { paths, webhooks, components,...rest } = zodOpenApiObject;
6
- const document = rest;
7
- const registry = createRegistry(components);
8
- const createdPaths = createPaths(paths, registry, ["paths"]);
9
- if (createdPaths) document.paths = createdPaths;
10
- const createdWebhooks = createPaths(webhooks, registry, ["webhooks"]);
11
- if (createdWebhooks) document.webhooks = createdWebhooks;
12
- const createdComponents = createComponents(registry, opts);
13
- if (Object.keys(createdComponents).length > 0) document.components = createdComponents;
14
- return document;
15
- };
16
-
17
- //#endregion
18
- export { createDocument, createSchema };