@kubb/plugin-zod 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/OVERVIEW.md ADDED
@@ -0,0 +1,20 @@
1
+ # Zod
2
+
3
+ Generates Zod v4 schemas from your OpenAPI spec. Use them to validate API responses, form input, and query params at runtime.
4
+
5
+ The schemas can stand on their own. With `inferred: true`, the plugin also exports a `z.infer` type next to each schema, so you can skip `@kubb/plugin-ts`. Client plugins such as `@kubb/plugin-fetch` and `@kubb/plugin-axios` use these schemas when you set their `validator` option.
6
+
7
+ ## Setup
8
+
9
+ Install Zod v4 or higher in the app that uses the generated code. No other plugins are needed.
10
+
11
+ ## Options worth knowing
12
+
13
+ - `mini` generates Zod Mini schemas for smaller bundles, and switches `importPath` to `zod/mini`.
14
+ - `importPath` sets the module the files import `z` from. The default is `zod`.
15
+ - `inferred` exports a `z.infer` type alias next to each schema.
16
+ - `coercion` wraps schemas in `z.coerce`, so input is converted before validation. Pass an object to coerce only dates, strings, or numbers.
17
+ - `guidType` picks `z.uuid()` (default) or `z.guid()` for `format: uuid`.
18
+ - `regexType` writes a `pattern` as a regex literal (default) or a `RegExp` constructor.
19
+ - `typeGuards` adds `is*` type guards and `assert*` assertions.
20
+ - `compile` wraps schemas in `z.compile` for faster validation.
package/dist/index.cjs CHANGED
@@ -2229,6 +2229,15 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
2229
2229
  }
2230
2230
  });
2231
2231
  //#endregion
2232
+ //#region kubb-extension.json
2233
+ var compatibility = {
2234
+ "kubb": ">=5.8.0",
2235
+ "node": ">=22"
2236
+ };
2237
+ //#endregion
2238
+ //#region package.json
2239
+ var version = "5.4.6";
2240
+ //#endregion
2232
2241
  //#region src/resolvers/resolverZod.ts
2233
2242
  /**
2234
2243
  * Default resolver used by `@kubb/plugin-zod`. Decides the names and file
@@ -2315,37 +2324,37 @@ const pluginZodName = "plugin-zod";
2315
2324
  * })
2316
2325
  * ```
2317
2326
  */
2318
- const pluginZod = (0, kubb_kit.definePlugin)((options) => {
2319
- const { output = {
2320
- path: "zod",
2321
- barrel: { type: "named" }
2322
- }, group, exclude = [], include, override = [], compile = false, mini = false, guidType = "uuid", regexType = "literal", importPath = mini ? "zod/mini" : "zod", coercion = false, inferred = false, typeGuards = false, printer, resolver: userResolver, macros: userMacros } = options;
2323
- const groupConfig = createGroupConfig(group);
2324
- return {
2327
+ const pluginZod = (0, kubb_kit.definePlugin)({
2328
+ meta: {
2325
2329
  name: pluginZodName,
2326
- options,
2327
- hooks: { "kubb:plugin:setup"(ctx) {
2328
- ctx.setOptions({
2329
- output,
2330
- exclude,
2331
- include,
2332
- override,
2333
- group: groupConfig,
2334
- importPath,
2335
- coercion,
2336
- inferred,
2337
- guidType,
2338
- regexType,
2339
- compile,
2340
- mini,
2341
- typeGuards,
2342
- printer
2343
- });
2344
- ctx.setResolver(userResolver ? kubb_kit.Resolver.merge(resolverZod, userResolver) : resolverZod);
2345
- if (userMacros?.length) ctx.setMacros(userMacros);
2346
- ctx.addGenerator(zodGenerator);
2347
- } }
2348
- };
2330
+ version,
2331
+ compatibility
2332
+ },
2333
+ setup(options) {
2334
+ const { output = {
2335
+ path: "zod",
2336
+ barrel: { type: "named" }
2337
+ }, group, exclude = [], include, override = [], compile = false, mini = false, guidType = "uuid", regexType = "literal", importPath = mini ? "zod/mini" : "zod", coercion = false, inferred = false, typeGuards = false, printer, resolver: userResolver, macros: userMacros } = options;
2338
+ (0, kubb_kit.setResolver)(userResolver ? kubb_kit.Resolver.merge(resolverZod, userResolver) : resolverZod);
2339
+ if (userMacros?.length) (0, kubb_kit.setMacros)(userMacros);
2340
+ (0, kubb_kit.addGenerator)(zodGenerator);
2341
+ return {
2342
+ output,
2343
+ exclude,
2344
+ include,
2345
+ override,
2346
+ group: createGroupConfig(group),
2347
+ importPath,
2348
+ coercion,
2349
+ inferred,
2350
+ guidType,
2351
+ regexType,
2352
+ compile,
2353
+ mini,
2354
+ typeGuards,
2355
+ printer
2356
+ };
2357
+ }
2349
2358
  });
2350
2359
  //#endregion
2351
2360
  exports.default = pluginZod;