zod-openapi 5.4.4 → 5.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_components = require('./components-fd4LXedu.cjs');
1
+ const require_components = require('./components-ZWafjNVh.cjs');
2
2
 
3
3
  exports.createComponents = require_components.createComponents;
4
4
  exports.createRegistry = require_components.createRegistry;
package/dist/api.d.cts ADDED
@@ -0,0 +1,7 @@
1
+ import { A as ZodOpenApiBaseMetadata, At as isAnyZodType, F as ZodOpenApiOverrideMetaContext, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, P as ZodOpenApiOverrideMeta, j as ZodOpenApiMetadata, n as createComponents, r as createRegistry, t as ComponentRegistry } from "./components-CpNqFsIP.cjs";
2
+ import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
3
+
4
+ //#region src/create/object.d.ts
5
+ declare const unwrapZodObject: (zodType: $ZodTypes, io: "input" | "output", path: string[]) => $ZodObject;
6
+ //#endregion
7
+ export { type ComponentRegistry, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, createComponents, createRegistry, isAnyZodType, unwrapZodObject };
package/dist/api.d.mts ADDED
@@ -0,0 +1,7 @@
1
+ import { A as ZodOpenApiBaseMetadata, At as isAnyZodType, F as ZodOpenApiOverrideMetaContext, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, P as ZodOpenApiOverrideMeta, j as ZodOpenApiMetadata, n as createComponents, r as createRegistry, t as ComponentRegistry } from "./components-Bl1eJexW.mjs";
2
+ import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
3
+
4
+ //#region src/create/object.d.ts
5
+ declare const unwrapZodObject: (zodType: $ZodTypes, io: "input" | "output", path: string[]) => $ZodObject;
6
+ //#endregion
7
+ export { type ComponentRegistry, ZodOpenApiBaseMetadata, ZodOpenApiMetadata, ZodOpenApiOverride, ZodOpenApiOverrideContext, ZodOpenApiOverrideMeta, ZodOpenApiOverrideMetaContext, createComponents, createRegistry, isAnyZodType, unwrapZodObject };
@@ -1,3 +1,3 @@
1
- import { a as unwrapZodObject, n as createRegistry, o as isAnyZodType, t as createComponents } from "./components-CfkaVvOy.js";
1
+ import { a as unwrapZodObject, n as createRegistry, o as isAnyZodType, t as createComponents } from "./components-DiNDbisK.mjs";
2
2
 
3
3
  export { createComponents, createRegistry, isAnyZodType, unwrapZodObject };
@@ -1,9 +1,15 @@
1
+ import * as core from "zod/v4/core";
1
2
  import { $ZodType, $ZodTypes, JSONSchemaMeta, toJSONSchema } from "zod/v4/core";
2
3
 
3
4
  //#region src/openapi.d.ts
4
5
  declare const openApiVersions: readonly ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.1.0", "3.1.1"];
5
6
  type OpenApiVersion = (typeof openApiVersions)[number];
6
7
  //#endregion
8
+ //#region src/zod.d.ts
9
+ declare const isAnyZodType: (schema: unknown) => schema is core.$ZodTypes;
10
+ type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof toJSONSchema>[1]>['override']>>[0];
11
+ type OverrideSchemaParameters = Omit<OverrideParameters, 'zodSchema'>;
12
+ //#endregion
7
13
  //#region packages/openapi3-ts/lib-types/dist/model/specification-extension.d.ts
8
14
  type IExtensionName = `x-${string}`;
9
15
  type IExtensionType = any;
@@ -323,8 +329,6 @@ interface SecurityRequirementObject {
323
329
  }
324
330
  //#endregion
325
331
  //#region src/types.d.ts
326
- type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof toJSONSchema>[1]>['override']>>[0];
327
- type OverrideSchemaParameters = Omit<OverrideParameters, 'zodSchema'>;
328
332
  type ZodOpenApiOverrideContext = OverrideParameters & {
329
333
  io: 'input' | 'output';
330
334
  };
@@ -632,4 +636,4 @@ interface ComponentRegistry {
632
636
  declare const createRegistry: (components?: ZodOpenApiComponentsObject) => ComponentRegistry;
633
637
  declare const createComponents: (registry: ComponentRegistry, opts: CreateDocumentOptions, openapiVersion?: OpenApiVersion) => ComponentsObject;
634
638
  //#endregion
635
- export { LinkParametersObject as $, ZodOpenApiBaseMetadata as A, OpenApiVersion as At, ContactObject as B, ZodOpenApiRequestBodyObject as C, TagObject as Ct, ZodOpenApiSecuritySchemeObject as D, IExtensionName as Dt, ZodOpenApiSchemaObject as E, ServerVariableObject as Et, ZodOpenApiOverrideMetaContext as F, ExampleObject as G, DiscriminatorObject as H, BaseParameterObject as I, HeaderObject as J, ExamplesObject as K, CallbackObject as L, ZodOpenApiOverride as M, ZodOpenApiOverrideContext as N, ZodOpenApiVersion as O, IExtensionType as Ot, ZodOpenApiOverrideMeta as P, LinkObject as Q, CallbacksObject as R, ZodOpenApiPathsObject as S, SecuritySchemeType as St, ZodOpenApiResponsesObject as T, ServerObject as Tt, EncodingObject as U, ContentObject as V, EncodingPropertyObject as W, InfoObject as X, HeadersObject as Y, LicenseObject as Z, ZodOpenApiObject as _, SchemaObjectType as _t, ZodObjectInput as a, OperationObject as at, ZodOpenApiParameters as b, SecurityRequirementObject as bt, ZodOpenApiComponentsObject as c, ParameterStyle as ct, ZodOpenApiExamplesObject as d, PathsObject as dt, LinksObject as et, ZodOpenApiHeaderObject as f, ReferenceObject as ft, ZodOpenApiMediaTypeObject as g, SchemaObject as gt, ZodOpenApiLinksObject as h, ResponsesObject as ht, CreateDocumentOptions as i, OpenAPIObject as it, ZodOpenApiMetadata as j, createDocument as k, ISpecificationExtension as kt, ZodOpenApiContentObject as l, PathItemObject as lt, ZodOpenApiLinkObject as m, ResponseObject as mt, createComponents as n, OAuthFlowObject as nt, ZodOpenApiCallbackObject as o, ParameterLocation as ot, ZodOpenApiHeadersObject as p, RequestBodyObject as pt, ExternalDocumentationObject as q, createRegistry as r, OAuthFlowsObject as rt, ZodOpenApiCallbacksObject as s, ParameterObject as st, ComponentRegistry as t, MediaTypeObject as tt, ZodOpenApiExampleObject as u, PathObject as ut, ZodOpenApiOperationObject as v, SchemasObject as vt, ZodOpenApiResponseObject as w, XmlObject as wt, ZodOpenApiPathItemObject as x, SecuritySchemeObject as xt, ZodOpenApiParameterObject as y, ScopesObject as yt, ComponentsObject as z };
639
+ export { LinkParametersObject as $, ZodOpenApiBaseMetadata as A, isAnyZodType as At, ContactObject as B, ZodOpenApiRequestBodyObject as C, TagObject as Ct, ZodOpenApiSecuritySchemeObject as D, IExtensionName as Dt, ZodOpenApiSchemaObject as E, ServerVariableObject as Et, ZodOpenApiOverrideMetaContext as F, ExampleObject as G, DiscriminatorObject as H, BaseParameterObject as I, HeaderObject as J, ExamplesObject as K, CallbackObject as L, ZodOpenApiOverride as M, ZodOpenApiOverrideContext as N, ZodOpenApiVersion as O, IExtensionType as Ot, ZodOpenApiOverrideMeta as P, LinkObject as Q, CallbacksObject as R, ZodOpenApiPathsObject as S, SecuritySchemeType as St, ZodOpenApiResponsesObject as T, ServerObject as Tt, EncodingObject as U, ContentObject as V, EncodingPropertyObject as W, InfoObject as X, HeadersObject as Y, LicenseObject as Z, ZodOpenApiObject as _, SchemaObjectType as _t, ZodObjectInput as a, OperationObject as at, ZodOpenApiParameters as b, SecurityRequirementObject as bt, ZodOpenApiComponentsObject as c, ParameterStyle as ct, ZodOpenApiExamplesObject as d, PathsObject as dt, LinksObject as et, ZodOpenApiHeaderObject as f, ReferenceObject as ft, ZodOpenApiMediaTypeObject as g, SchemaObject as gt, ZodOpenApiLinksObject as h, ResponsesObject as ht, CreateDocumentOptions as i, OpenAPIObject as it, ZodOpenApiMetadata as j, OpenApiVersion as jt, createDocument as k, ISpecificationExtension as kt, ZodOpenApiContentObject as l, PathItemObject as lt, ZodOpenApiLinkObject as m, ResponseObject as mt, createComponents as n, OAuthFlowObject as nt, ZodOpenApiCallbackObject as o, ParameterLocation as ot, ZodOpenApiHeadersObject as p, RequestBodyObject as pt, ExternalDocumentationObject as q, createRegistry as r, OAuthFlowsObject as rt, ZodOpenApiCallbacksObject as s, ParameterObject as st, ComponentRegistry as t, MediaTypeObject as tt, ZodOpenApiExampleObject as u, PathObject as ut, ZodOpenApiOperationObject as v, SchemasObject as vt, ZodOpenApiResponseObject as w, XmlObject as wt, ZodOpenApiPathItemObject as x, SecuritySchemeObject as xt, ZodOpenApiParameterObject as y, ScopesObject as yt, ComponentsObject as z };
@@ -1,9 +1,15 @@
1
+ import * as core from "zod/v4/core";
1
2
  import { $ZodType, $ZodTypes, JSONSchemaMeta, toJSONSchema } from "zod/v4/core";
2
3
 
3
4
  //#region src/openapi.d.ts
4
5
  declare const openApiVersions: readonly ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.1.0", "3.1.1"];
5
6
  type OpenApiVersion = (typeof openApiVersions)[number];
6
7
  //#endregion
8
+ //#region src/zod.d.ts
9
+ declare const isAnyZodType: (schema: unknown) => schema is core.$ZodTypes;
10
+ type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof toJSONSchema>[1]>['override']>>[0];
11
+ type OverrideSchemaParameters = Omit<OverrideParameters, 'zodSchema'>;
12
+ //#endregion
7
13
  //#region packages/openapi3-ts/lib-types/dist/model/specification-extension.d.ts
8
14
  type IExtensionName = `x-${string}`;
9
15
  type IExtensionType = any;
@@ -323,8 +329,6 @@ interface SecurityRequirementObject {
323
329
  }
324
330
  //#endregion
325
331
  //#region src/types.d.ts
326
- type OverrideParameters = Parameters<NonNullable<NonNullable<Parameters<typeof toJSONSchema>[1]>['override']>>[0];
327
- type OverrideSchemaParameters = Omit<OverrideParameters, 'zodSchema'>;
328
332
  type ZodOpenApiOverrideContext = OverrideParameters & {
329
333
  io: 'input' | 'output';
330
334
  };
@@ -632,4 +636,4 @@ interface ComponentRegistry {
632
636
  declare const createRegistry: (components?: ZodOpenApiComponentsObject) => ComponentRegistry;
633
637
  declare const createComponents: (registry: ComponentRegistry, opts: CreateDocumentOptions, openapiVersion?: OpenApiVersion) => ComponentsObject;
634
638
  //#endregion
635
- export { LinkParametersObject as $, ZodOpenApiBaseMetadata as A, OpenApiVersion as At, ContactObject as B, ZodOpenApiRequestBodyObject as C, TagObject as Ct, ZodOpenApiSecuritySchemeObject as D, IExtensionName as Dt, ZodOpenApiSchemaObject as E, ServerVariableObject as Et, ZodOpenApiOverrideMetaContext as F, ExampleObject as G, DiscriminatorObject as H, BaseParameterObject as I, HeaderObject as J, ExamplesObject as K, CallbackObject as L, ZodOpenApiOverride as M, ZodOpenApiOverrideContext as N, ZodOpenApiVersion as O, IExtensionType as Ot, ZodOpenApiOverrideMeta as P, LinkObject as Q, CallbacksObject as R, ZodOpenApiPathsObject as S, SecuritySchemeType as St, ZodOpenApiResponsesObject as T, ServerObject as Tt, EncodingObject as U, ContentObject as V, EncodingPropertyObject as W, InfoObject as X, HeadersObject as Y, LicenseObject as Z, ZodOpenApiObject as _, SchemaObjectType as _t, ZodObjectInput as a, OperationObject as at, ZodOpenApiParameters as b, SecurityRequirementObject as bt, ZodOpenApiComponentsObject as c, ParameterStyle as ct, ZodOpenApiExamplesObject as d, PathsObject as dt, LinksObject as et, ZodOpenApiHeaderObject as f, ReferenceObject as ft, ZodOpenApiMediaTypeObject as g, SchemaObject as gt, ZodOpenApiLinksObject as h, ResponsesObject as ht, CreateDocumentOptions as i, OpenAPIObject as it, ZodOpenApiMetadata as j, createDocument as k, ISpecificationExtension as kt, ZodOpenApiContentObject as l, PathItemObject as lt, ZodOpenApiLinkObject as m, ResponseObject as mt, createComponents as n, OAuthFlowObject as nt, ZodOpenApiCallbackObject as o, ParameterLocation as ot, ZodOpenApiHeadersObject as p, RequestBodyObject as pt, ExternalDocumentationObject as q, createRegistry as r, OAuthFlowsObject as rt, ZodOpenApiCallbacksObject as s, ParameterObject as st, ComponentRegistry as t, MediaTypeObject as tt, ZodOpenApiExampleObject as u, PathObject as ut, ZodOpenApiOperationObject as v, SchemasObject as vt, ZodOpenApiResponseObject as w, XmlObject as wt, ZodOpenApiPathItemObject as x, SecuritySchemeObject as xt, ZodOpenApiParameterObject as y, ScopesObject as yt, ComponentsObject as z };
639
+ export { LinkParametersObject as $, ZodOpenApiBaseMetadata as A, isAnyZodType as At, ContactObject as B, ZodOpenApiRequestBodyObject as C, TagObject as Ct, ZodOpenApiSecuritySchemeObject as D, IExtensionName as Dt, ZodOpenApiSchemaObject as E, ServerVariableObject as Et, ZodOpenApiOverrideMetaContext as F, ExampleObject as G, DiscriminatorObject as H, BaseParameterObject as I, HeaderObject as J, ExamplesObject as K, CallbackObject as L, ZodOpenApiOverride as M, ZodOpenApiOverrideContext as N, ZodOpenApiVersion as O, IExtensionType as Ot, ZodOpenApiOverrideMeta as P, LinkObject as Q, CallbacksObject as R, ZodOpenApiPathsObject as S, SecuritySchemeType as St, ZodOpenApiResponsesObject as T, ServerObject as Tt, EncodingObject as U, ContentObject as V, EncodingPropertyObject as W, InfoObject as X, HeadersObject as Y, LicenseObject as Z, ZodOpenApiObject as _, SchemaObjectType as _t, ZodObjectInput as a, OperationObject as at, ZodOpenApiParameters as b, SecurityRequirementObject as bt, ZodOpenApiComponentsObject as c, ParameterStyle as ct, ZodOpenApiExamplesObject as d, PathsObject as dt, LinksObject as et, ZodOpenApiHeaderObject as f, ReferenceObject as ft, ZodOpenApiMediaTypeObject as g, SchemaObject as gt, ZodOpenApiLinksObject as h, ResponsesObject as ht, CreateDocumentOptions as i, OpenAPIObject as it, ZodOpenApiMetadata as j, OpenApiVersion as jt, createDocument as k, ISpecificationExtension as kt, ZodOpenApiContentObject as l, PathItemObject as lt, ZodOpenApiLinkObject as m, ResponseObject as mt, createComponents as n, OAuthFlowObject as nt, ZodOpenApiCallbackObject as o, ParameterLocation as ot, ZodOpenApiHeadersObject as p, RequestBodyObject as pt, ExternalDocumentationObject as q, createRegistry as r, OAuthFlowsObject as rt, ZodOpenApiCallbacksObject as s, ParameterObject as st, ComponentRegistry as t, MediaTypeObject as tt, ZodOpenApiExampleObject as u, PathObject as ut, ZodOpenApiOperationObject as v, SchemasObject as vt, ZodOpenApiResponseObject as w, XmlObject as wt, ZodOpenApiPathItemObject as x, SecuritySchemeObject as xt, ZodOpenApiParameterObject as y, ScopesObject as yt, ComponentsObject as z };
@@ -239,7 +239,12 @@ const override = (ctx) => {
239
239
  break;
240
240
  }
241
241
  };
242
- const validate = (ctx, opts) => {
242
+ const validate = (ctx, opts, previousContext) => {
243
+ if (previousContext.context && ctx.zodSchema._zod.parent !== previousContext.context.zodSchema) {
244
+ if (previousContext.context.zodSchema._zod.def.type === "pipe") throw new Error(`Zod transform found at ${previousContext.context.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()\``);
245
+ throw new Error(`Zod schema of type \`${previousContext.context.zodSchema._zod.def.type}\` at ${previousContext.context?.path.join(" > ")} cannot be represented in OpenAPI. Please assign it metadata with \`.meta()\``);
246
+ }
247
+ previousContext.context = void 0;
243
248
  if (Object.keys(ctx.jsonSchema).length) return;
244
249
  const def = ctx.zodSchema._zod.def;
245
250
  const allowEmptySchema = opts.allowEmptySchema?.[def.type];
@@ -249,12 +254,17 @@ const validate = (ctx, opts) => {
249
254
  validate({
250
255
  ...ctx,
251
256
  zodSchema: def.innerType
252
- }, opts);
257
+ }, opts, previousContext);
253
258
  return;
254
259
  case "any": return;
255
260
  case "unknown": return;
256
261
  case "pipe":
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()\``);
262
+ if (ctx.io === "output") {
263
+ if (!ctx.zodSchema._zod.parent) {
264
+ previousContext.context = ctx;
265
+ return;
266
+ }
267
+ }
258
268
  return;
259
269
  case "transform":
260
270
  if (ctx.io === "output") return;
@@ -262,6 +272,10 @@ const validate = (ctx, opts) => {
262
272
  case "literal":
263
273
  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.`);
264
274
  return;
275
+ case "custom": if (!ctx.zodSchema._zod.parent) {
276
+ previousContext.context = ctx;
277
+ return;
278
+ }
265
279
  }
266
280
  throw new Error(`Zod schema of type \`${def.type}\` at ${ctx.path.join(" > ")} cannot be represented in OpenAPI. Please assign it metadata with \`.meta()\``);
267
281
  };
@@ -360,6 +374,7 @@ const createSchemas = (schemas, ctx) => {
360
374
  for (const [id, { zodType }] of ctx.registry.components.schemas.manual) zodRegistry.add(zodType, { id });
361
375
  const outputIds = /* @__PURE__ */ new Map();
362
376
  const defsName = satisfiesVersion(ctx.openapiVersion ?? "3.1.0", "3.1.0") ? "$defs" : "definitions";
377
+ const previousContext = {};
363
378
  const jsonSchema = toJSONSchema$1(zodRegistry, {
364
379
  override(context) {
365
380
  const meta = globalRegistry$1.get(context.zodSchema);
@@ -381,7 +396,7 @@ const createSchemas = (schemas, ctx) => {
381
396
  }
382
397
  deleteInvalidJsonSchemaFields(context.jsonSchema);
383
398
  deleteZodOpenApiMeta(context.jsonSchema);
384
- validate(enrichedContext, ctx.opts);
399
+ validate(enrichedContext, ctx.opts, previousContext);
385
400
  },
386
401
  io: ctx.io,
387
402
  unrepresentable: "any",
@@ -239,7 +239,12 @@ const override = (ctx) => {
239
239
  break;
240
240
  }
241
241
  };
242
- const validate = (ctx, opts) => {
242
+ const validate = (ctx, opts, previousContext) => {
243
+ if (previousContext.context && ctx.zodSchema._zod.parent !== previousContext.context.zodSchema) {
244
+ if (previousContext.context.zodSchema._zod.def.type === "pipe") throw new Error(`Zod transform found at ${previousContext.context.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()\``);
245
+ throw new Error(`Zod schema of type \`${previousContext.context.zodSchema._zod.def.type}\` at ${previousContext.context?.path.join(" > ")} cannot be represented in OpenAPI. Please assign it metadata with \`.meta()\``);
246
+ }
247
+ previousContext.context = void 0;
243
248
  if (Object.keys(ctx.jsonSchema).length) return;
244
249
  const def = ctx.zodSchema._zod.def;
245
250
  const allowEmptySchema = opts.allowEmptySchema?.[def.type];
@@ -249,12 +254,17 @@ const validate = (ctx, opts) => {
249
254
  validate({
250
255
  ...ctx,
251
256
  zodSchema: def.innerType
252
- }, opts);
257
+ }, opts, previousContext);
253
258
  return;
254
259
  case "any": return;
255
260
  case "unknown": return;
256
261
  case "pipe":
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()\``);
262
+ if (ctx.io === "output") {
263
+ if (!ctx.zodSchema._zod.parent) {
264
+ previousContext.context = ctx;
265
+ return;
266
+ }
267
+ }
258
268
  return;
259
269
  case "transform":
260
270
  if (ctx.io === "output") return;
@@ -262,6 +272,10 @@ const validate = (ctx, opts) => {
262
272
  case "literal":
263
273
  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.`);
264
274
  return;
275
+ case "custom": if (!ctx.zodSchema._zod.parent) {
276
+ previousContext.context = ctx;
277
+ return;
278
+ }
265
279
  }
266
280
  throw new Error(`Zod schema of type \`${def.type}\` at ${ctx.path.join(" > ")} cannot be represented in OpenAPI. Please assign it metadata with \`.meta()\``);
267
281
  };
@@ -360,6 +374,7 @@ const createSchemas = (schemas, ctx) => {
360
374
  for (const [id, { zodType }] of ctx.registry.components.schemas.manual) zodRegistry.add(zodType, { id });
361
375
  const outputIds = /* @__PURE__ */ new Map();
362
376
  const defsName = satisfiesVersion(ctx.openapiVersion ?? "3.1.0", "3.1.0") ? "$defs" : "definitions";
377
+ const previousContext = {};
363
378
  const jsonSchema = (0, zod_v4.toJSONSchema)(zodRegistry, {
364
379
  override(context) {
365
380
  const meta = zod_v4.globalRegistry.get(context.zodSchema);
@@ -381,7 +396,7 @@ const createSchemas = (schemas, ctx) => {
381
396
  }
382
397
  deleteInvalidJsonSchemaFields(context.jsonSchema);
383
398
  deleteZodOpenApiMeta(context.jsonSchema);
384
- validate(enrichedContext, ctx.opts);
399
+ validate(enrichedContext, ctx.opts, previousContext);
385
400
  },
386
401
  io: ctx.io,
387
402
  unrepresentable: "any",
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_components = require('./components-fd4LXedu.cjs');
1
+ const require_components = require('./components-ZWafjNVh.cjs');
2
2
 
3
3
  //#region src/create/document.ts
4
4
  const createDocument = (zodOpenApiObject, opts = {}) => {
@@ -1,4 +1,4 @@
1
- import { $ as LinkParametersObject, A as ZodOpenApiBaseMetadata, At as OpenApiVersion, B as ContactObject, C as ZodOpenApiRequestBodyObject, Ct as TagObject, D as ZodOpenApiSecuritySchemeObject, Dt as IExtensionName, E as ZodOpenApiSchemaObject, Et as ServerVariableObject, F as ZodOpenApiOverrideMetaContext, G as ExampleObject, H as DiscriminatorObject, I as BaseParameterObject, J as HeaderObject, K as ExamplesObject, L as CallbackObject, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, O as ZodOpenApiVersion, Ot as IExtensionType, P as ZodOpenApiOverrideMeta, Q as LinkObject, R as CallbacksObject, S as ZodOpenApiPathsObject, St as SecuritySchemeType, T as ZodOpenApiResponsesObject, Tt as ServerObject, U as EncodingObject, V as ContentObject, W as EncodingPropertyObject, X as InfoObject, Y as HeadersObject, Z as LicenseObject, _ as ZodOpenApiObject, _t as SchemaObjectType, a as ZodObjectInput, at as OperationObject, b as ZodOpenApiParameters, bt as SecurityRequirementObject, c as ZodOpenApiComponentsObject, ct as ParameterStyle, d as ZodOpenApiExamplesObject, dt as PathsObject, et as LinksObject, f as ZodOpenApiHeaderObject, ft as ReferenceObject, g as ZodOpenApiMediaTypeObject, gt as SchemaObject, h as ZodOpenApiLinksObject, ht as ResponsesObject, i as CreateDocumentOptions, it as OpenAPIObject, j as ZodOpenApiMetadata, k as createDocument, kt as ISpecificationExtension, l as ZodOpenApiContentObject, lt as PathItemObject, m as ZodOpenApiLinkObject, mt as ResponseObject, nt as OAuthFlowObject, o as ZodOpenApiCallbackObject, ot as ParameterLocation, p as ZodOpenApiHeadersObject, pt as RequestBodyObject, q as ExternalDocumentationObject, rt as OAuthFlowsObject, s as ZodOpenApiCallbacksObject, st as ParameterObject, t as ComponentRegistry, tt as MediaTypeObject, u as ZodOpenApiExampleObject, ut as PathObject, v as ZodOpenApiOperationObject, vt as SchemasObject, w as ZodOpenApiResponseObject, wt as XmlObject, x as ZodOpenApiPathItemObject, xt as SecuritySchemeObject, y as ZodOpenApiParameterObject, yt as ScopesObject, z as ComponentsObject } from "./components-DkkceUuA.cjs";
1
+ import { $ as LinkParametersObject, A as ZodOpenApiBaseMetadata, B as ContactObject, C as ZodOpenApiRequestBodyObject, Ct as TagObject, D as ZodOpenApiSecuritySchemeObject, Dt as IExtensionName, E as ZodOpenApiSchemaObject, Et as ServerVariableObject, F as ZodOpenApiOverrideMetaContext, G as ExampleObject, H as DiscriminatorObject, I as BaseParameterObject, J as HeaderObject, K as ExamplesObject, L as CallbackObject, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, O as ZodOpenApiVersion, Ot as IExtensionType, P as ZodOpenApiOverrideMeta, Q as LinkObject, R as CallbacksObject, S as ZodOpenApiPathsObject, St as SecuritySchemeType, T as ZodOpenApiResponsesObject, Tt as ServerObject, U as EncodingObject, V as ContentObject, W as EncodingPropertyObject, X as InfoObject, Y as HeadersObject, Z as LicenseObject, _ as ZodOpenApiObject, _t as SchemaObjectType, a as ZodObjectInput, at as OperationObject, b as ZodOpenApiParameters, bt as SecurityRequirementObject, c as ZodOpenApiComponentsObject, ct as ParameterStyle, d as ZodOpenApiExamplesObject, dt as PathsObject, et as LinksObject, f as ZodOpenApiHeaderObject, ft as ReferenceObject, g as ZodOpenApiMediaTypeObject, gt as SchemaObject, h as ZodOpenApiLinksObject, ht as ResponsesObject, i as CreateDocumentOptions, it as OpenAPIObject, j as ZodOpenApiMetadata, jt as OpenApiVersion, k as createDocument, kt as ISpecificationExtension, l as ZodOpenApiContentObject, lt as PathItemObject, m as ZodOpenApiLinkObject, mt as ResponseObject, nt as OAuthFlowObject, o as ZodOpenApiCallbackObject, ot as ParameterLocation, p as ZodOpenApiHeadersObject, pt as RequestBodyObject, q as ExternalDocumentationObject, rt as OAuthFlowsObject, s as ZodOpenApiCallbacksObject, st as ParameterObject, t as ComponentRegistry, tt as MediaTypeObject, u as ZodOpenApiExampleObject, ut as PathObject, v as ZodOpenApiOperationObject, vt as SchemasObject, w as ZodOpenApiResponseObject, wt as XmlObject, x as ZodOpenApiPathItemObject, xt as SecuritySchemeObject, y as ZodOpenApiParameterObject, yt as ScopesObject, z as ComponentsObject } from "./components-CpNqFsIP.cjs";
2
2
  import * as core from "zod/v4/core";
3
3
 
4
4
  //#region rolldown:runtime
@@ -1,4 +1,4 @@
1
- import { $ as LinkParametersObject, A as ZodOpenApiBaseMetadata, At as OpenApiVersion, B as ContactObject, C as ZodOpenApiRequestBodyObject, Ct as TagObject, D as ZodOpenApiSecuritySchemeObject, Dt as IExtensionName, E as ZodOpenApiSchemaObject, Et as ServerVariableObject, F as ZodOpenApiOverrideMetaContext, G as ExampleObject, H as DiscriminatorObject, I as BaseParameterObject, J as HeaderObject, K as ExamplesObject, L as CallbackObject, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, O as ZodOpenApiVersion, Ot as IExtensionType, P as ZodOpenApiOverrideMeta, Q as LinkObject, R as CallbacksObject, S as ZodOpenApiPathsObject, St as SecuritySchemeType, T as ZodOpenApiResponsesObject, Tt as ServerObject, U as EncodingObject, V as ContentObject, W as EncodingPropertyObject, X as InfoObject, Y as HeadersObject, Z as LicenseObject, _ as ZodOpenApiObject, _t as SchemaObjectType, a as ZodObjectInput, at as OperationObject, b as ZodOpenApiParameters, bt as SecurityRequirementObject, c as ZodOpenApiComponentsObject, ct as ParameterStyle, d as ZodOpenApiExamplesObject, dt as PathsObject, et as LinksObject, f as ZodOpenApiHeaderObject, ft as ReferenceObject, g as ZodOpenApiMediaTypeObject, gt as SchemaObject, h as ZodOpenApiLinksObject, ht as ResponsesObject, i as CreateDocumentOptions, it as OpenAPIObject, j as ZodOpenApiMetadata, k as createDocument, kt as ISpecificationExtension, l as ZodOpenApiContentObject, lt as PathItemObject, m as ZodOpenApiLinkObject, mt as ResponseObject, nt as OAuthFlowObject, o as ZodOpenApiCallbackObject, ot as ParameterLocation, p as ZodOpenApiHeadersObject, pt as RequestBodyObject, q as ExternalDocumentationObject, rt as OAuthFlowsObject, s as ZodOpenApiCallbacksObject, st as ParameterObject, t as ComponentRegistry, tt as MediaTypeObject, u as ZodOpenApiExampleObject, ut as PathObject, v as ZodOpenApiOperationObject, vt as SchemasObject, w as ZodOpenApiResponseObject, wt as XmlObject, x as ZodOpenApiPathItemObject, xt as SecuritySchemeObject, y as ZodOpenApiParameterObject, yt as ScopesObject, z as ComponentsObject } from "./components-B8qGeOfG.js";
1
+ import { $ as LinkParametersObject, A as ZodOpenApiBaseMetadata, B as ContactObject, C as ZodOpenApiRequestBodyObject, Ct as TagObject, D as ZodOpenApiSecuritySchemeObject, Dt as IExtensionName, E as ZodOpenApiSchemaObject, Et as ServerVariableObject, F as ZodOpenApiOverrideMetaContext, G as ExampleObject, H as DiscriminatorObject, I as BaseParameterObject, J as HeaderObject, K as ExamplesObject, L as CallbackObject, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, O as ZodOpenApiVersion, Ot as IExtensionType, P as ZodOpenApiOverrideMeta, Q as LinkObject, R as CallbacksObject, S as ZodOpenApiPathsObject, St as SecuritySchemeType, T as ZodOpenApiResponsesObject, Tt as ServerObject, U as EncodingObject, V as ContentObject, W as EncodingPropertyObject, X as InfoObject, Y as HeadersObject, Z as LicenseObject, _ as ZodOpenApiObject, _t as SchemaObjectType, a as ZodObjectInput, at as OperationObject, b as ZodOpenApiParameters, bt as SecurityRequirementObject, c as ZodOpenApiComponentsObject, ct as ParameterStyle, d as ZodOpenApiExamplesObject, dt as PathsObject, et as LinksObject, f as ZodOpenApiHeaderObject, ft as ReferenceObject, g as ZodOpenApiMediaTypeObject, gt as SchemaObject, h as ZodOpenApiLinksObject, ht as ResponsesObject, i as CreateDocumentOptions, it as OpenAPIObject, j as ZodOpenApiMetadata, jt as OpenApiVersion, k as createDocument, kt as ISpecificationExtension, l as ZodOpenApiContentObject, lt as PathItemObject, m as ZodOpenApiLinkObject, mt as ResponseObject, nt as OAuthFlowObject, o as ZodOpenApiCallbackObject, ot as ParameterLocation, p as ZodOpenApiHeadersObject, pt as RequestBodyObject, q as ExternalDocumentationObject, rt as OAuthFlowsObject, s as ZodOpenApiCallbacksObject, st as ParameterObject, t as ComponentRegistry, tt as MediaTypeObject, u as ZodOpenApiExampleObject, ut as PathObject, v as ZodOpenApiOperationObject, vt as SchemasObject, w as ZodOpenApiResponseObject, wt as XmlObject, x as ZodOpenApiPathItemObject, xt as SecuritySchemeObject, y as ZodOpenApiParameterObject, yt as ScopesObject, z as ComponentsObject } from "./components-Bl1eJexW.mjs";
2
2
  import * as core from "zod/v4/core";
3
3
 
4
4
  //#region rolldown:runtime
@@ -1,4 +1,4 @@
1
- import { i as createPaths, n as createRegistry, r as createSchema, t as createComponents } from "./components-CfkaVvOy.js";
1
+ import { i as createPaths, n as createRegistry, r as createSchema, t as createComponents } from "./components-DiNDbisK.mjs";
2
2
 
3
3
  //#region src/create/document.ts
4
4
  const createDocument = (zodOpenApiObject, opts = {}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "5.4.4",
3
+ "version": "5.4.6",
4
4
  "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
5
5
  "keywords": [
6
6
  "typescript",
@@ -25,17 +25,17 @@
25
25
  "type": "module",
26
26
  "exports": {
27
27
  ".": {
28
- "import": "./dist/index.js",
29
- "require": "./dist/index.cjs"
28
+ "require": "./dist/index.cjs",
29
+ "import": "./dist/index.mjs"
30
30
  },
31
31
  "./api": {
32
- "import": "./dist/api.js",
33
- "require": "./dist/api.cjs"
32
+ "require": "./dist/api.cjs",
33
+ "import": "./dist/api.mjs"
34
34
  },
35
35
  "./package.json": "./package.json"
36
36
  },
37
37
  "main": "./dist/index.cjs",
38
- "module": "./dist/index.js",
38
+ "module": "./dist/index.mjs",
39
39
  "types": "./dist/index.d.cts",
40
40
  "files": [
41
41
  "dist",
@@ -43,20 +43,19 @@
43
43
  ],
44
44
  "devDependencies": {
45
45
  "@arethetypeswrong/cli": "0.18.2",
46
- "@changesets/changelog-github": "0.5.1",
47
- "@changesets/cli": "2.29.6",
46
+ "@changesets/changelog-github": "0.5.2",
47
+ "@changesets/cli": "2.29.8",
48
48
  "@redocly/cli": "2.0.8",
49
49
  "@types/node": "22.15.21",
50
50
  "@vitest/coverage-v8": "3.2.4",
51
51
  "@zod-openapi/openapi3-ts": "1.0.0",
52
52
  "ajv": "8.17.1",
53
- "eslint-plugin-import-zod": "1.2.0",
54
53
  "eslint-plugin-zod-openapi": "2.0.0",
55
- "skuba": "12.4.1",
56
- "tsdown": "0.15.6",
54
+ "skuba": "13.1.1",
55
+ "tsdown": "0.18.4",
57
56
  "vitest": "3.2.4",
58
57
  "yaml": "2.8.1",
59
- "zod": "4.1.13"
58
+ "zod": "4.3.5"
60
59
  },
61
60
  "peerDependencies": {
62
61
  "zod": "^3.25.74 || ^4.0.0"
@@ -72,7 +71,7 @@
72
71
  "entryPoint": "src/index.ts",
73
72
  "template": "oss-npm-package",
74
73
  "type": "package",
75
- "version": "12.4.1"
74
+ "version": "13.1.1"
76
75
  },
77
76
  "scripts": {
78
77
  "build": "pnpm -r build && tsdown",
@@ -83,6 +82,7 @@
83
82
  "release": "pnpm build && changeset publish",
84
83
  "test": "vitest run",
85
84
  "test:ci": "vitest run --coverage",
86
- "test:watch": "vitest"
85
+ "test:watch": "vitest",
86
+ "validate:pack": "attw --pack ."
87
87
  }
88
88
  }
@@ -1,11 +0,0 @@
1
- import { A as ZodOpenApiBaseMetadata, F as ZodOpenApiOverrideMetaContext, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, P as ZodOpenApiOverrideMeta, j as ZodOpenApiMetadata, n as createComponents, r as createRegistry, t as ComponentRegistry } from "./components-DkkceUuA.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 };
@@ -1,11 +0,0 @@
1
- import { A as ZodOpenApiBaseMetadata, F as ZodOpenApiOverrideMetaContext, M as ZodOpenApiOverride, N as ZodOpenApiOverrideContext, P as ZodOpenApiOverrideMeta, j as ZodOpenApiMetadata, n as createComponents, r as createRegistry, t as ComponentRegistry } from "./components-B8qGeOfG.js";
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 };