···178178179179## Metadata
180180181181-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.
181181+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. You can set `metadata` to `true` to attach descriptions to schemas when available.
182182183183::: code-group
184184···200200 {
201201 name: 'valibot',
202202 metadata: true, // [!code ++]
203203+ },
204204+ ],
205205+};
206206+```
207207+208208+:::
209209+210210+For more control over metadata, you can provide your own function. It receives the source `schema`, the target `node` object, and the `$` builder for populating metadata.
211211+212212+::: code-group
213213+214214+```ts [example]
215215+export const vFoo = v.pipe(
216216+ v.string(),
217217+ v.metadata({
218218+ hasTitle: false,
219219+ createdAt: 1735732800000,
220220+ }),
221221+);
222222+```
223223+224224+```js [config]
225225+export default {
226226+ input: 'hey-api/backend', // sign up at app.heyapi.dev
227227+ output: 'src/client',
228228+ plugins: [
229229+ // ...other plugins
230230+ {
231231+ name: 'valibot',
232232+ metadata({ $, node, schema }) {
233233+ // [!code ++]
234234+ node.prop('hasTitle', $.literal(Boolean(schema.title))); // [!code ++]
235235+ node.prop('createdAt', $.literal(Date.now())); // [!code ++]
236236+ }, // [!code ++]
203237 },
204238 ],
205239};
+32-1
docs/openapi-ts/plugins/zod.md
···238238239239## Metadata
240240241241-It's often useful to associate a schema with some additional [metadata](https://zod.dev/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.
241241+It's often useful to associate a schema with some additional [metadata](https://zod.dev/metadata) for documentation, code generation, AI structured outputs, form validation, and other purposes. You can set `metadata` to `true` to attach descriptions to schemas when available.
242242243243::: code-group
244244···257257 {
258258 name: 'zod',
259259 metadata: true, // [!code ++]
260260+ },
261261+ ],
262262+};
263263+```
264264+265265+:::
266266+267267+For more control over metadata, you can provide your own function. It receives the source `schema`, the target `node` object, and the `$` builder for populating metadata.
268268+269269+::: code-group
270270+271271+```ts [example]
272272+export const zFoo = z.string().register(z.globalRegistry, {
273273+ hasTitle: true,
274274+ createdAt: 1735732800000,
275275+});
276276+```
277277+278278+```js [config]
279279+export default {
280280+ input: 'hey-api/backend', // sign up at app.heyapi.dev
281281+ output: 'src/client',
282282+ plugins: [
283283+ // ...other plugins
284284+ {
285285+ name: 'zod',
286286+ metadata({ $, node, schema }) {
287287+ // [!code ++]
288288+ node.prop('hasTitle', $.literal(Boolean(schema.title))); // [!code ++]
289289+ node.prop('createdAt', $.literal(Date.now())); // [!code ++]
290290+ }, // [!code ++]
260291 },
261292 ],
262293};
+33-1
docs/openapi-ts/plugins/zod/mini.md
···249249250250## Metadata
251251252252-It's often useful to associate a schema with some additional [metadata](https://zod.dev/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.
252252+It's often useful to associate a schema with some additional [metadata](https://zod.dev/metadata) for documentation, code generation, AI structured outputs, form validation, and other purposes. You can set `metadata` to `true` to attach descriptions to schemas when available.
253253254254::: code-group
255255···269269 name: 'zod',
270270 compatibilityVersion: 'mini',
271271 metadata: true, // [!code ++]
272272+ },
273273+ ],
274274+};
275275+```
276276+277277+:::
278278+279279+For more control over metadata, you can provide your own function. It receives the source `schema`, the target `node` object, and the `$` builder for populating metadata.
280280+281281+::: code-group
282282+283283+```ts [example]
284284+export const zFoo = z.string().register(z.globalRegistry, {
285285+ hasTitle: true,
286286+ createdAt: 1735732800000,
287287+});
288288+```
289289+290290+```js [config]
291291+export default {
292292+ input: 'hey-api/backend', // sign up at app.heyapi.dev
293293+ output: 'src/client',
294294+ plugins: [
295295+ // ...other plugins
296296+ {
297297+ name: 'zod',
298298+ compatibilityVersion: 'mini',
299299+ metadata({ $, node, schema }) {
300300+ // [!code ++]
301301+ node.prop('hasTitle', $.literal(Boolean(schema.title))); // [!code ++]
302302+ node.prop('createdAt', $.literal(Date.now())); // [!code ++]
303303+ }, // [!code ++]
272304 },
273305 ],
274306};