@kubb/plugin-zod 5.7.0-canary.20261024T190548 → 5.7.0
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 +18 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/docs/options.md +31 -7
- package/package.json +3 -3
package/docs/options.md
CHANGED
|
@@ -9,7 +9,7 @@ Pass these options to `pluginZod()`. Shared options link to [Shared plugin optio
|
|
|
9
9
|
| [`output`](https://kubb.dev/docs/5.x/reference/plugin-options#output) | Where files are written: `path`, `mode`, `barrel`, `banner`, `footer`. | `{ path: 'zod', barrel: { type: 'named' } }` |
|
|
10
10
|
| [`group`](https://kubb.dev/docs/5.x/reference/plugin-options#group) | Split output by tag or path: `type`, `name`. | None |
|
|
11
11
|
| [`importPath`](#importpath) | Module the generated files import `z` from. | `'zod'`, or `'zod/mini'` with `mini` |
|
|
12
|
-
| [`inferred`](#inferred) | Emit a `z.infer` alias next to each schema.
|
|
12
|
+
| [`inferred`](#inferred) | Emit a `z.infer` (or `z.input`/`z.output`) alias next to each schema. | `false` |
|
|
13
13
|
| [`coercion`](#coercion) | Coerce input before validation. | `false` |
|
|
14
14
|
| [`guidType`](#guidtype) | Validator for `format: uuid` properties. | `'uuid'` |
|
|
15
15
|
| [`regexType`](#regextype) | How an OpenAPI `pattern` is written. | `'literal'` |
|
|
@@ -40,18 +40,42 @@ Module the generated files import `z` from. Point it at your own module to re-ex
|
|
|
40
40
|
|
|
41
41
|
### inferred
|
|
42
42
|
|
|
43
|
-
Exports a
|
|
43
|
+
Exports a type alias next to each schema, so you do not need `@kubb/plugin-ts`. The type takes the PascalCase schema name plus `SchemaType`, so `petSchema` gets `PetSchemaType`.
|
|
44
44
|
|
|
45
|
-
| |
|
|
46
|
-
| -------- |
|
|
47
|
-
| Type | `boolean` |
|
|
48
|
-
| Required | `false`
|
|
49
|
-
| Default | `false`
|
|
45
|
+
| | |
|
|
46
|
+
| -------- | ------------------------ |
|
|
47
|
+
| Type | `boolean \| 'direction'` |
|
|
48
|
+
| Required | `false` |
|
|
49
|
+
| Default | `false` |
|
|
50
|
+
|
|
51
|
+
::field-group
|
|
52
|
+
|
|
53
|
+
:::field{name="false"}
|
|
54
|
+
Default value. Emits no type aliases.
|
|
55
|
+
:::
|
|
56
|
+
|
|
57
|
+
:::field{name="true"}
|
|
58
|
+
Emits `z.infer<typeof schema>` for every schema.
|
|
59
|
+
:::
|
|
60
|
+
|
|
61
|
+
:::field{name="'direction'"}
|
|
62
|
+
Emits `z.input<typeof schema>` for request schemas (bodies and params) and `z.output<typeof schema>` for response schemas. Use it with codecs, where a request takes the domain value (a `Date`) that the schema encodes and a response returns the decoded value.
|
|
63
|
+
:::
|
|
64
|
+
|
|
65
|
+
::
|
|
50
66
|
|
|
51
67
|
```typescript
|
|
52
68
|
export type PetSchemaType = z.infer<typeof petSchema>
|
|
53
69
|
```
|
|
54
70
|
|
|
71
|
+
With `'direction'`, request types read the schema's input:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
export type PutEventBodySchemaType = z.input<typeof putEventBodySchema>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pair `'direction'` with `validator: { request: 'zod', params: 'zod' }` in [`@kubb/plugin-fetch`](https://kubb.dev/extensions/kubb-labs/plugin-fetch/options#validator) or [`@kubb/plugin-axios`](https://kubb.dev/extensions/kubb-labs/plugin-axios/options#validator). Without request validation, the client sends the domain value unencoded.
|
|
78
|
+
|
|
55
79
|
It also writes a `ResponsesSchema` for each operation (one schema per status code) and its inferred type. [`@kubb/plugin-fetch`](https://kubb.dev/extensions/kubb-labs/plugin-fetch) and [`@kubb/plugin-axios`](https://kubb.dev/extensions/kubb-labs/plugin-axios) key their `RequestResult` on it when `@kubb/plugin-ts` is absent.
|
|
56
80
|
|
|
57
81
|
### coercion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "5.7.0
|
|
3
|
+
"version": "5.7.0",
|
|
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",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"registry": "https://registry.npmjs.org/"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@internals/shared": "0.
|
|
73
|
-
"@internals/utils": "0.
|
|
72
|
+
"@internals/shared": "0.0.0",
|
|
73
|
+
"@internals/utils": "0.0.0",
|
|
74
74
|
"kubb": "^5.13.0",
|
|
75
75
|
"zod": "^4.6.7"
|
|
76
76
|
},
|