@kubb/plugin-zod 5.9.0-canary.20261111T122006 → 5.9.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 +760 -806
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +761 -807
- package/dist/index.js.map +1 -1
- package/docs/guides/customization.md +31 -23
- package/docs/options.md +2 -1
- package/kubb-extension.json +1 -1
- package/package.json +5 -5
|
@@ -115,29 +115,37 @@ Generated files import `myCodec` from `my-codec/zod`. Leave `root` unset on this
|
|
|
115
115
|
|
|
116
116
|
`@kubb/plugin-zod` maps OpenAPI types and formats to Zod v4:
|
|
117
117
|
|
|
118
|
-
| OpenAPI type and format
|
|
119
|
-
|
|
|
120
|
-
| `integer`
|
|
121
|
-
| `integer`, `format: int32`
|
|
122
|
-
| `integer`, `format: uint32`
|
|
123
|
-
| `integer`, `format: int64`
|
|
124
|
-
| `string`, `format: byte` / `base64`
|
|
125
|
-
| `string`, `format: base64url`
|
|
126
|
-
| `string`, `
|
|
127
|
-
| `string`, `
|
|
128
|
-
| `string`, `format:
|
|
129
|
-
| `string`, `format:
|
|
130
|
-
| `string`, `format:
|
|
131
|
-
| `string`, `format:
|
|
132
|
-
| `string`, `format:
|
|
133
|
-
| `string`, `format:
|
|
134
|
-
| `string`, `format:
|
|
135
|
-
| `string`, `format:
|
|
136
|
-
| `string`, `format:
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
139
|
-
| `object`, `
|
|
140
|
-
| `object`, `
|
|
118
|
+
| OpenAPI type and format | Zod | Zod Mini | Notes |
|
|
119
|
+
| :----------------------------------------------------- | :------------------------------------ | :------------------------------------ | :------------------------------------------------------------------------------ |
|
|
120
|
+
| `integer` | `z.int()` | `z.int()` | Coerces to `z.coerce.number().int()` when `coercion.numbers` is enabled |
|
|
121
|
+
| `integer`, `format: int32` | `z.int32()` | `z.int32()` | 32-bit signed integer |
|
|
122
|
+
| `integer`, `format: uint32` | `z.uint32()` | `z.uint32()` | 32-bit unsigned integer |
|
|
123
|
+
| `integer`, `format: int64` | `z.bigint()` | `z.bigint()` | 64-bit integer |
|
|
124
|
+
| `string`, `format: byte` / `base64` | `z.base64()` | `z.base64()` | Base64 string validation |
|
|
125
|
+
| `string`, `format: base64url` | `z.base64url()` | `z.base64url()` | URL-safe base64 string validation |
|
|
126
|
+
| `string`, `contentEncoding: base64` / `base64url` | `z.base64()` / `z.base64url()` | `z.base64()` / `z.base64url()` | Same checks as the formats. Other encodings stay `z.string()` |
|
|
127
|
+
| `string`, JSON `contentMediaType` with `contentSchema` | `z.string().refine(...)` | `z.string().check(z.refine(...))` | The string must parse as JSON that passes the content schema. It stays a string |
|
|
128
|
+
| `string`, `format: jwt` | `z.jwt()` | `z.jwt()` | JSON Web Token format |
|
|
129
|
+
| `string`, `format: ulid` | `z.ulid()` | `z.ulid()` | ULID format |
|
|
130
|
+
| `string`, `format: iban` | `z.iban()` | `z.iban()` | International Bank Account Number |
|
|
131
|
+
| `string`, `format: duration` | `z.iso.duration()` | `z.iso.duration()` | ISO 8601 duration format |
|
|
132
|
+
| `string`, `format: uuid` | `z.uuid()` (or `z.guid()`) | `z.uuid()` (or `z.guid()`) | Configured via `guidType` |
|
|
133
|
+
| `string`, `format: email` | `z.email()` | `z.email()` | Email format |
|
|
134
|
+
| `string`, `format: uri` / `url` | `z.url()` | `z.url()` | URL format |
|
|
135
|
+
| `string`, `format: ipv4` / `ipv6` | `z.ipv4()` / `z.ipv6()` | `z.ipv4()` / `z.ipv6()` | IP address format |
|
|
136
|
+
| `string`, `format: date` | `z.iso.date()` | `z.iso.date()` | ISO 8601 date |
|
|
137
|
+
| `string`, `format: date-time` | `z.iso.datetime()` | `z.string()` | ISO 8601 date-time |
|
|
138
|
+
| `string`, `format: time` | `z.iso.time()` | `z.iso.time()` | ISO 8601 time |
|
|
139
|
+
| `object`, `additionalProperties: <schema>` | `z.record(z.string(), schema)` | `z.record(z.string(), schema)` | Dictionary with no fixed properties |
|
|
140
|
+
| `object`, `additionalProperties: true` | `z.looseObject(shape)` | `z.looseObject(shape)` | Open/passthrough object allowing extra keys |
|
|
141
|
+
| `object`, `propertyNames: <schema>` | `z.record(keySchema, schema)` | `z.record(keySchema, schema)` | Dynamic map with validated key schema (e.g. pattern, format) |
|
|
142
|
+
| `object`, `propertyNames: <enum>` | `z.partialRecord(enumSchema, schema)` | `z.partialRecord(enumSchema, schema)` | Enum keys may be missing |
|
|
143
|
+
|
|
144
|
+
These keywords print a `z.refine` check, in both APIs:
|
|
145
|
+
|
|
146
|
+
- `if`/`then`/`else`, `dependentRequired`, and `dependentSchemas` check the input before it is parsed, in `z.pipe(z.unknown().check(...), schema)`.
|
|
147
|
+
- `contains` with `minContains` and `maxContains` counts the matching items of an array.
|
|
148
|
+
- `propertyNames` on an object that also declares `properties` checks every key of the input. A dictionary keeps `z.record(keySchema, schema)`.
|
|
141
149
|
|
|
142
150
|
## Dictionaries, open objects, and key schemas
|
|
143
151
|
|
package/docs/options.md
CHANGED
|
@@ -175,7 +175,7 @@ Emits `z.xor([...])`, which passes only when exactly one member matches, as `one
|
|
|
175
175
|
|
|
176
176
|
::
|
|
177
177
|
|
|
178
|
-
A `oneOf` with a discriminator, where every member is an object, prints `z.discriminatedUnion(...)` with either value. An `anyOf` always prints `z.union(...)`.
|
|
178
|
+
A `oneOf` with a discriminator, where every member is an object, prints `z.discriminatedUnion(...)` with either value, and its members keep extra keys the spec allows. An `anyOf` always prints `z.union(...)`.
|
|
179
179
|
|
|
180
180
|
### compile
|
|
181
181
|
|
|
@@ -287,6 +287,7 @@ type ResolverZodPatch = {
|
|
|
287
287
|
}
|
|
288
288
|
response?: {
|
|
289
289
|
status?(node: OperationNode, statusCode: StatusCode): string
|
|
290
|
+
headers?(node: OperationNode, statusCode: StatusCode): string
|
|
290
291
|
body?(node: OperationNode): string
|
|
291
292
|
responses?(node: OperationNode): string
|
|
292
293
|
response?(node: OperationNode): string
|
package/kubb-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "5.9.0
|
|
3
|
+
"version": "5.9.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,12 +69,12 @@
|
|
|
69
69
|
"registry": "https://registry.npmjs.org/"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@kubb/kit": "^5.18.
|
|
73
|
-
"@kubb/renderer-jsx": "^5.18.
|
|
72
|
+
"@kubb/kit": "^5.18.6",
|
|
73
|
+
"@kubb/renderer-jsx": "^5.18.6"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@internals/shared": "0.
|
|
77
|
-
"@internals/utils": "0.
|
|
76
|
+
"@internals/shared": "0.0.0",
|
|
77
|
+
"@internals/utils": "0.0.0",
|
|
78
78
|
"zod": "^4.6.7"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|