···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import { type ClientOptions, type Config, createClient, createConfig } from './client';
44+import type { ClientOptions as ClientOptions2 } from './types.gen';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions2>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { Auth, AuthToken } from './auth.gen';
44+import type {
55+ BodySerializer,
66+ QuerySerializer,
77+ QuerySerializerOptions,
88+} from './bodySerializer.gen';
99+1010+export type HttpMethod =
1111+ | 'connect'
1212+ | 'delete'
1313+ | 'get'
1414+ | 'head'
1515+ | 'options'
1616+ | 'patch'
1717+ | 'post'
1818+ | 'put'
1919+ | 'trace';
2020+2121+export type Client<
2222+ RequestFn = never,
2323+ Config = unknown,
2424+ MethodFn = never,
2525+ BuildUrlFn = never,
2626+ SseFn = never,
2727+> = {
2828+ /**
2929+ * Returns the final request URL.
3030+ */
3131+ buildUrl: BuildUrlFn;
3232+ getConfig: () => Config;
3333+ request: RequestFn;
3434+ setConfig: (config: Config) => Config;
3535+} & {
3636+ [K in HttpMethod]: MethodFn;
3737+} & ([SseFn] extends [never]
3838+ ? { sse?: never }
3939+ : { sse: { [K in HttpMethod]: SseFn } });
4040+4141+export interface Config {
4242+ /**
4343+ * Auth token or a function returning auth token. The resolved value will be
4444+ * added to the request payload as defined by its `security` array.
4545+ */
4646+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
4747+ /**
4848+ * A function for serializing request body parameter. By default,
4949+ * {@link JSON.stringify()} will be used.
5050+ */
5151+ bodySerializer?: BodySerializer | null;
5252+ /**
5353+ * An object containing any HTTP headers that you want to pre-populate your
5454+ * `Headers` object with.
5555+ *
5656+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
5757+ */
5858+ headers?:
5959+ | RequestInit['headers']
6060+ | Record<
6161+ string,
6262+ | string
6363+ | number
6464+ | boolean
6565+ | (string | number | boolean)[]
6666+ | null
6767+ | undefined
6868+ | unknown
6969+ >;
7070+ /**
7171+ * The request method.
7272+ *
7373+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
7474+ */
7575+ method?: Uppercase<HttpMethod>;
7676+ /**
7777+ * A function for serializing request query parameters. By default, arrays
7878+ * will be exploded in form style, objects will be exploded in deepObject
7979+ * style, and reserved characters are percent-encoded.
8080+ *
8181+ * This method will have no effect if the native `paramsSerializer()` Axios
8282+ * API function is used.
8383+ *
8484+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
8585+ */
8686+ querySerializer?: QuerySerializer | QuerySerializerOptions;
8787+ /**
8888+ * A function validating request data. This is useful if you want to ensure
8989+ * the request conforms to the desired shape, so it can be safely sent to
9090+ * the server.
9191+ */
9292+ requestValidator?: (data: unknown) => Promise<unknown>;
9393+ /**
9494+ * A function transforming response data before it's returned. This is useful
9595+ * for post-processing data, e.g. converting ISO strings into Date objects.
9696+ */
9797+ responseTransformer?: (data: unknown) => Promise<unknown>;
9898+ /**
9999+ * A function validating response data. This is useful if you want to ensure
100100+ * the response conforms to the desired shape, so it can be safely passed to
101101+ * the transformers and returned to the user.
102102+ */
103103+ responseValidator?: (data: unknown) => Promise<unknown>;
104104+}
105105+106106+type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
107107+ ? true
108108+ : [T] extends [never | undefined]
109109+ ? [undefined] extends [T]
110110+ ? false
111111+ : true
112112+ : false;
113113+114114+export type OmitNever<T extends Record<string, unknown>> = {
115115+ [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true
116116+ ? never
117117+ : K]: T[K];
118118+};
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+export { getBar, getFoo, type Options } from './sdk.gen';
44+export type { ClientOptions, GetBarData, GetBarResponses, GetFooData, GetFooResponses } from './types.gen';
···11-openapi: '3.1.0'
11+openapi: 3.1.0
22info:
33- title: Number Type Min/Max Constraints Test API
44- version: '1.0.0'
55-paths: {}
33+ title: OpenAPI 3.1.0 min max constraints example
44+ version: '1'
65components:
76 schemas:
87 NumberWithMinimum:
···359359360360type Resolvers = Plugin.Resolvers<{
361361 /**
362362+ * Resolvers for number schemas.
363363+ *
364364+ * Allows customization of how number types are rendered, including
365365+ * per-format handling.
366366+ */
367367+ number?: {
368368+ /**
369369+ * Resolvers for number formats (e.g., `float`, `double`, `int32`).
370370+ *
371371+ * Each key represents a specific format name with a custom
372372+ * resolver function that controls how that format is rendered.
373373+ *
374374+ * Example path: `~resolvers.number.formats.float`
375375+ *
376376+ * Returning `undefined` from a resolver will apply the default
377377+ * generation behavior for that format.
378378+ */
379379+ formats?: Record<
380380+ string,
381381+ (args: FormatResolverArgs) => boolean | number | undefined
382382+ >;
383383+ };
384384+ /**
362385 * Resolvers for object schemas.
363386 *
364387 * Allows customization of how object types are rendered.
···783783784784type Resolvers = Plugin.Resolvers<{
785785 /**
786786+ * Resolvers for number schemas.
787787+ *
788788+ * Allows customization of how number types are rendered, including
789789+ * per-format handling.
790790+ */
791791+ number?: {
792792+ /**
793793+ * Resolvers for number formats (e.g., `float`, `double`, `int32`).
794794+ *
795795+ * Each key represents a specific format name with a custom
796796+ * resolver function that controls how that format is rendered.
797797+ *
798798+ * Example path: `~resolvers.number.formats.float`
799799+ *
800800+ * Returning `undefined` from a resolver will apply the default
801801+ * generation behavior for that format.
802802+ */
803803+ formats?: Record<
804804+ string,
805805+ (args: FormatResolverArgs) => boolean | number | undefined
806806+ >;
807807+ };
808808+ /**
786809 * Resolvers for object schemas.
787810 *
788811 * Allows customization of how object types are rendered.
+8-8
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
···55import type { IR } from '~/ir/types';
66import { buildName } from '~/openApi/shared/utils/name';
77import type { SchemaWithType } from '~/plugins';
88+import { maybeBigInt } from '~/plugins/shared/utils/coerce';
89import { $ } from '~/ts-dsl';
910import { pathToJsonPointer, refToName } from '~/utils/ref';
10111112import { identifiers } from '../constants';
1213import { exportAst } from '../shared/export';
1314import { getZodModule } from '../shared/module';
1414-import { numberParameter } from '../shared/numbers';
1515import { irOperationToAst } from '../shared/operation';
1616import type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';
1717import { irWebhookToAst } from '../shared/webhook';
···139139 }
140140141141 if (schema.default !== undefined) {
142142- const isBigInt = schema.type === 'integer' && schema.format === 'int64';
143143- ast.expression = ast.expression.attr(identifiers.default).call(
144144- numberParameter({
145145- isBigInt,
146146- value: schema.default,
147147- }),
148148- );
142142+ ast.expression = ast.expression
143143+ .attr(identifiers.default)
144144+ .call(
145145+ schema.type === 'integer' || schema.type === 'number'
146146+ ? maybeBigInt(schema.default, schema.format)
147147+ : $.fromValue(schema.default),
148148+ );
149149 }
150150 }
151151