zod-openapi 6.0.1 → 6.0.2

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/lib/api.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_components = require("./components-BDEwP6Uu.cjs");
2
+ const require_components = require("./components-Cf1rJmfd.cjs");
3
3
  exports.createComponents = require_components.createComponents;
4
4
  exports.createRegistry = require_components.createRegistry;
5
5
  exports.isAnyZodType = require_components.isAnyZodType;
package/lib/api.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as unwrapZodObject, n as createRegistry, o as isAnyZodType, t as createComponents } from "./components-DgApn4JL.mjs";
1
+ import { a as unwrapZodObject, n as createRegistry, o as isAnyZodType, t as createComponents } from "./components-Dl9_S9V7.mjs";
2
2
  export { createComponents, createRegistry, isAnyZodType, unwrapZodObject };
@@ -23,8 +23,14 @@ const unwrapZodObject = (zodType, io, path) => {
23
23
  }
24
24
  throw new Error(`Failed to unwrap ZodObject from type: ${zodType._zod.def.type} at ${path.join(" > ")}`);
25
25
  };
26
+ const inputOptin = (schema) => {
27
+ const def = schema._zod.def;
28
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
29
+ if (def.type === "catch") return inputOptin(def.innerType);
30
+ return schema._zod.optin;
31
+ };
26
32
  const isRequired = (zodType, io) => {
27
- if (io === "input") return zodType._zod.optin === void 0;
33
+ if (io === "input") return inputOptin(zodType) === void 0;
28
34
  return zodType._zod.optout === void 0;
29
35
  };
30
36
  //#endregion
@@ -23,8 +23,14 @@ const unwrapZodObject = (zodType, io, path) => {
23
23
  }
24
24
  throw new Error(`Failed to unwrap ZodObject from type: ${zodType._zod.def.type} at ${path.join(" > ")}`);
25
25
  };
26
+ const inputOptin = (schema) => {
27
+ const def = schema._zod.def;
28
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
29
+ if (def.type === "catch") return inputOptin(def.innerType);
30
+ return schema._zod.optin;
31
+ };
26
32
  const isRequired = (zodType, io) => {
27
- if (io === "input") return zodType._zod.optin === void 0;
33
+ if (io === "input") return inputOptin(zodType) === void 0;
28
34
  return zodType._zod.optout === void 0;
29
35
  };
30
36
  //#endregion
package/lib/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_components = require("./components-BDEwP6Uu.cjs");
2
+ const require_components = require("./components-Cf1rJmfd.cjs");
3
3
  //#region src/create/document.ts
4
4
  const createDocument = (zodOpenApiObject, opts = {}) => {
5
5
  const { paths, webhooks, components, ...rest } = zodOpenApiObject;
package/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as createPaths, n as createRegistry, r as createSchema, t as createComponents } from "./components-DgApn4JL.mjs";
1
+ import { i as createPaths, n as createRegistry, r as createSchema, t as createComponents } from "./components-Dl9_S9V7.mjs";
2
2
  //#region src/create/document.ts
3
3
  const createDocument = (zodOpenApiObject, opts = {}) => {
4
4
  const { paths, webhooks, components, ...rest } = zodOpenApiObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
5
5
  "keywords": [
6
6
  "typescript",