@kubb/plugin-zod 5.4.7 → 5.4.8
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/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/docs/overview.md +12 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/docs/overview.md
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
# Zod
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Zod plugin generates a Zod v4 schema for every schema in your OpenAPI spec.
|
|
4
4
|
|
|
5
|
-
The
|
|
5
|
+
The client plugins `@kubb/plugin-fetch`, `@kubb/plugin-axios`, and `@kubb/plugin-client` use these schemas when you set their `validator` option.
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- No other plugins are needed.
|
|
10
|
+
- Install `zod` v4 in the app that uses the generated code. `compile` needs 4.5 or later, and `typeGuards` needs 4.6 or later.
|
|
10
11
|
|
|
11
12
|
## Options worth knowing
|
|
12
13
|
|
|
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`
|
|
14
|
+
- `mini` (beta) generates Zod Mini schemas for smaller bundles, and switches `importPath` to `zod/mini`.
|
|
15
|
+
- `importPath` sets the module the generated files import `z` from. The default is `zod`.
|
|
16
|
+
- `inferred` adds a `z.infer` type next to each schema, so you can skip `@kubb/plugin-ts`.
|
|
16
17
|
- `coercion` wraps schemas in `z.coerce`, so input is converted before validation. Pass an object to coerce only dates, strings, or numbers.
|
|
17
18
|
- `guidType` picks `z.uuid()` (default) or `z.guid()` for `format: uuid`.
|
|
18
19
|
- `regexType` writes a `pattern` as a regex literal (default) or a `RegExp` constructor.
|
|
19
20
|
- `typeGuards` adds `is*` type guards and `assert*` assertions.
|
|
20
|
-
- `compile` wraps schemas in `z.compile` for faster validation.
|
|
21
|
+
- `compile` wraps schemas in `z.compile` for faster validation. Circular schemas are left as they are.
|
|
22
|
+
|
|
23
|
+
See [Options](https://kubb.dev/extensions/kubb-labs/plugin-zod/options) for every option and its default.
|
|
21
24
|
|
|
22
25
|
## Example
|
|
23
26
|
|
|
27
|
+
The config below generates the schemas with a `z.infer` type next to each one.
|
|
28
|
+
|
|
24
29
|
```typescript [kubb.config.ts]
|
|
25
30
|
import { defineConfig } from 'kubb/config'
|
|
26
31
|
import { pluginZod } from '@kubb/plugin-zod'
|
|
@@ -33,8 +38,3 @@ export default defineConfig({
|
|
|
33
38
|
],
|
|
34
39
|
})
|
|
35
40
|
```
|
|
36
|
-
|
|
37
|
-
## See also
|
|
38
|
-
|
|
39
|
-
- [Zod](https://zod.dev/)
|
|
40
|
-
- [Zod Mini](https://zod.dev/packages/mini)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.8",
|
|
4
4
|
"description": "Generate Zod validation schemas with Kubb for runtime data parsing and type safety. Pairs with @kubb/plugin-ts for end-to-end type coverage.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generation",
|