You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(zod): document override.zod.version targeting and per-op/tag scoping
Add a "Zod version" section (Zod 4 default baseline, override.zod.version
3 | 4 | 'auto', and the auto->Zod 4 fallback) plus a per-operation/tag
scoping section to the Zod guide, and a `### version` subsection to the
output reference.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Orval generates **Zod 4** output by default (`z.strictObject`, `z.looseObject`, `z.iso.datetime()`, `.meta()`, …). Projects still on Zod 3 are fully supported.
44
+
45
+
With the default (`'auto'`), Orval infers the target from the `zod` version resolved in your project's `package.json`. When no `zod` package can be detected — for example in a fresh or partially-installed workspace — it falls back to **Zod 4**.
46
+
47
+
To make generation deterministic, pin the target with `override.zod.version`:
|`4`| Always emit Zod 4 syntax, regardless of the installed `zod` version. |
73
+
|`3`| Always emit Zod 3-compatible syntax, regardless of the installed `zod` version. |
74
+
|`'auto'`| (default) Infer from the resolved `zod` version; fall back to Zod 4 when none is detected. |
75
+
76
+
Pinning the version keeps output stable: the same spec produces the same schemas on every machine and in CI, independent of which `zod` version happens to be installed.
77
+
78
+
## Scoping options per operation or tag
79
+
80
+
Most `override.zod` settings can be applied to part of your API instead of globally, via `override.operations[operationId].zod` (a single operation) or `override.tags[tagName].zod` (every operation sharing a tag):
81
+
82
+
```ts title="orval.config.ts"
83
+
exportdefaultdefineConfig({
84
+
petstore: {
85
+
output: {
86
+
client: 'zod',
87
+
override: {
88
+
zod: {
89
+
strict: { response: true }, // applies everywhere
90
+
},
91
+
operations: {
92
+
listPets: {
93
+
zod: {
94
+
coerce: { query: ['number'] }, // only this operation
95
+
},
96
+
},
97
+
},
98
+
tags: {
99
+
admin: {
100
+
zod: {
101
+
strict: { body: true }, // every operation tagged "admin"
102
+
},
103
+
},
104
+
},
105
+
},
106
+
},
107
+
},
108
+
});
109
+
```
110
+
111
+
Per-operation and per-tag overrides accept the settings that apply to an individual schema: `strict`, `generate`, `coerce`, `preprocess`, `params`, and `useBrandedTypes`.
112
+
113
+
Output-wide settings — `version`, `dateTimeOptions`, `timeOptions`, `generateEachHttpStatus`, `generateReusableSchemas`, and `generateMeta` — only make sense for the whole output and must stay on `override.zod`. If you place one on an operation or tag it is ignored — the value from `override.zod` still applies — and Orval prints a build warning:
114
+
115
+
```
116
+
⚠️ override.operations.listPets.zod only supports strict, generate, coerce, preprocess, params, and useBrandedTypes. Ignoring unsupported field: zod.version.
|`'auto'`| Infer from the resolved `zod` version; fall back to Zod 4 when none is detected. |
1404
+
1405
+
Unlike most `override.zod` options, `version` is output-wide and cannot be set per operation or tag. See the [Zod guide](/docs/guides/zod#zod-version) for details.
0 commit comments