fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #3506 from hey-api/docs/zod-valibot-metadata

docs: expand metadata section for zod and valibot

authored by

Lubos and committed by
GitHub
c6e182f0 5eb29966

+100 -3
+35 -1
docs/openapi-ts/plugins/valibot.md
··· 178 178 179 179 ## Metadata 180 180 181 - 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. 181 + 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. 182 182 183 183 ::: code-group 184 184 ··· 200 200 { 201 201 name: 'valibot', 202 202 metadata: true, // [!code ++] 203 + }, 204 + ], 205 + }; 206 + ``` 207 + 208 + ::: 209 + 210 + 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. 211 + 212 + ::: code-group 213 + 214 + ```ts [example] 215 + export const vFoo = v.pipe( 216 + v.string(), 217 + v.metadata({ 218 + hasTitle: false, 219 + createdAt: 1735732800000, 220 + }), 221 + ); 222 + ``` 223 + 224 + ```js [config] 225 + export default { 226 + input: 'hey-api/backend', // sign up at app.heyapi.dev 227 + output: 'src/client', 228 + plugins: [ 229 + // ...other plugins 230 + { 231 + name: 'valibot', 232 + metadata({ $, node, schema }) { 233 + // [!code ++] 234 + node.prop('hasTitle', $.literal(Boolean(schema.title))); // [!code ++] 235 + node.prop('createdAt', $.literal(Date.now())); // [!code ++] 236 + }, // [!code ++] 203 237 }, 204 238 ], 205 239 };
+32 -1
docs/openapi-ts/plugins/zod.md
··· 238 238 239 239 ## Metadata 240 240 241 - 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. 241 + 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. 242 242 243 243 ::: code-group 244 244 ··· 257 257 { 258 258 name: 'zod', 259 259 metadata: true, // [!code ++] 260 + }, 261 + ], 262 + }; 263 + ``` 264 + 265 + ::: 266 + 267 + 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. 268 + 269 + ::: code-group 270 + 271 + ```ts [example] 272 + export const zFoo = z.string().register(z.globalRegistry, { 273 + hasTitle: true, 274 + createdAt: 1735732800000, 275 + }); 276 + ``` 277 + 278 + ```js [config] 279 + export default { 280 + input: 'hey-api/backend', // sign up at app.heyapi.dev 281 + output: 'src/client', 282 + plugins: [ 283 + // ...other plugins 284 + { 285 + name: 'zod', 286 + metadata({ $, node, schema }) { 287 + // [!code ++] 288 + node.prop('hasTitle', $.literal(Boolean(schema.title))); // [!code ++] 289 + node.prop('createdAt', $.literal(Date.now())); // [!code ++] 290 + }, // [!code ++] 260 291 }, 261 292 ], 262 293 };
+33 -1
docs/openapi-ts/plugins/zod/mini.md
··· 249 249 250 250 ## Metadata 251 251 252 - 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. 252 + 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. 253 253 254 254 ::: code-group 255 255 ··· 269 269 name: 'zod', 270 270 compatibilityVersion: 'mini', 271 271 metadata: true, // [!code ++] 272 + }, 273 + ], 274 + }; 275 + ``` 276 + 277 + ::: 278 + 279 + 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. 280 + 281 + ::: code-group 282 + 283 + ```ts [example] 284 + export const zFoo = z.string().register(z.globalRegistry, { 285 + hasTitle: true, 286 + createdAt: 1735732800000, 287 + }); 288 + ``` 289 + 290 + ```js [config] 291 + export default { 292 + input: 'hey-api/backend', // sign up at app.heyapi.dev 293 + output: 'src/client', 294 + plugins: [ 295 + // ...other plugins 296 + { 297 + name: 'zod', 298 + compatibilityVersion: 'mini', 299 + metadata({ $, node, schema }) { 300 + // [!code ++] 301 + node.prop('hasTitle', $.literal(Boolean(schema.title))); // [!code ++] 302 + node.prop('createdAt', $.literal(Date.now())); // [!code ++] 303 + }, // [!code ++] 272 304 }, 273 305 ], 274 306 };