···11+---
22+'@hey-api/codegen-core': patch
33+---
44+55+**types**: document default values for `importKind` and `kind`
+7
.changeset/fruity-camels-type.md
···11+---
22+'@hey-api/openapi-ts': minor
33+---
44+55+**plugin(valibot)**: **BREAKING:** standardize `~resolvers` API
66+77+The [Resolvers API](https://heyapi.dev/openapi-ts/plugins/concepts/resolvers) has been simplified and expanded to provide a more consistent behavior across plugins. You can view a few common examples on the [Resolvers](https://heyapi.dev/openapi-ts/plugins/concepts/resolvers) page.
+7
.changeset/upset-weeks-dream.md
···11+---
22+'@hey-api/openapi-ts': minor
33+---
44+55+**plugin(zod)**: **BREAKING:** standardize `~resolvers` API
66+77+The [Resolvers API](https://heyapi.dev/openapi-ts/plugins/concepts/resolvers) has been simplified and expanded to provide a more consistent behavior across plugins. You can view a few common examples on the [Resolvers](https://heyapi.dev/openapi-ts/plugins/concepts/resolvers) page.
···11---
22title: Clients
33-description: REST clients for Hey API. Compatible with all our features.
33+description: HTTP clients for Hey API. Compatible with all our features.
44---
5566<script setup lang="ts">
77import { embedProject } from '../embed'
88</script>
991010-# REST Clients
1010+# HTTP Clients
11111212We all send HTTP requests in a slightly different way. Hey API doesn't force you to use any specific technology. What we do, however, is support your choice with great clients. All seamlessly integrated with our other features.
1313
+6
docs/openapi-ts/migrating.md
···7788While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features. This page lists changes that require updates to your code. If you run into a problem with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
991010+## v0.90.0
1111+1212+### Resolvers API
1313+1414+The [Resolvers API](/openapi-ts/plugins/concepts/resolvers) has been simplified and expanded to provide a more consistent behavior across plugins. You can view a few common examples on the [Resolvers](/openapi-ts/plugins/concepts/resolvers) page.
1515+1016## v0.89.0
11171218### Prefer named exports
+181
docs/openapi-ts/plugins/concepts/resolvers.md
···11+---
22+title: Resolvers
33+description: Understand the concepts behind plugins.
44+---
55+66+# Resolvers
77+88+Sometimes the default plugin behavior isn't what you need or expect. Resolvers let you patch plugins in a safe and performant way, without forking or reimplementing core logic.
99+1010+Currently available for [Valibot](/openapi-ts/plugins/valibot) and [Zod](/openapi-ts/plugins/zod).
1111+1212+## Examples
1313+1414+This page demonstrates resolvers through a few common scenarios.
1515+1616+1. [Handle arbitrary schema formats](#example-1)
1717+2. [Validate high precision numbers](#example-2)
1818+3. [Replace default base](#example-3)
1919+2020+## Terminology
2121+2222+Before we look at examples, let's go through the resolvers API to help you understand how they work. Plugins that support resolvers expose them through the `~resolvers` option. Each resolver is a function that receives context and returns an implemented node (or patches existing ones).
2323+2424+The resolver context will usually contain:
2525+2626+- `$` - The node builder interface. Use it to build your custom logic.
2727+- `nodes` - Parts of the plugin logic. You can use these to avoid reimplementing the functionality, or replace them with custom implementation.
2828+- `plugin` - The plugin instance. You'll most likely use it to register new symbols.
2929+- `symbols` - Frequently used symbols. These are effectively shorthands for commonly used `plugin.referenceSymbol()` calls.
3030+3131+Other fields may include the current schema or relevant utilities.
3232+3333+## Example 1
3434+3535+### Handle arbitrary schema formats
3636+3737+By default, the Valibot plugin may produce the following schemas for `date` and `date-time` strings.
3838+3939+```js
4040+export const vDates = v.object({
4141+ created: v.pipe(v.string(), v.isoDate()),
4242+ modified: v.pipe(v.string(), v.isoTimestamp()),
4343+});
4444+```
4545+4646+We can override this behavior by patching the `nodes.format` function only for strings with `date` or `date-time` formats.
4747+4848+```js
4949+{
5050+ name: 'valibot',
5151+ '~resolvers': {
5252+ string(ctx) {
5353+ const { $, schema, symbols } = ctx;
5454+ const { v } = symbols;
5555+ if (schema.format === 'date' || schema.format === 'date-time') {
5656+ ctx.nodes.format = () => $(v).attr('isoDateTime').call();
5757+ }
5858+ }
5959+ }
6060+}
6161+```
6262+6363+This applies custom logic with surgical precision, without affecting the rest of the default behavior.
6464+6565+::: code-group
6666+6767+```js [after]
6868+export const vDates = v.object({
6969+ created: v.pipe(v.string(), v.isoDateTime()),
7070+ modified: v.pipe(v.string(), v.isoDateTime()),
7171+});
7272+```
7373+7474+```js [before]
7575+export const vDates = v.object({
7676+ created: v.pipe(v.string(), v.isoDate()),
7777+ modified: v.pipe(v.string(), v.isoTimestamp()),
7878+});
7979+```
8080+8181+:::
8282+8383+## Example 2
8484+8585+### Validate high precision numbers
8686+8787+Let's say you're dealing with very large or unsafe numbers.
8888+8989+```js
9090+export const vAmount = v.number();
9191+```
9292+9393+In this case, you'll want to use a third-party library to validate your values. We can use big.js to validate all numbers by replacing the whole resolver.
9494+9595+```js
9696+{
9797+ name: 'valibot',
9898+ '~resolvers': {
9999+ number(ctx) {
100100+ const { $, plugin, symbols } = ctx;
101101+ const { v } = symbols;
102102+ const big = plugin.symbolOnce('Big', {
103103+ external: 'big.js',
104104+ importKind: 'default',
105105+ });
106106+ return $(v).attr('instance').call(big);
107107+ }
108108+ }
109109+}
110110+```
111111+112112+We're calling `plugin.symbolOnce()` to ensure we always use the same symbol reference.
113113+114114+::: code-group
115115+116116+```js [after]
117117+import Big from 'big.js';
118118+119119+export const vAmount = v.instance(Big);
120120+```
121121+122122+```js [before]
123123+export const vAmount = v.number();
124124+```
125125+126126+:::
127127+128128+## Example 3
129129+130130+### Replace default base
131131+132132+You might want to replace the default base schema, e.g. `v.object()`.
133133+134134+```js
135135+export const vUser = v.object({
136136+ age: v.number(),
137137+});
138138+```
139139+140140+Let's say we want to interpret any schema without explicitly defined additional properties as a loose object.
141141+142142+```js
143143+{
144144+ name: 'valibot',
145145+ '~resolvers': {
146146+ object(ctx) {
147147+ const { $, symbols } = ctx;
148148+ const { v } = symbols;
149149+ const additional = ctx.nodes.additionalProperties(ctx);
150150+ if (additional === undefined) {
151151+ const shape = ctx.nodes.shape(ctx);
152152+ ctx.nodes.base = () => $(v).attr('looseObject').call(shape);
153153+ }
154154+ }
155155+ }
156156+}
157157+```
158158+159159+Above we demonstrate patching a node based on the result of another node.
160160+161161+::: code-group
162162+163163+```js [after]
164164+export const vUser = v.looseObject({
165165+ age: v.number(),
166166+});
167167+```
168168+169169+```js [before]
170170+export const vUser = v.object({
171171+ age: v.number(),
172172+});
173173+```
174174+175175+:::
176176+177177+## Feedback
178178+179179+We welcome feedback on the Resolvers API. [Open a GitHub issue](https://github.com/hey-api/openapi-ts/issues) to request support for additional plugins.
180180+181181+<!--@include: ../../../partials/sponsors.md-->
+4
docs/openapi-ts/plugins/valibot.md
···207207208208:::
209209210210+## Resolvers
211211+212212+You can further customize this plugin's behavior using [resolvers](/openapi-ts/plugins/concepts/resolvers).
213213+210214## API
211215212216You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/valibot/types.d.ts) interface.
+4
docs/openapi-ts/plugins/zod.md
···299299300300You can customize the naming and casing pattern for schema-specific `types` using the `.name` and `.case` options.
301301302302+## Resolvers
303303+304304+You can further customize this plugin's behavior using [resolvers](/openapi-ts/plugins/concepts/resolvers).
305305+302306## API
303307304308You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.d.ts) interface.
+4
docs/openapi-ts/plugins/zod/mini.md
···312312313313You can customize the naming and casing pattern for schema-specific `types` using the `.name` and `.case` options.
314314315315+## Resolvers
316316+317317+You can further customize this plugin's behavior using [resolvers](/openapi-ts/plugins/concepts/resolvers).
318318+315319## API
316320317321You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.d.ts) interface.
+4
docs/openapi-ts/plugins/zod/v3.md
···310310311311You can customize the naming and casing pattern for schema-specific `types` using the `.name` and `.case` options.
312312313313+## Resolvers
314314+315315+You can further customize this plugin's behavior using [resolvers](/openapi-ts/plugins/concepts/resolvers).
316316+313317## API
314318315319You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/zod/types.d.ts) interface.
+4
packages/codegen-core/src/symbols/types.d.ts
···4444 getFilePath?: Symbol['getFilePath'];
4545 /**
4646 * Kind of import if this symbol represents an import.
4747+ *
4848+ * @default 'named'
4749 */
4850 importKind?: BindingKind;
4951 /**
5052 * Kind of symbol.
5353+ *
5454+ * @default 'var'
5155 */
5256 kind?: SymbolKind;
5357 /**
···22import type ts from 'typescript';
3344import type { IR } from '~/ir/types';
55-import type { $ } from '~/ts-dsl';
6576import type { ValibotPlugin } from '../types';
77+import type { Pipes } from './pipes';
8899export type Ast = {
1010 hasLazyExpression?: boolean;
1111- pipes: Array<ReturnType<typeof $.call | typeof $.expr>>;
1111+ pipes: Pipes;
1212 typeName?: string | ts.Identifier;
1313};
1414