Valibot Plugin Configuration#
The valibot plugin for @hey-api/openapi-ts generates Valibot validation schemas from OpenAPI specifications. Configuration is defined inside the plugins array of the openapi-ts config file. The complete UserConfig interface is the authoritative reference for all options .
Schema Generation: What Gets Generated#
Four top-level options control which schema categories are emitted. All default to true :
| Option | Default | Generated names (default pattern) |
|---|---|---|
definitions | true | v{{name}} (e.g., vPet) |
requests | true | v{{name}}Data + sub-schemas (see below) |
responses | true | v{{name}}Response |
webhooks | true | v{{name}}WebhookRequest |
Each of these accepts three shorthand forms :
- boolean — shorthand for
{ enabled: boolean } - string or function — shorthand for
{ name: string | function } - full object —
{ case?, enabled?, name? }
Requests: Sub-Layer Configuration#
requests has the deepest nesting, with independent configuration for each HTTP request layer :
| Sub-option | Default name pattern |
|---|---|
requests.body | v{{name}}Body |
requests.headers | v{{name}}Headers |
requests.path | v{{name}}Path |
requests.query | v{{name}}Query |
Each sub-option also supports the same boolean | NameTransformer | object shorthand.
shouldExtract#
requests.shouldExtract controls whether the composite request schema is emitted as a named export (vProjectListData) or built inline :
- Default:
false(inline) true: always export as a named schema- Function: per-operation control via
({ operation }) => boolean
Naming Conventions (name)#
The name option on any category accepts :
- A template string using
{{name}}as a placeholder (e.g.,'v{{name}}Response') - A function
(name: string) => stringfor programmatic transformation
Casing (case)#
A top-level case option sets the global default casing for all generated identifiers, with 'camelCase' as the default . Any nested category (e.g., definitions.case, requests.body.case) can override it independently.
Accepted values come from the shared Casing type (e.g., 'camelCase', 'PascalCase', 'snake_case') .
Metadata#
metadata attaches Valibot metadata() actions to generated schemas :
false(default) — no metadata emittedtrue— attaches{ description }from the OpenAPI schema when present- Function — custom builder receiving
{ $, node, schema }; populatenodewith$.literal(…)calls to add arbitrary metadata fields
SDK Integration#
To wire Valibot schemas as runtime validators in a generated SDK, set validator: true on the @hey-api/sdk plugin alongside valibot .
References#
- Official plugin docs
UserConfigTypeScript interface- Resolvers concepts — for further customization beyond config options
- Live examples on StackBlitz