···11+---
22+'@hey-api/openapi-ts': minor
33+---
44+55+feat(valibot): generate a single schema for requests
66+77+### Single Valibot schema per request
88+99+Previously, we generated a separate schema for each endpoint parameter and request body. In v0.76.0, a single request schema is generated for the whole endpoint. It may contain a request body, parameters, and headers.
1010+1111+```ts
1212+const vData = v.object({
1313+ body: v.optional(v.object({
1414+ foo: v.optional(v.string()),
1515+ bar: v.optional(v.union([v.number(), v.null()])),
1616+ })),
1717+ headers: v.optional(v.never()),
1818+ path: v.object({
1919+ baz: v.string(),
2020+ }),
2121+ query: v.optional(v.never()),
2222+});
2323+```
2424+2525+If you need to access individual fields, you can do so using the [`.entries`](https://valibot.dev/api/object/) API. For example, we can get the request body schema with `vData.entries.body`.
+5
.changeset/six-birds-peel.md
···11+---
22+'@hey-api/openapi-ts': patch
33+---
44+55+fix(valibot): add `metadata` option to generate additional metadata for documentation, code generation, AI structured outputs, form validation, and other purposes
+24
docs/openapi-ts/migrating.md
···27272828This config option is deprecated and will be removed.
29293030+## v0.76.0
3131+3232+### Single Valibot schema per request
3333+3434+Previously, we generated a separate schema for each endpoint parameter and request body. In v0.76.0, a single request schema is generated for the whole endpoint. It may contain a request body, parameters, and headers.
3535+3636+```ts
3737+const vData = v.object({
3838+ body: v.optional(
3939+ v.object({
4040+ foo: v.optional(v.string()),
4141+ bar: v.optional(v.union([v.number(), v.null()])),
4242+ }),
4343+ ),
4444+ headers: v.optional(v.never()),
4545+ path: v.object({
4646+ baz: v.string(),
4747+ }),
4848+ query: v.optional(v.never()),
4949+});
5050+```
5151+5252+If you need to access individual fields, you can do so using the [`.entries`](https://valibot.dev/api/object/) API. For example, we can get the request body schema with `vData.entries.body`.
5353+3054## v0.75.0
31553256### Updated TanStack Query options
+51-28
docs/openapi-ts/plugins/valibot.md
···2626## Features
27272828- seamless integration with `@hey-api/openapi-ts` ecosystem
2929-- Valibot schemas for request payloads, parameters, and responses
2929+- Valibot schemas for requests, responses, and reusable definitions
30303131## Installation
32323333In your [configuration](/openapi-ts/get-started), add `valibot` to your plugins and you'll be ready to generate Valibot artifacts. :tada:
34343535```js
3636-import { defaultPlugins } from '@hey-api/openapi-ts';
3737-3836export default {
3937 input: 'https://get.heyapi.dev/hey-api/backend',
4038 output: 'src/client',
4139 plugins: [
4242- ...defaultPlugins,
4040+ // ...other plugins
4341 'valibot', // [!code ++]
4442 ],
4543};
···5048To automatically validate response data in your SDKs, set `sdk.validator` to `true`.
51495250```js
5353-import { defaultPlugins } from '@hey-api/openapi-ts';
5454-5551export default {
5652 input: 'https://get.heyapi.dev/hey-api/backend',
5753 output: 'src/client',
5854 plugins: [
5959- ...defaultPlugins,
5555+ // ...other plugins
6056 'valibot',
6157 {
6258 name: '@hey-api/sdk', // [!code ++]
···70667167The Valibot plugin will generate the following artifacts, depending on the input specification.
72686969+## Requests
7070+7171+A single request schema is generated for each endpoint. It may contain a request body, parameters, and headers.
7272+7373+```ts
7474+const vData = v.object({
7575+ body: v.optional(
7676+ v.object({
7777+ foo: v.optional(v.string()),
7878+ bar: v.optional(v.union([v.number(), v.null()])),
7979+ }),
8080+ ),
8181+ headers: v.optional(v.never()),
8282+ path: v.object({
8383+ baz: v.string(),
8484+ }),
8585+ query: v.optional(v.never()),
8686+});
8787+```
8888+8989+::: tip
9090+If you need to access individual fields, you can do so using the [`.entries`](https://valibot.dev/api/object/) API. For example, we can get the request body schema with `vData.entries.body`.
9191+:::
9292+9393+You can customize the naming and casing pattern for requests using the `requests.name` and `requests.case` options.
9494+7395## Responses
74967597A single Valibot schema is generated for all endpoint's responses. If the endpoint describes multiple responses, the generated schema is a union of all possible response shapes.
···85107]);
86108```
871098888-## Request Bodies
110110+You can customize the naming and casing pattern for responses using the `responses.name` and `responses.case` options.
891119090-If an endpoint describes a request body, we will generate a Valibot schema representing its shape.
112112+## Definitions
911139292-```ts
9393-const vData = v.object({
9494- foo: v.optional(v.string()),
9595- bar: v.optional(v.union([v.number(), v.null()])),
9696-});
9797-```
9898-9999-## Parameters
100100-101101-A separate Valibot schema is generated for every request parameter.
114114+A Valibot schema is generated for every reusable definition from your input.
102115103116```ts
104104-const vParameterFoo = v.pipe(v.number(), v.integer());
117117+const vFoo = v.pipe(v.number(), v.integer());
105118106106-const vParameterBar = v.string();
119119+const vBar = v.object({
120120+ bar: v.optional(v.array(v.pipe(v.number(), v.integer()))),
121121+});
107122```
108123109109-## Schemas
124124+You can customize the naming and casing pattern for definitions using the `definitions.name` and `definitions.case` options.
110125111111-A separate Valibot schema is generated for every reusable schema.
126126+## Metadata
112127113113-```ts
114114-const vFoo = v.pipe(v.number(), v.integer());
128128+It's often useful to associate a schema with some additional [metadata](https://valibot.dev/api/metadata/) for documentation, code generation, AI structured outputs, form validation, and other purposes. If this is your use case, you can set `metadata` to `true` to generate additional metadata about schemas.
115129116116-const vBar = v.object({
117117- bar: v.optional(v.union([v.array(v.unknown()), v.null()])),
118118-});
130130+```js
131131+export default {
132132+ input: 'https://get.heyapi.dev/hey-api/backend',
133133+ output: 'src/client',
134134+ plugins: [
135135+ // ...other plugins
136136+ {
137137+ metadata: true, // [!code ++]
138138+ name: 'valibot',
139139+ },
140140+ ],
141141+};
119142```
120143121144<!--@include: ../../examples.md-->