+5
.changeset/fuzzy-taxes-cheer.md
+5
.changeset/fuzzy-taxes-cheer.md
+6
-6
dev/openapi-ts.config.ts
+6
-6
dev/openapi-ts.config.ts
···
38
38
// },
39
39
path: path.resolve(
40
40
getSpecsPath(),
41
-
'3.0.x',
42
-
// '3.1.x',
41
+
// '3.0.x',
42
+
'3.1.x',
43
43
// 'circular.yaml',
44
44
// 'dutchie.json',
45
45
// 'enum-names-values.yaml',
46
46
// 'full.yaml',
47
-
// 'integer-formats.yaml',
47
+
'integer-formats.yaml',
48
48
// 'invalid',
49
49
// 'object-property-names.yaml',
50
50
// 'openai.yaml',
···
52
52
// 'pagination-ref.yaml',
53
53
// 'schema-const.yaml',
54
54
// 'sdk-instance.yaml',
55
-
'sdk-method-class-conflict.yaml',
55
+
// 'sdk-method-class-conflict.yaml',
56
56
// 'sdk-nested-classes.yaml',
57
57
// 'sdk-nested-conflict.yaml',
58
58
// 'string-with-format.yaml',
···
397
397
definitions: 'z{{name}}',
398
398
exportFromIndex: true,
399
399
// metadata: true,
400
-
// name: 'valibot',
400
+
name: 'valibot',
401
401
// requests: {
402
402
// case: 'PascalCase',
403
403
// name: '{{name}}Data',
···
467
467
{
468
468
// case: 'snake_case',
469
469
// comments: false,
470
-
compatibilityVersion: 4,
470
+
compatibilityVersion: 3,
471
471
dates: {
472
472
// local: true,
473
473
// offset: true,
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/angular-query-experimental.gen.ts
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/angular-query-experimental.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { type DefaultError, queryOptions } from '@tanstack/angular-query-experimental';
4
+
5
+
import { client } from '../client.gen';
6
+
import { getBar, getFoo, type Options } from '../sdk.gen';
7
+
import type { GetBarData, GetFooData } from '../types.gen';
8
+
9
+
export type QueryKey<TOptions extends Options> = [
10
+
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
11
+
_id: string;
12
+
_infinite?: boolean;
13
+
tags?: ReadonlyArray<string>;
14
+
}
15
+
];
16
+
17
+
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
18
+
QueryKey<TOptions>[0]
19
+
] => {
20
+
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
21
+
if (infinite) {
22
+
params._infinite = infinite;
23
+
}
24
+
if (tags) {
25
+
params.tags = tags;
26
+
}
27
+
if (options?.body) {
28
+
params.body = options.body;
29
+
}
30
+
if (options?.headers) {
31
+
params.headers = options.headers;
32
+
}
33
+
if (options?.path) {
34
+
params.path = options.path;
35
+
}
36
+
if (options?.query) {
37
+
params.query = options.query;
38
+
}
39
+
return [params];
40
+
};
41
+
42
+
export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options);
43
+
44
+
export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({
45
+
queryFn: async ({ queryKey, signal }) => {
46
+
const { data } = await getFoo({
47
+
...options,
48
+
...queryKey[0],
49
+
signal,
50
+
throwOnError: true
51
+
});
52
+
return data;
53
+
},
54
+
queryKey: getFooQueryKey(options),
55
+
meta: {
56
+
id: 'getFoo',
57
+
method: 'get',
58
+
path: '/foo'
59
+
}
60
+
});
61
+
62
+
export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options);
63
+
64
+
export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({
65
+
queryFn: async ({ queryKey, signal }) => {
66
+
const { data } = await getBar({
67
+
...options,
68
+
...queryKey[0],
69
+
signal,
70
+
throwOnError: true
71
+
});
72
+
return data;
73
+
},
74
+
queryKey: getBarQueryKey(options),
75
+
meta: {
76
+
id: 'getBar',
77
+
method: 'get',
78
+
path: '/bar'
79
+
}
80
+
});
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/react-query.gen.ts
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/react-query.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { type DefaultError, queryOptions } from '@tanstack/react-query';
4
+
5
+
import { client } from '../client.gen';
6
+
import { getBar, getFoo, type Options } from '../sdk.gen';
7
+
import type { GetBarData, GetFooData } from '../types.gen';
8
+
9
+
export type QueryKey<TOptions extends Options> = [
10
+
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
11
+
_id: string;
12
+
_infinite?: boolean;
13
+
tags?: ReadonlyArray<string>;
14
+
}
15
+
];
16
+
17
+
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
18
+
QueryKey<TOptions>[0]
19
+
] => {
20
+
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
21
+
if (infinite) {
22
+
params._infinite = infinite;
23
+
}
24
+
if (tags) {
25
+
params.tags = tags;
26
+
}
27
+
if (options?.body) {
28
+
params.body = options.body;
29
+
}
30
+
if (options?.headers) {
31
+
params.headers = options.headers;
32
+
}
33
+
if (options?.path) {
34
+
params.path = options.path;
35
+
}
36
+
if (options?.query) {
37
+
params.query = options.query;
38
+
}
39
+
return [params];
40
+
};
41
+
42
+
export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options);
43
+
44
+
export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({
45
+
queryFn: async ({ queryKey, signal }) => {
46
+
const { data } = await getFoo({
47
+
...options,
48
+
...queryKey[0],
49
+
signal,
50
+
throwOnError: true
51
+
});
52
+
return data;
53
+
},
54
+
queryKey: getFooQueryKey(options),
55
+
meta: {
56
+
id: 'getFoo',
57
+
method: 'get',
58
+
path: '/foo'
59
+
}
60
+
});
61
+
62
+
export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options);
63
+
64
+
export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({
65
+
queryFn: async ({ queryKey, signal }) => {
66
+
const { data } = await getBar({
67
+
...options,
68
+
...queryKey[0],
69
+
signal,
70
+
throwOnError: true
71
+
});
72
+
return data;
73
+
},
74
+
queryKey: getBarQueryKey(options),
75
+
meta: {
76
+
id: 'getBar',
77
+
method: 'get',
78
+
path: '/bar'
79
+
}
80
+
});
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/solid-query.gen.ts
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/solid-query.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { type DefaultError, queryOptions } from '@tanstack/solid-query';
4
+
5
+
import { client } from '../client.gen';
6
+
import { getBar, getFoo, type Options } from '../sdk.gen';
7
+
import type { GetBarData, GetFooData } from '../types.gen';
8
+
9
+
export type QueryKey<TOptions extends Options> = [
10
+
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
11
+
_id: string;
12
+
_infinite?: boolean;
13
+
tags?: ReadonlyArray<string>;
14
+
}
15
+
];
16
+
17
+
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
18
+
QueryKey<TOptions>[0]
19
+
] => {
20
+
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
21
+
if (infinite) {
22
+
params._infinite = infinite;
23
+
}
24
+
if (tags) {
25
+
params.tags = tags;
26
+
}
27
+
if (options?.body) {
28
+
params.body = options.body;
29
+
}
30
+
if (options?.headers) {
31
+
params.headers = options.headers;
32
+
}
33
+
if (options?.path) {
34
+
params.path = options.path;
35
+
}
36
+
if (options?.query) {
37
+
params.query = options.query;
38
+
}
39
+
return [params];
40
+
};
41
+
42
+
export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options);
43
+
44
+
export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({
45
+
queryFn: async ({ queryKey, signal }) => {
46
+
const { data } = await getFoo({
47
+
...options,
48
+
...queryKey[0],
49
+
signal,
50
+
throwOnError: true
51
+
});
52
+
return data;
53
+
},
54
+
queryKey: getFooQueryKey(options),
55
+
meta: {
56
+
id: 'getFoo',
57
+
method: 'get',
58
+
path: '/foo'
59
+
}
60
+
});
61
+
62
+
export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options);
63
+
64
+
export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({
65
+
queryFn: async ({ queryKey, signal }) => {
66
+
const { data } = await getBar({
67
+
...options,
68
+
...queryKey[0],
69
+
signal,
70
+
throwOnError: true
71
+
});
72
+
return data;
73
+
},
74
+
queryKey: getBarQueryKey(options),
75
+
meta: {
76
+
id: 'getBar',
77
+
method: 'get',
78
+
path: '/bar'
79
+
}
80
+
});
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/svelte-query.gen.ts
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/svelte-query.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { type DefaultError, queryOptions } from '@tanstack/svelte-query';
4
+
5
+
import { client } from '../client.gen';
6
+
import { getBar, getFoo, type Options } from '../sdk.gen';
7
+
import type { GetBarData, GetFooData } from '../types.gen';
8
+
9
+
export type QueryKey<TOptions extends Options> = [
10
+
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
11
+
_id: string;
12
+
_infinite?: boolean;
13
+
tags?: ReadonlyArray<string>;
14
+
}
15
+
];
16
+
17
+
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
18
+
QueryKey<TOptions>[0]
19
+
] => {
20
+
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
21
+
if (infinite) {
22
+
params._infinite = infinite;
23
+
}
24
+
if (tags) {
25
+
params.tags = tags;
26
+
}
27
+
if (options?.body) {
28
+
params.body = options.body;
29
+
}
30
+
if (options?.headers) {
31
+
params.headers = options.headers;
32
+
}
33
+
if (options?.path) {
34
+
params.path = options.path;
35
+
}
36
+
if (options?.query) {
37
+
params.query = options.query;
38
+
}
39
+
return [params];
40
+
};
41
+
42
+
export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options);
43
+
44
+
export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({
45
+
queryFn: async ({ queryKey, signal }) => {
46
+
const { data } = await getFoo({
47
+
...options,
48
+
...queryKey[0],
49
+
signal,
50
+
throwOnError: true
51
+
});
52
+
return data;
53
+
},
54
+
queryKey: getFooQueryKey(options),
55
+
meta: {
56
+
id: 'getFoo',
57
+
method: 'get',
58
+
path: '/foo'
59
+
}
60
+
});
61
+
62
+
export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options);
63
+
64
+
export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({
65
+
queryFn: async ({ queryKey, signal }) => {
66
+
const { data } = await getBar({
67
+
...options,
68
+
...queryKey[0],
69
+
signal,
70
+
throwOnError: true
71
+
});
72
+
return data;
73
+
},
74
+
queryKey: getBarQueryKey(options),
75
+
meta: {
76
+
id: 'getBar',
77
+
method: 'get',
78
+
path: '/bar'
79
+
}
80
+
});
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/vue-query.gen.ts
+80
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/@tanstack/vue-query.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { type DefaultError, queryOptions } from '@tanstack/vue-query';
4
+
5
+
import { client } from '../client.gen';
6
+
import { getBar, getFoo, type Options } from '../sdk.gen';
7
+
import type { GetBarData, GetFooData } from '../types.gen';
8
+
9
+
export type QueryKey<TOptions extends Options> = [
10
+
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
11
+
_id: string;
12
+
_infinite?: boolean;
13
+
tags?: ReadonlyArray<string>;
14
+
}
15
+
];
16
+
17
+
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
18
+
QueryKey<TOptions>[0]
19
+
] => {
20
+
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
21
+
if (infinite) {
22
+
params._infinite = infinite;
23
+
}
24
+
if (tags) {
25
+
params.tags = tags;
26
+
}
27
+
if (options?.body) {
28
+
params.body = options.body;
29
+
}
30
+
if (options?.headers) {
31
+
params.headers = options.headers;
32
+
}
33
+
if (options?.path) {
34
+
params.path = options.path;
35
+
}
36
+
if (options?.query) {
37
+
params.query = options.query;
38
+
}
39
+
return [params];
40
+
};
41
+
42
+
export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options);
43
+
44
+
export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({
45
+
queryFn: async ({ queryKey, signal }) => {
46
+
const { data } = await getFoo({
47
+
...options,
48
+
...queryKey[0],
49
+
signal,
50
+
throwOnError: true
51
+
});
52
+
return data;
53
+
},
54
+
queryKey: getFooQueryKey(options),
55
+
meta: {
56
+
id: 'getFoo',
57
+
method: 'get',
58
+
path: '/foo'
59
+
}
60
+
});
61
+
62
+
export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options);
63
+
64
+
export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({
65
+
queryFn: async ({ queryKey, signal }) => {
66
+
const { data } = await getBar({
67
+
...options,
68
+
...queryKey[0],
69
+
signal,
70
+
throwOnError: true
71
+
});
72
+
return data;
73
+
},
74
+
queryKey: getBarQueryKey(options),
75
+
meta: {
76
+
id: 'getBar',
77
+
method: 'get',
78
+
path: '/bar'
79
+
}
80
+
});
+16
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client.gen.ts
+16
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { type ClientOptions, type Config, createClient, createConfig } from './client';
4
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
5
+
6
+
/**
7
+
* The `createClientConfig()` function will be called on client initialization
8
+
* and the returned object will become the client's initial configuration.
9
+
*
10
+
* You may want to initialize your client this way instead of calling
11
+
* `setConfig()`. This is useful for example if you're using Next.js
12
+
* to ensure your client always has the correct values.
13
+
*/
14
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
15
+
16
+
export const client = createClient(createConfig<ClientOptions2>());
+301
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts
+301
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { createSseClient } from '../core/serverSentEvents.gen';
4
+
import type { HttpMethod } from '../core/types.gen';
5
+
import { getValidRequestBody } from '../core/utils.gen';
6
+
import type {
7
+
Client,
8
+
Config,
9
+
RequestOptions,
10
+
ResolvedRequestOptions,
11
+
} from './types.gen';
12
+
import {
13
+
buildUrl,
14
+
createConfig,
15
+
createInterceptors,
16
+
getParseAs,
17
+
mergeConfigs,
18
+
mergeHeaders,
19
+
setAuthParams,
20
+
} from './utils.gen';
21
+
22
+
type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
23
+
body?: any;
24
+
headers: ReturnType<typeof mergeHeaders>;
25
+
};
26
+
27
+
export const createClient = (config: Config = {}): Client => {
28
+
let _config = mergeConfigs(createConfig(), config);
29
+
30
+
const getConfig = (): Config => ({ ..._config });
31
+
32
+
const setConfig = (config: Config): Config => {
33
+
_config = mergeConfigs(_config, config);
34
+
return getConfig();
35
+
};
36
+
37
+
const interceptors = createInterceptors<
38
+
Request,
39
+
Response,
40
+
unknown,
41
+
ResolvedRequestOptions
42
+
>();
43
+
44
+
const beforeRequest = async (options: RequestOptions) => {
45
+
const opts = {
46
+
..._config,
47
+
...options,
48
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
49
+
headers: mergeHeaders(_config.headers, options.headers),
50
+
serializedBody: undefined,
51
+
};
52
+
53
+
if (opts.security) {
54
+
await setAuthParams({
55
+
...opts,
56
+
security: opts.security,
57
+
});
58
+
}
59
+
60
+
if (opts.requestValidator) {
61
+
await opts.requestValidator(opts);
62
+
}
63
+
64
+
if (opts.body !== undefined && opts.bodySerializer) {
65
+
opts.serializedBody = opts.bodySerializer(opts.body);
66
+
}
67
+
68
+
// remove Content-Type header if body is empty to avoid sending invalid requests
69
+
if (opts.body === undefined || opts.serializedBody === '') {
70
+
opts.headers.delete('Content-Type');
71
+
}
72
+
73
+
const url = buildUrl(opts);
74
+
75
+
return { opts, url };
76
+
};
77
+
78
+
const request: Client['request'] = async (options) => {
79
+
// @ts-expect-error
80
+
const { opts, url } = await beforeRequest(options);
81
+
const requestInit: ReqInit = {
82
+
redirect: 'follow',
83
+
...opts,
84
+
body: getValidRequestBody(opts),
85
+
};
86
+
87
+
let request = new Request(url, requestInit);
88
+
89
+
for (const fn of interceptors.request.fns) {
90
+
if (fn) {
91
+
request = await fn(request, opts);
92
+
}
93
+
}
94
+
95
+
// fetch must be assigned here, otherwise it would throw the error:
96
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
97
+
const _fetch = opts.fetch!;
98
+
let response: Response;
99
+
100
+
try {
101
+
response = await _fetch(request);
102
+
} catch (error) {
103
+
// Handle fetch exceptions (AbortError, network errors, etc.)
104
+
let finalError = error;
105
+
106
+
for (const fn of interceptors.error.fns) {
107
+
if (fn) {
108
+
finalError = (await fn(
109
+
error,
110
+
undefined as any,
111
+
request,
112
+
opts,
113
+
)) as unknown;
114
+
}
115
+
}
116
+
117
+
finalError = finalError || ({} as unknown);
118
+
119
+
if (opts.throwOnError) {
120
+
throw finalError;
121
+
}
122
+
123
+
// Return error response
124
+
return opts.responseStyle === 'data'
125
+
? undefined
126
+
: {
127
+
error: finalError,
128
+
request,
129
+
response: undefined as any,
130
+
};
131
+
}
132
+
133
+
for (const fn of interceptors.response.fns) {
134
+
if (fn) {
135
+
response = await fn(response, request, opts);
136
+
}
137
+
}
138
+
139
+
const result = {
140
+
request,
141
+
response,
142
+
};
143
+
144
+
if (response.ok) {
145
+
const parseAs =
146
+
(opts.parseAs === 'auto'
147
+
? getParseAs(response.headers.get('Content-Type'))
148
+
: opts.parseAs) ?? 'json';
149
+
150
+
if (
151
+
response.status === 204 ||
152
+
response.headers.get('Content-Length') === '0'
153
+
) {
154
+
let emptyData: any;
155
+
switch (parseAs) {
156
+
case 'arrayBuffer':
157
+
case 'blob':
158
+
case 'text':
159
+
emptyData = await response[parseAs]();
160
+
break;
161
+
case 'formData':
162
+
emptyData = new FormData();
163
+
break;
164
+
case 'stream':
165
+
emptyData = response.body;
166
+
break;
167
+
case 'json':
168
+
default:
169
+
emptyData = {};
170
+
break;
171
+
}
172
+
return opts.responseStyle === 'data'
173
+
? emptyData
174
+
: {
175
+
data: emptyData,
176
+
...result,
177
+
};
178
+
}
179
+
180
+
let data: any;
181
+
switch (parseAs) {
182
+
case 'arrayBuffer':
183
+
case 'blob':
184
+
case 'formData':
185
+
case 'json':
186
+
case 'text':
187
+
data = await response[parseAs]();
188
+
break;
189
+
case 'stream':
190
+
return opts.responseStyle === 'data'
191
+
? response.body
192
+
: {
193
+
data: response.body,
194
+
...result,
195
+
};
196
+
}
197
+
198
+
if (parseAs === 'json') {
199
+
if (opts.responseValidator) {
200
+
await opts.responseValidator(data);
201
+
}
202
+
203
+
if (opts.responseTransformer) {
204
+
data = await opts.responseTransformer(data);
205
+
}
206
+
}
207
+
208
+
return opts.responseStyle === 'data'
209
+
? data
210
+
: {
211
+
data,
212
+
...result,
213
+
};
214
+
}
215
+
216
+
const textError = await response.text();
217
+
let jsonError: unknown;
218
+
219
+
try {
220
+
jsonError = JSON.parse(textError);
221
+
} catch {
222
+
// noop
223
+
}
224
+
225
+
const error = jsonError ?? textError;
226
+
let finalError = error;
227
+
228
+
for (const fn of interceptors.error.fns) {
229
+
if (fn) {
230
+
finalError = (await fn(error, response, request, opts)) as string;
231
+
}
232
+
}
233
+
234
+
finalError = finalError || ({} as string);
235
+
236
+
if (opts.throwOnError) {
237
+
throw finalError;
238
+
}
239
+
240
+
// TODO: we probably want to return error and improve types
241
+
return opts.responseStyle === 'data'
242
+
? undefined
243
+
: {
244
+
error: finalError,
245
+
...result,
246
+
};
247
+
};
248
+
249
+
const makeMethodFn =
250
+
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
251
+
request({ ...options, method });
252
+
253
+
const makeSseFn =
254
+
(method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
255
+
const { opts, url } = await beforeRequest(options);
256
+
return createSseClient({
257
+
...opts,
258
+
body: opts.body as BodyInit | null | undefined,
259
+
headers: opts.headers as unknown as Record<string, string>,
260
+
method,
261
+
onRequest: async (url, init) => {
262
+
let request = new Request(url, init);
263
+
for (const fn of interceptors.request.fns) {
264
+
if (fn) {
265
+
request = await fn(request, opts);
266
+
}
267
+
}
268
+
return request;
269
+
},
270
+
url,
271
+
});
272
+
};
273
+
274
+
return {
275
+
buildUrl,
276
+
connect: makeMethodFn('CONNECT'),
277
+
delete: makeMethodFn('DELETE'),
278
+
get: makeMethodFn('GET'),
279
+
getConfig,
280
+
head: makeMethodFn('HEAD'),
281
+
interceptors,
282
+
options: makeMethodFn('OPTIONS'),
283
+
patch: makeMethodFn('PATCH'),
284
+
post: makeMethodFn('POST'),
285
+
put: makeMethodFn('PUT'),
286
+
request,
287
+
setConfig,
288
+
sse: {
289
+
connect: makeSseFn('CONNECT'),
290
+
delete: makeSseFn('DELETE'),
291
+
get: makeSseFn('GET'),
292
+
head: makeSseFn('HEAD'),
293
+
options: makeSseFn('OPTIONS'),
294
+
patch: makeSseFn('PATCH'),
295
+
post: makeSseFn('POST'),
296
+
put: makeSseFn('PUT'),
297
+
trace: makeSseFn('TRACE'),
298
+
},
299
+
trace: makeMethodFn('TRACE'),
300
+
} as Client;
301
+
};
+25
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/index.ts
+25
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/index.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
export type { Auth } from '../core/auth.gen';
4
+
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
5
+
export {
6
+
formDataBodySerializer,
7
+
jsonBodySerializer,
8
+
urlSearchParamsBodySerializer,
9
+
} from '../core/bodySerializer.gen';
10
+
export { buildClientParams } from '../core/params.gen';
11
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
12
+
export { createClient } from './client.gen';
13
+
export type {
14
+
Client,
15
+
ClientOptions,
16
+
Config,
17
+
CreateClientConfig,
18
+
Options,
19
+
RequestOptions,
20
+
RequestResult,
21
+
ResolvedRequestOptions,
22
+
ResponseStyle,
23
+
TDataShape,
24
+
} from './types.gen';
25
+
export { createConfig, mergeHeaders } from './utils.gen';
+241
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts
+241
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import type { Auth } from '../core/auth.gen';
4
+
import type {
5
+
ServerSentEventsOptions,
6
+
ServerSentEventsResult,
7
+
} from '../core/serverSentEvents.gen';
8
+
import type {
9
+
Client as CoreClient,
10
+
Config as CoreConfig,
11
+
} from '../core/types.gen';
12
+
import type { Middleware } from './utils.gen';
13
+
14
+
export type ResponseStyle = 'data' | 'fields';
15
+
16
+
export interface Config<T extends ClientOptions = ClientOptions>
17
+
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
18
+
CoreConfig {
19
+
/**
20
+
* Base URL for all requests made by this client.
21
+
*/
22
+
baseUrl?: T['baseUrl'];
23
+
/**
24
+
* Fetch API implementation. You can use this option to provide a custom
25
+
* fetch instance.
26
+
*
27
+
* @default globalThis.fetch
28
+
*/
29
+
fetch?: typeof fetch;
30
+
/**
31
+
* Please don't use the Fetch client for Next.js applications. The `next`
32
+
* options won't have any effect.
33
+
*
34
+
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
35
+
*/
36
+
next?: never;
37
+
/**
38
+
* Return the response data parsed in a specified format. By default, `auto`
39
+
* will infer the appropriate method from the `Content-Type` response header.
40
+
* You can override this behavior with any of the {@link Body} methods.
41
+
* Select `stream` if you don't want to parse response data at all.
42
+
*
43
+
* @default 'auto'
44
+
*/
45
+
parseAs?:
46
+
| 'arrayBuffer'
47
+
| 'auto'
48
+
| 'blob'
49
+
| 'formData'
50
+
| 'json'
51
+
| 'stream'
52
+
| 'text';
53
+
/**
54
+
* Should we return only data or multiple fields (data, error, response, etc.)?
55
+
*
56
+
* @default 'fields'
57
+
*/
58
+
responseStyle?: ResponseStyle;
59
+
/**
60
+
* Throw an error instead of returning it in the response?
61
+
*
62
+
* @default false
63
+
*/
64
+
throwOnError?: T['throwOnError'];
65
+
}
66
+
67
+
export interface RequestOptions<
68
+
TData = unknown,
69
+
TResponseStyle extends ResponseStyle = 'fields',
70
+
ThrowOnError extends boolean = boolean,
71
+
Url extends string = string,
72
+
> extends Config<{
73
+
responseStyle: TResponseStyle;
74
+
throwOnError: ThrowOnError;
75
+
}>,
76
+
Pick<
77
+
ServerSentEventsOptions<TData>,
78
+
| 'onSseError'
79
+
| 'onSseEvent'
80
+
| 'sseDefaultRetryDelay'
81
+
| 'sseMaxRetryAttempts'
82
+
| 'sseMaxRetryDelay'
83
+
> {
84
+
/**
85
+
* Any body that you want to add to your request.
86
+
*
87
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
88
+
*/
89
+
body?: unknown;
90
+
path?: Record<string, unknown>;
91
+
query?: Record<string, unknown>;
92
+
/**
93
+
* Security mechanism(s) to use for the request.
94
+
*/
95
+
security?: ReadonlyArray<Auth>;
96
+
url: Url;
97
+
}
98
+
99
+
export interface ResolvedRequestOptions<
100
+
TResponseStyle extends ResponseStyle = 'fields',
101
+
ThrowOnError extends boolean = boolean,
102
+
Url extends string = string,
103
+
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
104
+
serializedBody?: string;
105
+
}
106
+
107
+
export type RequestResult<
108
+
TData = unknown,
109
+
TError = unknown,
110
+
ThrowOnError extends boolean = boolean,
111
+
TResponseStyle extends ResponseStyle = 'fields',
112
+
> = ThrowOnError extends true
113
+
? Promise<
114
+
TResponseStyle extends 'data'
115
+
? TData extends Record<string, unknown>
116
+
? TData[keyof TData]
117
+
: TData
118
+
: {
119
+
data: TData extends Record<string, unknown>
120
+
? TData[keyof TData]
121
+
: TData;
122
+
request: Request;
123
+
response: Response;
124
+
}
125
+
>
126
+
: Promise<
127
+
TResponseStyle extends 'data'
128
+
?
129
+
| (TData extends Record<string, unknown>
130
+
? TData[keyof TData]
131
+
: TData)
132
+
| undefined
133
+
: (
134
+
| {
135
+
data: TData extends Record<string, unknown>
136
+
? TData[keyof TData]
137
+
: TData;
138
+
error: undefined;
139
+
}
140
+
| {
141
+
data: undefined;
142
+
error: TError extends Record<string, unknown>
143
+
? TError[keyof TError]
144
+
: TError;
145
+
}
146
+
) & {
147
+
request: Request;
148
+
response: Response;
149
+
}
150
+
>;
151
+
152
+
export interface ClientOptions {
153
+
baseUrl?: string;
154
+
responseStyle?: ResponseStyle;
155
+
throwOnError?: boolean;
156
+
}
157
+
158
+
type MethodFn = <
159
+
TData = unknown,
160
+
TError = unknown,
161
+
ThrowOnError extends boolean = false,
162
+
TResponseStyle extends ResponseStyle = 'fields',
163
+
>(
164
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
165
+
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
166
+
167
+
type SseFn = <
168
+
TData = unknown,
169
+
TError = unknown,
170
+
ThrowOnError extends boolean = false,
171
+
TResponseStyle extends ResponseStyle = 'fields',
172
+
>(
173
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
174
+
) => Promise<ServerSentEventsResult<TData, TError>>;
175
+
176
+
type RequestFn = <
177
+
TData = unknown,
178
+
TError = unknown,
179
+
ThrowOnError extends boolean = false,
180
+
TResponseStyle extends ResponseStyle = 'fields',
181
+
>(
182
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
183
+
Pick<
184
+
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
185
+
'method'
186
+
>,
187
+
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
188
+
189
+
type BuildUrlFn = <
190
+
TData extends {
191
+
body?: unknown;
192
+
path?: Record<string, unknown>;
193
+
query?: Record<string, unknown>;
194
+
url: string;
195
+
},
196
+
>(
197
+
options: TData & Options<TData>,
198
+
) => string;
199
+
200
+
export type Client = CoreClient<
201
+
RequestFn,
202
+
Config,
203
+
MethodFn,
204
+
BuildUrlFn,
205
+
SseFn
206
+
> & {
207
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
208
+
};
209
+
210
+
/**
211
+
* The `createClientConfig()` function will be called on client initialization
212
+
* and the returned object will become the client's initial configuration.
213
+
*
214
+
* You may want to initialize your client this way instead of calling
215
+
* `setConfig()`. This is useful for example if you're using Next.js
216
+
* to ensure your client always has the correct values.
217
+
*/
218
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
219
+
override?: Config<ClientOptions & T>,
220
+
) => Config<Required<ClientOptions> & T>;
221
+
222
+
export interface TDataShape {
223
+
body?: unknown;
224
+
headers?: unknown;
225
+
path?: unknown;
226
+
query?: unknown;
227
+
url: string;
228
+
}
229
+
230
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
231
+
232
+
export type Options<
233
+
TData extends TDataShape = TDataShape,
234
+
ThrowOnError extends boolean = boolean,
235
+
TResponse = unknown,
236
+
TResponseStyle extends ResponseStyle = 'fields',
237
+
> = OmitKeys<
238
+
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
239
+
'body' | 'path' | 'query' | 'url'
240
+
> &
241
+
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
+332
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/utils.gen.ts
+332
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/client/utils.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import { getAuthToken } from '../core/auth.gen';
4
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
5
+
import { jsonBodySerializer } from '../core/bodySerializer.gen';
6
+
import {
7
+
serializeArrayParam,
8
+
serializeObjectParam,
9
+
serializePrimitiveParam,
10
+
} from '../core/pathSerializer.gen';
11
+
import { getUrl } from '../core/utils.gen';
12
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
13
+
14
+
export const createQuerySerializer = <T = unknown>({
15
+
parameters = {},
16
+
...args
17
+
}: QuerySerializerOptions = {}) => {
18
+
const querySerializer = (queryParams: T) => {
19
+
const search: string[] = [];
20
+
if (queryParams && typeof queryParams === 'object') {
21
+
for (const name in queryParams) {
22
+
const value = queryParams[name];
23
+
24
+
if (value === undefined || value === null) {
25
+
continue;
26
+
}
27
+
28
+
const options = parameters[name] || args;
29
+
30
+
if (Array.isArray(value)) {
31
+
const serializedArray = serializeArrayParam({
32
+
allowReserved: options.allowReserved,
33
+
explode: true,
34
+
name,
35
+
style: 'form',
36
+
value,
37
+
...options.array,
38
+
});
39
+
if (serializedArray) search.push(serializedArray);
40
+
} else if (typeof value === 'object') {
41
+
const serializedObject = serializeObjectParam({
42
+
allowReserved: options.allowReserved,
43
+
explode: true,
44
+
name,
45
+
style: 'deepObject',
46
+
value: value as Record<string, unknown>,
47
+
...options.object,
48
+
});
49
+
if (serializedObject) search.push(serializedObject);
50
+
} else {
51
+
const serializedPrimitive = serializePrimitiveParam({
52
+
allowReserved: options.allowReserved,
53
+
name,
54
+
value: value as string,
55
+
});
56
+
if (serializedPrimitive) search.push(serializedPrimitive);
57
+
}
58
+
}
59
+
}
60
+
return search.join('&');
61
+
};
62
+
return querySerializer;
63
+
};
64
+
65
+
/**
66
+
* Infers parseAs value from provided Content-Type header.
67
+
*/
68
+
export const getParseAs = (
69
+
contentType: string | null,
70
+
): Exclude<Config['parseAs'], 'auto'> => {
71
+
if (!contentType) {
72
+
// If no Content-Type header is provided, the best we can do is return the raw response body,
73
+
// which is effectively the same as the 'stream' option.
74
+
return 'stream';
75
+
}
76
+
77
+
const cleanContent = contentType.split(';')[0]?.trim();
78
+
79
+
if (!cleanContent) {
80
+
return;
81
+
}
82
+
83
+
if (
84
+
cleanContent.startsWith('application/json') ||
85
+
cleanContent.endsWith('+json')
86
+
) {
87
+
return 'json';
88
+
}
89
+
90
+
if (cleanContent === 'multipart/form-data') {
91
+
return 'formData';
92
+
}
93
+
94
+
if (
95
+
['application/', 'audio/', 'image/', 'video/'].some((type) =>
96
+
cleanContent.startsWith(type),
97
+
)
98
+
) {
99
+
return 'blob';
100
+
}
101
+
102
+
if (cleanContent.startsWith('text/')) {
103
+
return 'text';
104
+
}
105
+
106
+
return;
107
+
};
108
+
109
+
const checkForExistence = (
110
+
options: Pick<RequestOptions, 'auth' | 'query'> & {
111
+
headers: Headers;
112
+
},
113
+
name?: string,
114
+
): boolean => {
115
+
if (!name) {
116
+
return false;
117
+
}
118
+
if (
119
+
options.headers.has(name) ||
120
+
options.query?.[name] ||
121
+
options.headers.get('Cookie')?.includes(`${name}=`)
122
+
) {
123
+
return true;
124
+
}
125
+
return false;
126
+
};
127
+
128
+
export const setAuthParams = async ({
129
+
security,
130
+
...options
131
+
}: Pick<Required<RequestOptions>, 'security'> &
132
+
Pick<RequestOptions, 'auth' | 'query'> & {
133
+
headers: Headers;
134
+
}) => {
135
+
for (const auth of security) {
136
+
if (checkForExistence(options, auth.name)) {
137
+
continue;
138
+
}
139
+
140
+
const token = await getAuthToken(auth, options.auth);
141
+
142
+
if (!token) {
143
+
continue;
144
+
}
145
+
146
+
const name = auth.name ?? 'Authorization';
147
+
148
+
switch (auth.in) {
149
+
case 'query':
150
+
if (!options.query) {
151
+
options.query = {};
152
+
}
153
+
options.query[name] = token;
154
+
break;
155
+
case 'cookie':
156
+
options.headers.append('Cookie', `${name}=${token}`);
157
+
break;
158
+
case 'header':
159
+
default:
160
+
options.headers.set(name, token);
161
+
break;
162
+
}
163
+
}
164
+
};
165
+
166
+
export const buildUrl: Client['buildUrl'] = (options) =>
167
+
getUrl({
168
+
baseUrl: options.baseUrl as string,
169
+
path: options.path,
170
+
query: options.query,
171
+
querySerializer:
172
+
typeof options.querySerializer === 'function'
173
+
? options.querySerializer
174
+
: createQuerySerializer(options.querySerializer),
175
+
url: options.url,
176
+
});
177
+
178
+
export const mergeConfigs = (a: Config, b: Config): Config => {
179
+
const config = { ...a, ...b };
180
+
if (config.baseUrl?.endsWith('/')) {
181
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
182
+
}
183
+
config.headers = mergeHeaders(a.headers, b.headers);
184
+
return config;
185
+
};
186
+
187
+
const headersEntries = (headers: Headers): Array<[string, string]> => {
188
+
const entries: Array<[string, string]> = [];
189
+
headers.forEach((value, key) => {
190
+
entries.push([key, value]);
191
+
});
192
+
return entries;
193
+
};
194
+
195
+
export const mergeHeaders = (
196
+
...headers: Array<Required<Config>['headers'] | undefined>
197
+
): Headers => {
198
+
const mergedHeaders = new Headers();
199
+
for (const header of headers) {
200
+
if (!header) {
201
+
continue;
202
+
}
203
+
204
+
const iterator =
205
+
header instanceof Headers
206
+
? headersEntries(header)
207
+
: Object.entries(header);
208
+
209
+
for (const [key, value] of iterator) {
210
+
if (value === null) {
211
+
mergedHeaders.delete(key);
212
+
} else if (Array.isArray(value)) {
213
+
for (const v of value) {
214
+
mergedHeaders.append(key, v as string);
215
+
}
216
+
} else if (value !== undefined) {
217
+
// assume object headers are meant to be JSON stringified, i.e. their
218
+
// content value in OpenAPI specification is 'application/json'
219
+
mergedHeaders.set(
220
+
key,
221
+
typeof value === 'object' ? JSON.stringify(value) : (value as string),
222
+
);
223
+
}
224
+
}
225
+
}
226
+
return mergedHeaders;
227
+
};
228
+
229
+
type ErrInterceptor<Err, Res, Req, Options> = (
230
+
error: Err,
231
+
response: Res,
232
+
request: Req,
233
+
options: Options,
234
+
) => Err | Promise<Err>;
235
+
236
+
type ReqInterceptor<Req, Options> = (
237
+
request: Req,
238
+
options: Options,
239
+
) => Req | Promise<Req>;
240
+
241
+
type ResInterceptor<Res, Req, Options> = (
242
+
response: Res,
243
+
request: Req,
244
+
options: Options,
245
+
) => Res | Promise<Res>;
246
+
247
+
class Interceptors<Interceptor> {
248
+
fns: Array<Interceptor | null> = [];
249
+
250
+
clear(): void {
251
+
this.fns = [];
252
+
}
253
+
254
+
eject(id: number | Interceptor): void {
255
+
const index = this.getInterceptorIndex(id);
256
+
if (this.fns[index]) {
257
+
this.fns[index] = null;
258
+
}
259
+
}
260
+
261
+
exists(id: number | Interceptor): boolean {
262
+
const index = this.getInterceptorIndex(id);
263
+
return Boolean(this.fns[index]);
264
+
}
265
+
266
+
getInterceptorIndex(id: number | Interceptor): number {
267
+
if (typeof id === 'number') {
268
+
return this.fns[id] ? id : -1;
269
+
}
270
+
return this.fns.indexOf(id);
271
+
}
272
+
273
+
update(
274
+
id: number | Interceptor,
275
+
fn: Interceptor,
276
+
): number | Interceptor | false {
277
+
const index = this.getInterceptorIndex(id);
278
+
if (this.fns[index]) {
279
+
this.fns[index] = fn;
280
+
return id;
281
+
}
282
+
return false;
283
+
}
284
+
285
+
use(fn: Interceptor): number {
286
+
this.fns.push(fn);
287
+
return this.fns.length - 1;
288
+
}
289
+
}
290
+
291
+
export interface Middleware<Req, Res, Err, Options> {
292
+
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
293
+
request: Interceptors<ReqInterceptor<Req, Options>>;
294
+
response: Interceptors<ResInterceptor<Res, Req, Options>>;
295
+
}
296
+
297
+
export const createInterceptors = <Req, Res, Err, Options>(): Middleware<
298
+
Req,
299
+
Res,
300
+
Err,
301
+
Options
302
+
> => ({
303
+
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
304
+
request: new Interceptors<ReqInterceptor<Req, Options>>(),
305
+
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
306
+
});
307
+
308
+
const defaultQuerySerializer = createQuerySerializer({
309
+
allowReserved: false,
310
+
array: {
311
+
explode: true,
312
+
style: 'form',
313
+
},
314
+
object: {
315
+
explode: true,
316
+
style: 'deepObject',
317
+
},
318
+
});
319
+
320
+
const defaultHeaders = {
321
+
'Content-Type': 'application/json',
322
+
};
323
+
324
+
export const createConfig = <T extends ClientOptions = ClientOptions>(
325
+
override: Config<Omit<ClientOptions, keyof T> & T> = {},
326
+
): Config<Omit<ClientOptions, keyof T> & T> => ({
327
+
...jsonBodySerializer,
328
+
headers: defaultHeaders,
329
+
parseAs: 'auto',
330
+
querySerializer: defaultQuerySerializer,
331
+
...override,
332
+
});
+42
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/auth.gen.ts
+42
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/auth.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
export type AuthToken = string | undefined;
4
+
5
+
export interface Auth {
6
+
/**
7
+
* Which part of the request do we use to send the auth?
8
+
*
9
+
* @default 'header'
10
+
*/
11
+
in?: 'header' | 'query' | 'cookie';
12
+
/**
13
+
* Header or query parameter name.
14
+
*
15
+
* @default 'Authorization'
16
+
*/
17
+
name?: string;
18
+
scheme?: 'basic' | 'bearer';
19
+
type: 'apiKey' | 'http';
20
+
}
21
+
22
+
export const getAuthToken = async (
23
+
auth: Auth,
24
+
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
25
+
): Promise<string | undefined> => {
26
+
const token =
27
+
typeof callback === 'function' ? await callback(auth) : callback;
28
+
29
+
if (!token) {
30
+
return;
31
+
}
32
+
33
+
if (auth.scheme === 'bearer') {
34
+
return `Bearer ${token}`;
35
+
}
36
+
37
+
if (auth.scheme === 'basic') {
38
+
return `Basic ${btoa(token)}`;
39
+
}
40
+
41
+
return token;
42
+
};
+100
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/bodySerializer.gen.ts
+100
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/bodySerializer.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import type {
4
+
ArrayStyle,
5
+
ObjectStyle,
6
+
SerializerOptions,
7
+
} from './pathSerializer.gen';
8
+
9
+
export type QuerySerializer = (query: Record<string, unknown>) => string;
10
+
11
+
export type BodySerializer = (body: any) => any;
12
+
13
+
type QuerySerializerOptionsObject = {
14
+
allowReserved?: boolean;
15
+
array?: Partial<SerializerOptions<ArrayStyle>>;
16
+
object?: Partial<SerializerOptions<ObjectStyle>>;
17
+
};
18
+
19
+
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
20
+
/**
21
+
* Per-parameter serialization overrides. When provided, these settings
22
+
* override the global array/object settings for specific parameter names.
23
+
*/
24
+
parameters?: Record<string, QuerySerializerOptionsObject>;
25
+
};
26
+
27
+
const serializeFormDataPair = (
28
+
data: FormData,
29
+
key: string,
30
+
value: unknown,
31
+
): void => {
32
+
if (typeof value === 'string' || value instanceof Blob) {
33
+
data.append(key, value);
34
+
} else if (value instanceof Date) {
35
+
data.append(key, value.toISOString());
36
+
} else {
37
+
data.append(key, JSON.stringify(value));
38
+
}
39
+
};
40
+
41
+
const serializeUrlSearchParamsPair = (
42
+
data: URLSearchParams,
43
+
key: string,
44
+
value: unknown,
45
+
): void => {
46
+
if (typeof value === 'string') {
47
+
data.append(key, value);
48
+
} else {
49
+
data.append(key, JSON.stringify(value));
50
+
}
51
+
};
52
+
53
+
export const formDataBodySerializer = {
54
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
55
+
body: T,
56
+
): FormData => {
57
+
const data = new FormData();
58
+
59
+
Object.entries(body).forEach(([key, value]) => {
60
+
if (value === undefined || value === null) {
61
+
return;
62
+
}
63
+
if (Array.isArray(value)) {
64
+
value.forEach((v) => serializeFormDataPair(data, key, v));
65
+
} else {
66
+
serializeFormDataPair(data, key, value);
67
+
}
68
+
});
69
+
70
+
return data;
71
+
},
72
+
};
73
+
74
+
export const jsonBodySerializer = {
75
+
bodySerializer: <T>(body: T): string =>
76
+
JSON.stringify(body, (_key, value) =>
77
+
typeof value === 'bigint' ? value.toString() : value,
78
+
),
79
+
};
80
+
81
+
export const urlSearchParamsBodySerializer = {
82
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
83
+
body: T,
84
+
): string => {
85
+
const data = new URLSearchParams();
86
+
87
+
Object.entries(body).forEach(([key, value]) => {
88
+
if (value === undefined || value === null) {
89
+
return;
90
+
}
91
+
if (Array.isArray(value)) {
92
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
93
+
} else {
94
+
serializeUrlSearchParamsPair(data, key, value);
95
+
}
96
+
});
97
+
98
+
return data.toString();
99
+
},
100
+
};
+176
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/params.gen.ts
+176
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/params.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
type Slot = 'body' | 'headers' | 'path' | 'query';
4
+
5
+
export type Field =
6
+
| {
7
+
in: Exclude<Slot, 'body'>;
8
+
/**
9
+
* Field name. This is the name we want the user to see and use.
10
+
*/
11
+
key: string;
12
+
/**
13
+
* Field mapped name. This is the name we want to use in the request.
14
+
* If omitted, we use the same value as `key`.
15
+
*/
16
+
map?: string;
17
+
}
18
+
| {
19
+
in: Extract<Slot, 'body'>;
20
+
/**
21
+
* Key isn't required for bodies.
22
+
*/
23
+
key?: string;
24
+
map?: string;
25
+
}
26
+
| {
27
+
/**
28
+
* Field name. This is the name we want the user to see and use.
29
+
*/
30
+
key: string;
31
+
/**
32
+
* Field mapped name. This is the name we want to use in the request.
33
+
* If `in` is omitted, `map` aliases `key` to the transport layer.
34
+
*/
35
+
map: Slot;
36
+
};
37
+
38
+
export interface Fields {
39
+
allowExtra?: Partial<Record<Slot, boolean>>;
40
+
args?: ReadonlyArray<Field>;
41
+
}
42
+
43
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
44
+
45
+
const extraPrefixesMap: Record<string, Slot> = {
46
+
$body_: 'body',
47
+
$headers_: 'headers',
48
+
$path_: 'path',
49
+
$query_: 'query',
50
+
};
51
+
const extraPrefixes = Object.entries(extraPrefixesMap);
52
+
53
+
type KeyMap = Map<
54
+
string,
55
+
| {
56
+
in: Slot;
57
+
map?: string;
58
+
}
59
+
| {
60
+
in?: never;
61
+
map: Slot;
62
+
}
63
+
>;
64
+
65
+
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
66
+
if (!map) {
67
+
map = new Map();
68
+
}
69
+
70
+
for (const config of fields) {
71
+
if ('in' in config) {
72
+
if (config.key) {
73
+
map.set(config.key, {
74
+
in: config.in,
75
+
map: config.map,
76
+
});
77
+
}
78
+
} else if ('key' in config) {
79
+
map.set(config.key, {
80
+
map: config.map,
81
+
});
82
+
} else if (config.args) {
83
+
buildKeyMap(config.args, map);
84
+
}
85
+
}
86
+
87
+
return map;
88
+
};
89
+
90
+
interface Params {
91
+
body: unknown;
92
+
headers: Record<string, unknown>;
93
+
path: Record<string, unknown>;
94
+
query: Record<string, unknown>;
95
+
}
96
+
97
+
const stripEmptySlots = (params: Params) => {
98
+
for (const [slot, value] of Object.entries(params)) {
99
+
if (value && typeof value === 'object' && !Object.keys(value).length) {
100
+
delete params[slot as Slot];
101
+
}
102
+
}
103
+
};
104
+
105
+
export const buildClientParams = (
106
+
args: ReadonlyArray<unknown>,
107
+
fields: FieldsConfig,
108
+
) => {
109
+
const params: Params = {
110
+
body: {},
111
+
headers: {},
112
+
path: {},
113
+
query: {},
114
+
};
115
+
116
+
const map = buildKeyMap(fields);
117
+
118
+
let config: FieldsConfig[number] | undefined;
119
+
120
+
for (const [index, arg] of args.entries()) {
121
+
if (fields[index]) {
122
+
config = fields[index];
123
+
}
124
+
125
+
if (!config) {
126
+
continue;
127
+
}
128
+
129
+
if ('in' in config) {
130
+
if (config.key) {
131
+
const field = map.get(config.key)!;
132
+
const name = field.map || config.key;
133
+
if (field.in) {
134
+
(params[field.in] as Record<string, unknown>)[name] = arg;
135
+
}
136
+
} else {
137
+
params.body = arg;
138
+
}
139
+
} else {
140
+
for (const [key, value] of Object.entries(arg ?? {})) {
141
+
const field = map.get(key);
142
+
143
+
if (field) {
144
+
if (field.in) {
145
+
const name = field.map || key;
146
+
(params[field.in] as Record<string, unknown>)[name] = value;
147
+
} else {
148
+
params[field.map] = value;
149
+
}
150
+
} else {
151
+
const extra = extraPrefixes.find(([prefix]) =>
152
+
key.startsWith(prefix),
153
+
);
154
+
155
+
if (extra) {
156
+
const [prefix, slot] = extra;
157
+
(params[slot] as Record<string, unknown>)[
158
+
key.slice(prefix.length)
159
+
] = value;
160
+
} else if ('allowExtra' in config && config.allowExtra) {
161
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
162
+
if (allowed) {
163
+
(params[slot as Slot] as Record<string, unknown>)[key] = value;
164
+
break;
165
+
}
166
+
}
167
+
}
168
+
}
169
+
}
170
+
}
171
+
}
172
+
173
+
stripEmptySlots(params);
174
+
175
+
return params;
176
+
};
+181
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/pathSerializer.gen.ts
+181
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/pathSerializer.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
interface SerializeOptions<T>
4
+
extends SerializePrimitiveOptions,
5
+
SerializerOptions<T> {}
6
+
7
+
interface SerializePrimitiveOptions {
8
+
allowReserved?: boolean;
9
+
name: string;
10
+
}
11
+
12
+
export interface SerializerOptions<T> {
13
+
/**
14
+
* @default true
15
+
*/
16
+
explode: boolean;
17
+
style: T;
18
+
}
19
+
20
+
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
21
+
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
22
+
type MatrixStyle = 'label' | 'matrix' | 'simple';
23
+
export type ObjectStyle = 'form' | 'deepObject';
24
+
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
25
+
26
+
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
27
+
value: string;
28
+
}
29
+
30
+
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
31
+
switch (style) {
32
+
case 'label':
33
+
return '.';
34
+
case 'matrix':
35
+
return ';';
36
+
case 'simple':
37
+
return ',';
38
+
default:
39
+
return '&';
40
+
}
41
+
};
42
+
43
+
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
44
+
switch (style) {
45
+
case 'form':
46
+
return ',';
47
+
case 'pipeDelimited':
48
+
return '|';
49
+
case 'spaceDelimited':
50
+
return '%20';
51
+
default:
52
+
return ',';
53
+
}
54
+
};
55
+
56
+
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
57
+
switch (style) {
58
+
case 'label':
59
+
return '.';
60
+
case 'matrix':
61
+
return ';';
62
+
case 'simple':
63
+
return ',';
64
+
default:
65
+
return '&';
66
+
}
67
+
};
68
+
69
+
export const serializeArrayParam = ({
70
+
allowReserved,
71
+
explode,
72
+
name,
73
+
style,
74
+
value,
75
+
}: SerializeOptions<ArraySeparatorStyle> & {
76
+
value: unknown[];
77
+
}) => {
78
+
if (!explode) {
79
+
const joinedValues = (
80
+
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
81
+
).join(separatorArrayNoExplode(style));
82
+
switch (style) {
83
+
case 'label':
84
+
return `.${joinedValues}`;
85
+
case 'matrix':
86
+
return `;${name}=${joinedValues}`;
87
+
case 'simple':
88
+
return joinedValues;
89
+
default:
90
+
return `${name}=${joinedValues}`;
91
+
}
92
+
}
93
+
94
+
const separator = separatorArrayExplode(style);
95
+
const joinedValues = value
96
+
.map((v) => {
97
+
if (style === 'label' || style === 'simple') {
98
+
return allowReserved ? v : encodeURIComponent(v as string);
99
+
}
100
+
101
+
return serializePrimitiveParam({
102
+
allowReserved,
103
+
name,
104
+
value: v as string,
105
+
});
106
+
})
107
+
.join(separator);
108
+
return style === 'label' || style === 'matrix'
109
+
? separator + joinedValues
110
+
: joinedValues;
111
+
};
112
+
113
+
export const serializePrimitiveParam = ({
114
+
allowReserved,
115
+
name,
116
+
value,
117
+
}: SerializePrimitiveParam) => {
118
+
if (value === undefined || value === null) {
119
+
return '';
120
+
}
121
+
122
+
if (typeof value === 'object') {
123
+
throw new Error(
124
+
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
125
+
);
126
+
}
127
+
128
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
129
+
};
130
+
131
+
export const serializeObjectParam = ({
132
+
allowReserved,
133
+
explode,
134
+
name,
135
+
style,
136
+
value,
137
+
valueOnly,
138
+
}: SerializeOptions<ObjectSeparatorStyle> & {
139
+
value: Record<string, unknown> | Date;
140
+
valueOnly?: boolean;
141
+
}) => {
142
+
if (value instanceof Date) {
143
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
144
+
}
145
+
146
+
if (style !== 'deepObject' && !explode) {
147
+
let values: string[] = [];
148
+
Object.entries(value).forEach(([key, v]) => {
149
+
values = [
150
+
...values,
151
+
key,
152
+
allowReserved ? (v as string) : encodeURIComponent(v as string),
153
+
];
154
+
});
155
+
const joinedValues = values.join(',');
156
+
switch (style) {
157
+
case 'form':
158
+
return `${name}=${joinedValues}`;
159
+
case 'label':
160
+
return `.${joinedValues}`;
161
+
case 'matrix':
162
+
return `;${name}=${joinedValues}`;
163
+
default:
164
+
return joinedValues;
165
+
}
166
+
}
167
+
168
+
const separator = separatorObjectExplode(style);
169
+
const joinedValues = Object.entries(value)
170
+
.map(([key, v]) =>
171
+
serializePrimitiveParam({
172
+
allowReserved,
173
+
name: style === 'deepObject' ? `${name}[${key}]` : key,
174
+
value: v as string,
175
+
}),
176
+
)
177
+
.join(separator);
178
+
return style === 'label' || style === 'matrix'
179
+
? separator + joinedValues
180
+
: joinedValues;
181
+
};
+136
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/queryKeySerializer.gen.ts
+136
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/queryKeySerializer.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
/**
4
+
* JSON-friendly union that mirrors what Pinia Colada can hash.
5
+
*/
6
+
export type JsonValue =
7
+
| null
8
+
| string
9
+
| number
10
+
| boolean
11
+
| JsonValue[]
12
+
| { [key: string]: JsonValue };
13
+
14
+
/**
15
+
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
16
+
*/
17
+
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
18
+
if (
19
+
value === undefined ||
20
+
typeof value === 'function' ||
21
+
typeof value === 'symbol'
22
+
) {
23
+
return undefined;
24
+
}
25
+
if (typeof value === 'bigint') {
26
+
return value.toString();
27
+
}
28
+
if (value instanceof Date) {
29
+
return value.toISOString();
30
+
}
31
+
return value;
32
+
};
33
+
34
+
/**
35
+
* Safely stringifies a value and parses it back into a JsonValue.
36
+
*/
37
+
export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
38
+
try {
39
+
const json = JSON.stringify(input, queryKeyJsonReplacer);
40
+
if (json === undefined) {
41
+
return undefined;
42
+
}
43
+
return JSON.parse(json) as JsonValue;
44
+
} catch {
45
+
return undefined;
46
+
}
47
+
};
48
+
49
+
/**
50
+
* Detects plain objects (including objects with a null prototype).
51
+
*/
52
+
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
53
+
if (value === null || typeof value !== 'object') {
54
+
return false;
55
+
}
56
+
const prototype = Object.getPrototypeOf(value as object);
57
+
return prototype === Object.prototype || prototype === null;
58
+
};
59
+
60
+
/**
61
+
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
62
+
*/
63
+
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
64
+
const entries = Array.from(params.entries()).sort(([a], [b]) =>
65
+
a.localeCompare(b),
66
+
);
67
+
const result: Record<string, JsonValue> = {};
68
+
69
+
for (const [key, value] of entries) {
70
+
const existing = result[key];
71
+
if (existing === undefined) {
72
+
result[key] = value;
73
+
continue;
74
+
}
75
+
76
+
if (Array.isArray(existing)) {
77
+
(existing as string[]).push(value);
78
+
} else {
79
+
result[key] = [existing, value];
80
+
}
81
+
}
82
+
83
+
return result;
84
+
};
85
+
86
+
/**
87
+
* Normalizes any accepted value into a JSON-friendly shape for query keys.
88
+
*/
89
+
export const serializeQueryKeyValue = (
90
+
value: unknown,
91
+
): JsonValue | undefined => {
92
+
if (value === null) {
93
+
return null;
94
+
}
95
+
96
+
if (
97
+
typeof value === 'string' ||
98
+
typeof value === 'number' ||
99
+
typeof value === 'boolean'
100
+
) {
101
+
return value;
102
+
}
103
+
104
+
if (
105
+
value === undefined ||
106
+
typeof value === 'function' ||
107
+
typeof value === 'symbol'
108
+
) {
109
+
return undefined;
110
+
}
111
+
112
+
if (typeof value === 'bigint') {
113
+
return value.toString();
114
+
}
115
+
116
+
if (value instanceof Date) {
117
+
return value.toISOString();
118
+
}
119
+
120
+
if (Array.isArray(value)) {
121
+
return stringifyToJsonValue(value);
122
+
}
123
+
124
+
if (
125
+
typeof URLSearchParams !== 'undefined' &&
126
+
value instanceof URLSearchParams
127
+
) {
128
+
return serializeSearchParams(value);
129
+
}
130
+
131
+
if (isPlainObject(value)) {
132
+
return stringifyToJsonValue(value);
133
+
}
134
+
135
+
return undefined;
136
+
};
+266
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts
+266
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import type { Config } from './types.gen';
4
+
5
+
export type ServerSentEventsOptions<TData = unknown> = Omit<
6
+
RequestInit,
7
+
'method'
8
+
> &
9
+
Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
10
+
/**
11
+
* Fetch API implementation. You can use this option to provide a custom
12
+
* fetch instance.
13
+
*
14
+
* @default globalThis.fetch
15
+
*/
16
+
fetch?: typeof fetch;
17
+
/**
18
+
* Implementing clients can call request interceptors inside this hook.
19
+
*/
20
+
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
21
+
/**
22
+
* Callback invoked when a network or parsing error occurs during streaming.
23
+
*
24
+
* This option applies only if the endpoint returns a stream of events.
25
+
*
26
+
* @param error The error that occurred.
27
+
*/
28
+
onSseError?: (error: unknown) => void;
29
+
/**
30
+
* Callback invoked when an event is streamed from the server.
31
+
*
32
+
* This option applies only if the endpoint returns a stream of events.
33
+
*
34
+
* @param event Event streamed from the server.
35
+
* @returns Nothing (void).
36
+
*/
37
+
onSseEvent?: (event: StreamEvent<TData>) => void;
38
+
serializedBody?: RequestInit['body'];
39
+
/**
40
+
* Default retry delay in milliseconds.
41
+
*
42
+
* This option applies only if the endpoint returns a stream of events.
43
+
*
44
+
* @default 3000
45
+
*/
46
+
sseDefaultRetryDelay?: number;
47
+
/**
48
+
* Maximum number of retry attempts before giving up.
49
+
*/
50
+
sseMaxRetryAttempts?: number;
51
+
/**
52
+
* Maximum retry delay in milliseconds.
53
+
*
54
+
* Applies only when exponential backoff is used.
55
+
*
56
+
* This option applies only if the endpoint returns a stream of events.
57
+
*
58
+
* @default 30000
59
+
*/
60
+
sseMaxRetryDelay?: number;
61
+
/**
62
+
* Optional sleep function for retry backoff.
63
+
*
64
+
* Defaults to using `setTimeout`.
65
+
*/
66
+
sseSleepFn?: (ms: number) => Promise<void>;
67
+
url: string;
68
+
};
69
+
70
+
export interface StreamEvent<TData = unknown> {
71
+
data: TData;
72
+
event?: string;
73
+
id?: string;
74
+
retry?: number;
75
+
}
76
+
77
+
export type ServerSentEventsResult<
78
+
TData = unknown,
79
+
TReturn = void,
80
+
TNext = unknown,
81
+
> = {
82
+
stream: AsyncGenerator<
83
+
TData extends Record<string, unknown> ? TData[keyof TData] : TData,
84
+
TReturn,
85
+
TNext
86
+
>;
87
+
};
88
+
89
+
export const createSseClient = <TData = unknown>({
90
+
onRequest,
91
+
onSseError,
92
+
onSseEvent,
93
+
responseTransformer,
94
+
responseValidator,
95
+
sseDefaultRetryDelay,
96
+
sseMaxRetryAttempts,
97
+
sseMaxRetryDelay,
98
+
sseSleepFn,
99
+
url,
100
+
...options
101
+
}: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
102
+
let lastEventId: string | undefined;
103
+
104
+
const sleep =
105
+
sseSleepFn ??
106
+
((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
107
+
108
+
const createStream = async function* () {
109
+
let retryDelay: number = sseDefaultRetryDelay ?? 3000;
110
+
let attempt = 0;
111
+
const signal = options.signal ?? new AbortController().signal;
112
+
113
+
while (true) {
114
+
if (signal.aborted) break;
115
+
116
+
attempt++;
117
+
118
+
const headers =
119
+
options.headers instanceof Headers
120
+
? options.headers
121
+
: new Headers(options.headers as Record<string, string> | undefined);
122
+
123
+
if (lastEventId !== undefined) {
124
+
headers.set('Last-Event-ID', lastEventId);
125
+
}
126
+
127
+
try {
128
+
const requestInit: RequestInit = {
129
+
redirect: 'follow',
130
+
...options,
131
+
body: options.serializedBody,
132
+
headers,
133
+
signal,
134
+
};
135
+
let request = new Request(url, requestInit);
136
+
if (onRequest) {
137
+
request = await onRequest(url, requestInit);
138
+
}
139
+
// fetch must be assigned here, otherwise it would throw the error:
140
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
141
+
const _fetch = options.fetch ?? globalThis.fetch;
142
+
const response = await _fetch(request);
143
+
144
+
if (!response.ok)
145
+
throw new Error(
146
+
`SSE failed: ${response.status} ${response.statusText}`,
147
+
);
148
+
149
+
if (!response.body) throw new Error('No body in SSE response');
150
+
151
+
const reader = response.body
152
+
.pipeThrough(new TextDecoderStream())
153
+
.getReader();
154
+
155
+
let buffer = '';
156
+
157
+
const abortHandler = () => {
158
+
try {
159
+
reader.cancel();
160
+
} catch {
161
+
// noop
162
+
}
163
+
};
164
+
165
+
signal.addEventListener('abort', abortHandler);
166
+
167
+
try {
168
+
while (true) {
169
+
const { done, value } = await reader.read();
170
+
if (done) break;
171
+
buffer += value;
172
+
// Normalize line endings: CRLF -> LF, then CR -> LF
173
+
buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
174
+
175
+
const chunks = buffer.split('\n\n');
176
+
buffer = chunks.pop() ?? '';
177
+
178
+
for (const chunk of chunks) {
179
+
const lines = chunk.split('\n');
180
+
const dataLines: Array<string> = [];
181
+
let eventName: string | undefined;
182
+
183
+
for (const line of lines) {
184
+
if (line.startsWith('data:')) {
185
+
dataLines.push(line.replace(/^data:\s*/, ''));
186
+
} else if (line.startsWith('event:')) {
187
+
eventName = line.replace(/^event:\s*/, '');
188
+
} else if (line.startsWith('id:')) {
189
+
lastEventId = line.replace(/^id:\s*/, '');
190
+
} else if (line.startsWith('retry:')) {
191
+
const parsed = Number.parseInt(
192
+
line.replace(/^retry:\s*/, ''),
193
+
10,
194
+
);
195
+
if (!Number.isNaN(parsed)) {
196
+
retryDelay = parsed;
197
+
}
198
+
}
199
+
}
200
+
201
+
let data: unknown;
202
+
let parsedJson = false;
203
+
204
+
if (dataLines.length) {
205
+
const rawData = dataLines.join('\n');
206
+
try {
207
+
data = JSON.parse(rawData);
208
+
parsedJson = true;
209
+
} catch {
210
+
data = rawData;
211
+
}
212
+
}
213
+
214
+
if (parsedJson) {
215
+
if (responseValidator) {
216
+
await responseValidator(data);
217
+
}
218
+
219
+
if (responseTransformer) {
220
+
data = await responseTransformer(data);
221
+
}
222
+
}
223
+
224
+
onSseEvent?.({
225
+
data,
226
+
event: eventName,
227
+
id: lastEventId,
228
+
retry: retryDelay,
229
+
});
230
+
231
+
if (dataLines.length) {
232
+
yield data as any;
233
+
}
234
+
}
235
+
}
236
+
} finally {
237
+
signal.removeEventListener('abort', abortHandler);
238
+
reader.releaseLock();
239
+
}
240
+
241
+
break; // exit loop on normal completion
242
+
} catch (error) {
243
+
// connection failed or aborted; retry after delay
244
+
onSseError?.(error);
245
+
246
+
if (
247
+
sseMaxRetryAttempts !== undefined &&
248
+
attempt >= sseMaxRetryAttempts
249
+
) {
250
+
break; // stop after firing error
251
+
}
252
+
253
+
// exponential backoff: double retry each attempt, cap at 30s
254
+
const backoff = Math.min(
255
+
retryDelay * 2 ** (attempt - 1),
256
+
sseMaxRetryDelay ?? 30000,
257
+
);
258
+
await sleep(backoff);
259
+
}
260
+
}
261
+
};
262
+
263
+
const stream = createStream();
264
+
265
+
return { stream };
266
+
};
+118
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts
+118
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import type { Auth, AuthToken } from './auth.gen';
4
+
import type {
5
+
BodySerializer,
6
+
QuerySerializer,
7
+
QuerySerializerOptions,
8
+
} from './bodySerializer.gen';
9
+
10
+
export type HttpMethod =
11
+
| 'connect'
12
+
| 'delete'
13
+
| 'get'
14
+
| 'head'
15
+
| 'options'
16
+
| 'patch'
17
+
| 'post'
18
+
| 'put'
19
+
| 'trace';
20
+
21
+
export type Client<
22
+
RequestFn = never,
23
+
Config = unknown,
24
+
MethodFn = never,
25
+
BuildUrlFn = never,
26
+
SseFn = never,
27
+
> = {
28
+
/**
29
+
* Returns the final request URL.
30
+
*/
31
+
buildUrl: BuildUrlFn;
32
+
getConfig: () => Config;
33
+
request: RequestFn;
34
+
setConfig: (config: Config) => Config;
35
+
} & {
36
+
[K in HttpMethod]: MethodFn;
37
+
} & ([SseFn] extends [never]
38
+
? { sse?: never }
39
+
: { sse: { [K in HttpMethod]: SseFn } });
40
+
41
+
export interface Config {
42
+
/**
43
+
* Auth token or a function returning auth token. The resolved value will be
44
+
* added to the request payload as defined by its `security` array.
45
+
*/
46
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
47
+
/**
48
+
* A function for serializing request body parameter. By default,
49
+
* {@link JSON.stringify()} will be used.
50
+
*/
51
+
bodySerializer?: BodySerializer | null;
52
+
/**
53
+
* An object containing any HTTP headers that you want to pre-populate your
54
+
* `Headers` object with.
55
+
*
56
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
57
+
*/
58
+
headers?:
59
+
| RequestInit['headers']
60
+
| Record<
61
+
string,
62
+
| string
63
+
| number
64
+
| boolean
65
+
| (string | number | boolean)[]
66
+
| null
67
+
| undefined
68
+
| unknown
69
+
>;
70
+
/**
71
+
* The request method.
72
+
*
73
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
74
+
*/
75
+
method?: Uppercase<HttpMethod>;
76
+
/**
77
+
* A function for serializing request query parameters. By default, arrays
78
+
* will be exploded in form style, objects will be exploded in deepObject
79
+
* style, and reserved characters are percent-encoded.
80
+
*
81
+
* This method will have no effect if the native `paramsSerializer()` Axios
82
+
* API function is used.
83
+
*
84
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
85
+
*/
86
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
87
+
/**
88
+
* A function validating request data. This is useful if you want to ensure
89
+
* the request conforms to the desired shape, so it can be safely sent to
90
+
* the server.
91
+
*/
92
+
requestValidator?: (data: unknown) => Promise<unknown>;
93
+
/**
94
+
* A function transforming response data before it's returned. This is useful
95
+
* for post-processing data, e.g. converting ISO strings into Date objects.
96
+
*/
97
+
responseTransformer?: (data: unknown) => Promise<unknown>;
98
+
/**
99
+
* A function validating response data. This is useful if you want to ensure
100
+
* the response conforms to the desired shape, so it can be safely passed to
101
+
* the transformers and returned to the user.
102
+
*/
103
+
responseValidator?: (data: unknown) => Promise<unknown>;
104
+
}
105
+
106
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
107
+
? true
108
+
: [T] extends [never | undefined]
109
+
? [undefined] extends [T]
110
+
? false
111
+
: true
112
+
: false;
113
+
114
+
export type OmitNever<T extends Record<string, unknown>> = {
115
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true
116
+
? never
117
+
: K]: T[K];
118
+
};
+143
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/utils.gen.ts
+143
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/core/utils.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
4
+
import {
5
+
type ArraySeparatorStyle,
6
+
serializeArrayParam,
7
+
serializeObjectParam,
8
+
serializePrimitiveParam,
9
+
} from './pathSerializer.gen';
10
+
11
+
export interface PathSerializer {
12
+
path: Record<string, unknown>;
13
+
url: string;
14
+
}
15
+
16
+
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
17
+
18
+
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
19
+
let url = _url;
20
+
const matches = _url.match(PATH_PARAM_RE);
21
+
if (matches) {
22
+
for (const match of matches) {
23
+
let explode = false;
24
+
let name = match.substring(1, match.length - 1);
25
+
let style: ArraySeparatorStyle = 'simple';
26
+
27
+
if (name.endsWith('*')) {
28
+
explode = true;
29
+
name = name.substring(0, name.length - 1);
30
+
}
31
+
32
+
if (name.startsWith('.')) {
33
+
name = name.substring(1);
34
+
style = 'label';
35
+
} else if (name.startsWith(';')) {
36
+
name = name.substring(1);
37
+
style = 'matrix';
38
+
}
39
+
40
+
const value = path[name];
41
+
42
+
if (value === undefined || value === null) {
43
+
continue;
44
+
}
45
+
46
+
if (Array.isArray(value)) {
47
+
url = url.replace(
48
+
match,
49
+
serializeArrayParam({ explode, name, style, value }),
50
+
);
51
+
continue;
52
+
}
53
+
54
+
if (typeof value === 'object') {
55
+
url = url.replace(
56
+
match,
57
+
serializeObjectParam({
58
+
explode,
59
+
name,
60
+
style,
61
+
value: value as Record<string, unknown>,
62
+
valueOnly: true,
63
+
}),
64
+
);
65
+
continue;
66
+
}
67
+
68
+
if (style === 'matrix') {
69
+
url = url.replace(
70
+
match,
71
+
`;${serializePrimitiveParam({
72
+
name,
73
+
value: value as string,
74
+
})}`,
75
+
);
76
+
continue;
77
+
}
78
+
79
+
const replaceValue = encodeURIComponent(
80
+
style === 'label' ? `.${value as string}` : (value as string),
81
+
);
82
+
url = url.replace(match, replaceValue);
83
+
}
84
+
}
85
+
return url;
86
+
};
87
+
88
+
export const getUrl = ({
89
+
baseUrl,
90
+
path,
91
+
query,
92
+
querySerializer,
93
+
url: _url,
94
+
}: {
95
+
baseUrl?: string;
96
+
path?: Record<string, unknown>;
97
+
query?: Record<string, unknown>;
98
+
querySerializer: QuerySerializer;
99
+
url: string;
100
+
}) => {
101
+
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
102
+
let url = (baseUrl ?? '') + pathUrl;
103
+
if (path) {
104
+
url = defaultPathSerializer({ path, url });
105
+
}
106
+
let search = query ? querySerializer(query) : '';
107
+
if (search.startsWith('?')) {
108
+
search = search.substring(1);
109
+
}
110
+
if (search) {
111
+
url += `?${search}`;
112
+
}
113
+
return url;
114
+
};
115
+
116
+
export function getValidRequestBody(options: {
117
+
body?: unknown;
118
+
bodySerializer?: BodySerializer | null;
119
+
serializedBody?: unknown;
120
+
}) {
121
+
const hasBody = options.body !== undefined;
122
+
const isSerializedBody = hasBody && options.bodySerializer;
123
+
124
+
if (isSerializedBody) {
125
+
if ('serializedBody' in options) {
126
+
const hasSerializedBody =
127
+
options.serializedBody !== undefined && options.serializedBody !== '';
128
+
129
+
return hasSerializedBody ? options.serializedBody : null;
130
+
}
131
+
132
+
// not all clients implement a serializedBody property (i.e. client-axios)
133
+
return options.body !== '' ? options.body : null;
134
+
}
135
+
136
+
// plain/text body
137
+
if (hasBody) {
138
+
return options.body;
139
+
}
140
+
141
+
// no body was provided
142
+
return undefined;
143
+
}
+4
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/index.ts
+4
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/index.ts
+39
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/sdk.gen.ts
+39
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/sdk.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
import type { Client, Options as Options2, TDataShape } from './client';
4
+
import { client } from './client.gen';
5
+
import type { GetBarData, GetBarResponses, GetFooData, GetFooResponses } from './types.gen';
6
+
7
+
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
8
+
/**
9
+
* You can provide a client instance returned by `createClient()` instead of
10
+
* individual options. This might be also useful if you want to implement a
11
+
* custom client.
12
+
*/
13
+
client?: Client;
14
+
/**
15
+
* You can pass arbitrary values through the `meta` object. This can be
16
+
* used to access values that aren't defined as part of the SDK function.
17
+
*/
18
+
meta?: Record<string, unknown>;
19
+
};
20
+
21
+
export const getFoo = <ThrowOnError extends boolean = false>(options?: Options<GetFooData, ThrowOnError>) => (options?.client ?? client).get<GetFooResponses, unknown, ThrowOnError>({
22
+
security: [{
23
+
in: 'query',
24
+
name: 'foo',
25
+
type: 'apiKey'
26
+
}],
27
+
url: '/foo',
28
+
...options
29
+
});
30
+
31
+
export const getBar = <ThrowOnError extends boolean = false>(options?: Options<GetBarData, ThrowOnError>) => (options?.client ?? client).get<GetBarResponses, unknown, ThrowOnError>({
32
+
security: [{
33
+
in: 'cookie',
34
+
name: 'bar',
35
+
type: 'apiKey'
36
+
}],
37
+
url: '/bar',
38
+
...options
39
+
});
+33
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/types.gen.ts
+33
packages/openapi-ts-tests/__snapshots__/plugins/@tanstack/meta/types.gen.ts
···
1
+
// This file is auto-generated by @hey-api/openapi-ts
2
+
3
+
export type ClientOptions = {
4
+
baseUrl: `${string}://${string}` | (string & {});
5
+
};
6
+
7
+
export type GetFooData = {
8
+
body?: never;
9
+
path?: never;
10
+
query?: never;
11
+
url: '/foo';
12
+
};
13
+
14
+
export type GetFooResponses = {
15
+
/**
16
+
* OK
17
+
*/
18
+
200: unknown;
19
+
};
20
+
21
+
export type GetBarData = {
22
+
body?: never;
23
+
path?: never;
24
+
query?: never;
25
+
url: '/bar';
26
+
};
27
+
28
+
export type GetBarResponses = {
29
+
/**
30
+
* OK
31
+
*/
32
+
200: unknown;
33
+
};
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
···
8
8
v.number(),
9
9
v.string(),
10
10
v.bigint()
11
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), BigInt(0)),
11
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')), BigInt(0)),
12
12
id: v.string()
13
13
});
14
14
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts
···
689
689
export const vTypesData = v.object({
690
690
body: v.optional(v.never()),
691
691
path: v.optional(v.object({
692
-
id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')))
692
+
id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')))
693
693
})),
694
694
query: v.object({
695
695
parameterNumber: v.optional(v.number(), 123),
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
···
8
8
v.number(),
9
9
v.string(),
10
10
v.bigint()
11
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), BigInt(0)),
11
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')), BigInt(0)),
12
12
id: v.string()
13
13
});
14
14
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts
+9
-9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts
···
630
630
});
631
631
632
632
export const vPageable = v.object({
633
-
page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(0)), 0),
634
-
size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(1))),
633
+
page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'), v.minValue(0)), 0),
634
+
size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'), v.minValue(1))),
635
635
sort: v.optional(v.array(v.string()))
636
636
});
637
637
···
962
962
}), v.strictObject({
963
963
bar: vNonAsciiStringæøåÆøÅöôêÊ字符串
964
964
})]), v.object({
965
-
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), v.null()]),
966
-
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0))
965
+
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'), v.minValue(0)), v.null()]),
966
+
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255'), v.minValue(0))
967
967
})]);
968
968
969
969
export const vModelWithOneOfAndProperties = v.intersect([v.union([vSimpleParameter, vNonAsciiStringæøåÆøÅöôêÊ字符串]), v.object({
970
-
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), v.null()]),
971
-
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0))
970
+
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'), v.minValue(0)), v.null()]),
971
+
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255'), v.minValue(0))
972
972
})]);
973
973
974
974
/**
···
1331
1331
export const vTypesData = v.object({
1332
1332
body: v.optional(v.never()),
1333
1333
path: v.optional(v.object({
1334
-
id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')))
1334
+
id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')))
1335
1335
})),
1336
1336
query: v.object({
1337
1337
parameterNumber: v.optional(v.number(), 123),
···
1444
1444
vModelWithDictionary
1445
1445
]),
1446
1446
user: v.optional(v.pipe(v.object({
1447
-
id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')), v.readonly())),
1447
+
id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), v.readonly())),
1448
1448
name: v.optional(v.pipe(v.union([v.pipe(v.string(), v.readonly()), v.null()]), v.readonly()))
1449
1449
}), v.readonly()))
1450
1450
})),
1451
1451
path: v.object({
1452
-
id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')),
1452
+
id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')),
1453
1453
'api-version': v.string()
1454
1454
}),
1455
1455
query: v.optional(v.never())
+18
-18
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/integer-formats/valibot.gen.ts
+18
-18
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/integer-formats/valibot.gen.ts
···
4
4
5
5
export const vIntegerFormats = v.object({
6
6
numberNoFormat: v.optional(v.number()),
7
-
numberInt8: v.optional(v.pipe(v.number(), v.minValue(-128, 'Invalid value: Expected int8 to be >= -2^7'), v.maxValue(127, 'Invalid value: Expected int8 to be <= 2^7-1'))),
8
-
numberInt16: v.optional(v.pipe(v.number(), v.minValue(-32768, 'Invalid value: Expected int16 to be >= -2^15'), v.maxValue(32767, 'Invalid value: Expected int16 to be <= 2^15-1'))),
9
-
numberInt32: v.optional(v.pipe(v.number(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'))),
7
+
numberInt8: v.optional(v.pipe(v.number(), v.minValue(-128, 'Invalid value: Expected int8 to be >= -128'), v.maxValue(127, 'Invalid value: Expected int8 to be <= 127'))),
8
+
numberInt16: v.optional(v.pipe(v.number(), v.minValue(-32768, 'Invalid value: Expected int16 to be >= -32768'), v.maxValue(32767, 'Invalid value: Expected int16 to be <= 32767'))),
9
+
numberInt32: v.optional(v.pipe(v.number(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'))),
10
10
numberInt64: v.optional(v.pipe(v.union([
11
11
v.number(),
12
12
v.string(),
13
13
v.bigint()
14
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
15
-
numberUint8: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'))),
16
-
numberUint16: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'))),
17
-
numberUint32: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint32 to be >= 0'), v.maxValue(4294967295, 'Invalid value: Expected uint32 to be <= 2^32-1'))),
14
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
15
+
numberUint8: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255'))),
16
+
numberUint16: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'))),
17
+
numberUint32: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint32 to be >= 0'), v.maxValue(4294967295, 'Invalid value: Expected uint32 to be <= 4294967295'))),
18
18
numberUint64: v.optional(v.pipe(v.union([
19
19
v.number(),
20
20
v.string(),
21
21
v.bigint()
22
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 2^64-1'))),
22
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 18446744073709551615'))),
23
23
integerNoFormat: v.optional(v.pipe(v.number(), v.integer())),
24
-
integerInt8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-128, 'Invalid value: Expected int8 to be >= -2^7'), v.maxValue(127, 'Invalid value: Expected int8 to be <= 2^7-1'))),
25
-
integerInt16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-32768, 'Invalid value: Expected int16 to be >= -2^15'), v.maxValue(32767, 'Invalid value: Expected int16 to be <= 2^15-1'))),
26
-
integerInt32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'))),
24
+
integerInt8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-128, 'Invalid value: Expected int8 to be >= -128'), v.maxValue(127, 'Invalid value: Expected int8 to be <= 127'))),
25
+
integerInt16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-32768, 'Invalid value: Expected int16 to be >= -32768'), v.maxValue(32767, 'Invalid value: Expected int16 to be <= 32767'))),
26
+
integerInt32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'))),
27
27
integerInt64: v.optional(v.pipe(v.union([
28
28
v.number(),
29
29
v.string(),
30
30
v.bigint()
31
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
32
-
integerUint8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'))),
33
-
integerUint16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'))),
34
-
integerUint32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint32 to be >= 0'), v.maxValue(4294967295, 'Invalid value: Expected uint32 to be <= 2^32-1'))),
31
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
32
+
integerUint8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255'))),
33
+
integerUint16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'))),
34
+
integerUint32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint32 to be >= 0'), v.maxValue(4294967295, 'Invalid value: Expected uint32 to be <= 4294967295'))),
35
35
integerUint64: v.optional(v.pipe(v.union([
36
36
v.number(),
37
37
v.string(),
38
38
v.bigint()
39
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 2^64-1'))),
39
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 18446744073709551615'))),
40
40
stringInt64: v.optional(v.pipe(v.union([
41
41
v.number(),
42
42
v.string(),
43
43
v.bigint()
44
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
44
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
45
45
stringUint64: v.optional(v.pipe(v.union([
46
46
v.number(),
47
47
v.string(),
48
48
v.bigint()
49
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 2^64-1')))
49
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 18446744073709551615')))
50
50
});
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
···
8
8
v.number(),
9
9
v.string(),
10
10
v.bigint()
11
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), BigInt(0)),
11
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')), BigInt(0)),
12
12
id: v.string()
13
13
});
14
14
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts
+9
-9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts
···
630
630
});
631
631
632
632
export const vPageable = v.object({
633
-
page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(0)), 0),
634
-
size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(1))),
633
+
page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'), v.minValue(0)), 0),
634
+
size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'), v.minValue(1))),
635
635
sort: v.optional(v.array(v.string()))
636
636
});
637
637
···
972
972
}), v.strictObject({
973
973
bar: vNonAsciiStringæøåÆøÅöôêÊ字符串
974
974
})]), v.object({
975
-
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), v.null()]),
976
-
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0))
975
+
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'), v.minValue(0)), v.null()]),
976
+
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255'), v.minValue(0))
977
977
})]);
978
978
979
979
export const vModelWithOneOfAndProperties = v.intersect([v.union([vSimpleParameter, vNonAsciiStringæøåÆøÅöôêÊ字符串]), v.object({
980
-
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), v.null()]),
981
-
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0))
980
+
baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'), v.minValue(0)), v.null()]),
981
+
qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255'), v.minValue(0))
982
982
})]);
983
983
984
984
/**
···
1347
1347
export const vTypesData = v.object({
1348
1348
body: v.optional(v.never()),
1349
1349
path: v.optional(v.object({
1350
-
id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')))
1350
+
id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')))
1351
1351
})),
1352
1352
query: v.object({
1353
1353
parameterNumber: v.optional(v.number(), 123),
···
1461
1461
vModelWithDictionary
1462
1462
]),
1463
1463
user: v.optional(v.pipe(v.object({
1464
-
id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')), v.readonly())),
1464
+
id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), v.readonly())),
1465
1465
name: v.optional(v.pipe(v.union([v.pipe(v.string(), v.readonly()), v.null()]), v.readonly()))
1466
1466
}), v.readonly()))
1467
1467
})),
1468
1468
path: v.object({
1469
-
id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')),
1469
+
id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')),
1470
1470
'api-version': v.string()
1471
1471
}),
1472
1472
query: v.optional(v.never())
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts
+1
-1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts
···
7
7
v.number(),
8
8
v.string(),
9
9
v.bigint()
10
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'), v.minValue(BigInt(0)), v.maxValue(BigInt(100))))
10
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'), v.minValue(BigInt(0)), v.maxValue(BigInt(100))))
11
11
});
+53
-53
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts
+53
-53
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts
···
9
9
v.number(),
10
10
v.string(),
11
11
v.bigint()
12
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
12
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
13
13
payload: v.strictObject({
14
14
account_id: v.string(),
15
15
object: v.strictObject({
···
17
17
v.number(),
18
18
v.string(),
19
19
v.bigint()
20
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
20
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
21
21
uuid: v.optional(v.string()),
22
22
session_id: v.string(),
23
23
session_name: v.string(),
···
30
30
v.number(),
31
31
v.string(),
32
32
v.bigint()
33
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
33
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
34
34
from_number: v.pipe(v.union([
35
35
v.number(),
36
36
v.string(),
37
37
v.bigint()
38
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))
38
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))
39
39
})
40
40
})
41
41
})
···
51
51
v.number(),
52
52
v.string(),
53
53
v.bigint()
54
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
54
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
55
55
payload: v.strictObject({
56
56
account_id: v.string(),
57
57
object: v.strictObject({
···
59
59
v.number(),
60
60
v.string(),
61
61
v.bigint()
62
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
62
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
63
63
uuid: v.optional(v.string()),
64
64
session_id: v.string(),
65
65
session_name: v.string(),
···
84
84
v.number(),
85
85
v.string(),
86
86
v.bigint()
87
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
87
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
88
88
payload: v.strictObject({
89
89
account_id: v.string(),
90
90
object: v.strictObject({
···
111
111
v.number(),
112
112
v.string(),
113
113
v.bigint()
114
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
114
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
115
115
payload: v.strictObject({
116
116
account_id: v.string(),
117
117
object: v.strictObject({
···
138
138
v.number(),
139
139
v.string(),
140
140
v.bigint()
141
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
141
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
142
142
payload: v.strictObject({
143
143
account_id: v.string(),
144
144
object: v.strictObject({
···
176
176
v.number(),
177
177
v.string(),
178
178
v.bigint()
179
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
179
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
180
180
payload: v.strictObject({
181
181
account_id: v.string(),
182
182
object: v.strictObject({
···
205
205
v.number(),
206
206
v.string(),
207
207
v.bigint()
208
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
208
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
209
209
payload: v.strictObject({
210
210
account_id: v.string(),
211
211
object: v.strictObject({
···
213
213
v.number(),
214
214
v.string(),
215
215
v.bigint()
216
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
216
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
217
217
uuid: v.optional(v.string()),
218
218
session_id: v.string(),
219
219
session_name: v.string(),
···
238
238
v.number(),
239
239
v.string(),
240
240
v.bigint()
241
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
241
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
242
242
payload: v.strictObject({
243
243
account_id: v.string(),
244
244
object: v.strictObject({
···
267
267
v.number(),
268
268
v.string(),
269
269
v.bigint()
270
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
270
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
271
271
payload: v.strictObject({
272
272
account_id: v.string(),
273
273
object: v.strictObject({
···
303
303
v.number(),
304
304
v.string(),
305
305
v.bigint()
306
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
306
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
307
307
payload: v.strictObject({
308
308
account_id: v.string(),
309
309
object: v.strictObject({
···
330
330
v.number(),
331
331
v.string(),
332
332
v.bigint()
333
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
333
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
334
334
payload: v.strictObject({
335
335
account_id: v.string(),
336
336
object: v.strictObject({
···
354
354
v.number(),
355
355
v.string(),
356
356
v.bigint()
357
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
357
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
358
358
payload: v.strictObject({
359
359
account_id: v.string(),
360
360
object: v.strictObject({
···
377
377
v.number(),
378
378
v.string(),
379
379
v.bigint()
380
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
380
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
381
381
payload: v.strictObject({
382
382
account_id: v.string(),
383
383
object: v.strictObject({
···
406
406
v.number(),
407
407
v.string(),
408
408
v.bigint()
409
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
409
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
410
410
payload: v.strictObject({
411
411
account_id: v.string(),
412
412
object: v.strictObject({
···
444
444
v.number(),
445
445
v.string(),
446
446
v.bigint()
447
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
447
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
448
448
payload: v.strictObject({
449
449
account_id: v.string(),
450
450
object: v.strictObject({
···
452
452
v.number(),
453
453
v.string(),
454
454
v.bigint()
455
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
455
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
456
456
uuid: v.optional(v.string()),
457
457
session_id: v.string(),
458
458
session_name: v.string(),
···
477
477
v.number(),
478
478
v.string(),
479
479
v.bigint()
480
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
480
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
481
481
payload: v.strictObject({
482
482
account_id: v.string(),
483
483
object: v.strictObject({
···
485
485
v.number(),
486
486
v.string(),
487
487
v.bigint()
488
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
488
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
489
489
uuid: v.optional(v.string()),
490
490
session_id: v.string(),
491
491
session_name: v.string(),
···
498
498
v.number(),
499
499
v.string(),
500
500
v.bigint()
501
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
501
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
502
502
from_number: v.pipe(v.union([
503
503
v.number(),
504
504
v.string(),
505
505
v.bigint()
506
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))
506
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))
507
507
})
508
508
})
509
509
})
···
519
519
v.number(),
520
520
v.string(),
521
521
v.bigint()
522
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
522
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
523
523
payload: v.strictObject({
524
524
account_id: v.string(),
525
525
object: v.strictObject({
···
550
550
v.number(),
551
551
v.string(),
552
552
v.bigint()
553
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
553
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
554
554
payload: v.strictObject({
555
555
account_id: v.string(),
556
556
object: v.strictObject({
···
586
586
v.number(),
587
587
v.string(),
588
588
v.bigint()
589
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
589
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
590
590
payload: v.strictObject({
591
591
account_id: v.string(),
592
592
object: v.strictObject({
···
600
600
v.number(),
601
601
v.string(),
602
602
v.bigint()
603
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
603
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
604
604
from_number: v.pipe(v.union([
605
605
v.number(),
606
606
v.string(),
607
607
v.bigint()
608
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))
608
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))
609
609
})
610
610
})
611
611
})
···
621
621
v.number(),
622
622
v.string(),
623
623
v.bigint()
624
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
624
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
625
625
download_token: v.string(),
626
626
payload: v.strictObject({
627
627
account_id: v.string(),
···
694
694
v.number(),
695
695
v.string(),
696
696
v.bigint()
697
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
697
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
698
698
payload: v.strictObject({
699
699
account_id: v.string(),
700
700
operator: v.pipe(v.string(), v.email()),
···
719
719
v.number(),
720
720
v.string(),
721
721
v.bigint()
722
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
722
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
723
723
payload: v.strictObject({
724
724
account_id: v.string(),
725
725
object: v.strictObject({
···
727
727
v.number(),
728
728
v.string(),
729
729
v.bigint()
730
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
730
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
731
731
uuid: v.optional(v.string()),
732
732
session_id: v.string(),
733
733
session_name: v.string(),
···
753
753
v.number(),
754
754
v.string(),
755
755
v.bigint()
756
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
756
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
757
757
download_token: v.string(),
758
758
payload: v.strictObject({
759
759
account_id: v.string(),
···
890
890
v.number(),
891
891
v.string(),
892
892
v.bigint()
893
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
893
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
894
894
payload: v.strictObject({
895
895
account_id: v.string(),
896
896
object: v.strictObject({
···
913
913
v.number(),
914
914
v.string(),
915
915
v.bigint()
916
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
916
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
917
917
payload: v.strictObject({
918
918
account_id: v.string(),
919
919
operator: v.pipe(v.string(), v.email()),
···
938
938
v.number(),
939
939
v.string(),
940
940
v.bigint()
941
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
941
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
942
942
payload: v.strictObject({
943
943
account_id: v.string(),
944
944
object: v.strictObject({
···
968
968
v.number(),
969
969
v.string(),
970
970
v.bigint()
971
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
971
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
972
972
payload: v.strictObject({
973
973
account_id: v.string(),
974
974
object: v.strictObject({
···
997
997
v.number(),
998
998
v.string(),
999
999
v.bigint()
1000
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1000
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1001
1001
payload: v.strictObject({
1002
1002
account_id: v.string(),
1003
1003
object: v.strictObject({
···
1026
1026
v.number(),
1027
1027
v.string(),
1028
1028
v.bigint()
1029
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1029
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1030
1030
payload: v.strictObject({
1031
1031
account_id: v.string(),
1032
1032
object: v.strictObject({
···
1055
1055
v.number(),
1056
1056
v.string(),
1057
1057
v.bigint()
1058
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1058
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1059
1059
payload: v.strictObject({
1060
1060
account_id: v.string(),
1061
1061
operator: v.pipe(v.string(), v.email()),
···
1080
1080
v.number(),
1081
1081
v.string(),
1082
1082
v.bigint()
1083
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1083
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1084
1084
payload: v.strictObject({
1085
1085
account_id: v.string(),
1086
1086
object: v.strictObject({
···
1088
1088
v.number(),
1089
1089
v.string(),
1090
1090
v.bigint()
1091
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
1091
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
1092
1092
uuid: v.optional(v.string()),
1093
1093
session_id: v.string(),
1094
1094
session_name: v.string(),
···
1101
1101
v.number(),
1102
1102
v.string(),
1103
1103
v.bigint()
1104
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1104
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1105
1105
from_number: v.pipe(v.union([
1106
1106
v.number(),
1107
1107
v.string(),
1108
1108
v.bigint()
1109
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))
1109
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))
1110
1110
})
1111
1111
})
1112
1112
})
···
1122
1122
v.number(),
1123
1123
v.string(),
1124
1124
v.bigint()
1125
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1125
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1126
1126
payload: v.strictObject({
1127
1127
account_id: v.string(),
1128
1128
object: v.strictObject({
···
1130
1130
v.number(),
1131
1131
v.string(),
1132
1132
v.bigint()
1133
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
1133
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
1134
1134
uuid: v.optional(v.string()),
1135
1135
session_id: v.string(),
1136
1136
session_name: v.string(),
···
1143
1143
v.number(),
1144
1144
v.string(),
1145
1145
v.bigint()
1146
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1146
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1147
1147
from_number: v.pipe(v.union([
1148
1148
v.number(),
1149
1149
v.string(),
1150
1150
v.bigint()
1151
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))
1151
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))
1152
1152
})
1153
1153
})
1154
1154
})
···
1164
1164
v.number(),
1165
1165
v.string(),
1166
1166
v.bigint()
1167
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1167
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1168
1168
payload: v.strictObject({
1169
1169
account_id: v.string(),
1170
1170
object: v.strictObject({
···
1172
1172
v.number(),
1173
1173
v.string(),
1174
1174
v.bigint()
1175
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))),
1175
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807'))),
1176
1176
uuid: v.optional(v.string()),
1177
1177
session_id: v.string(),
1178
1178
session_name: v.string(),
···
1197
1197
v.number(),
1198
1198
v.string(),
1199
1199
v.bigint()
1200
-
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')),
1200
+
]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')),
1201
1201
payload: v.strictObject({
1202
1202
account_id: v.string(),
1203
1203
object: v.strictObject({
+53
-53
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/zod.gen.ts
+53
-53
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/zod.gen.ts
···
5
5
export const zSessionUserPhoneCalloutRingingWebhookRequest = z.object({
6
6
body: z.optional(z.object({
7
7
event: z.string(),
8
-
event_ts: z.coerce.bigint(),
8
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
9
9
payload: z.object({
10
10
account_id: z.string(),
11
11
object: z.object({
12
-
id: z.optional(z.coerce.bigint()),
12
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
13
13
uuid: z.optional(z.string()),
14
14
session_id: z.string(),
15
15
session_name: z.string(),
···
18
18
host_id: z.string(),
19
19
participant: z.object({
20
20
invitee_name: z.string(),
21
-
phone_number: z.coerce.bigint(),
22
-
from_number: z.coerce.bigint()
21
+
phone_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
22
+
from_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })
23
23
})
24
24
})
25
25
})
···
31
31
export const zSessionUserRoomSystemCalloutRingingWebhookRequest = z.object({
32
32
body: z.optional(z.object({
33
33
event: z.string(),
34
-
event_ts: z.coerce.bigint(),
34
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
35
35
payload: z.object({
36
36
account_id: z.string(),
37
37
object: z.object({
38
-
id: z.optional(z.coerce.bigint()),
38
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
39
39
uuid: z.optional(z.string()),
40
40
session_id: z.string(),
41
41
session_name: z.string(),
···
56
56
export const zSessionRecordingStartedWebhookRequest = z.object({
57
57
body: z.optional(z.object({
58
58
event: z.enum(['session.recording_started']),
59
-
event_ts: z.coerce.bigint(),
59
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
60
60
payload: z.object({
61
61
account_id: z.string(),
62
62
object: z.object({
···
79
79
export const zSessionRecordingResumedWebhookRequest = z.object({
80
80
body: z.optional(z.object({
81
81
event: z.enum(['session.recording_resumed']),
82
-
event_ts: z.coerce.bigint(),
82
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
83
83
payload: z.object({
84
84
account_id: z.string(),
85
85
object: z.object({
···
102
102
export const zSessionLiveStreamingStoppedWebhookRequest = z.object({
103
103
body: z.optional(z.object({
104
104
event: z.enum(['session.live_streaming_stopped']),
105
-
event_ts: z.coerce.bigint(),
105
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
106
106
payload: z.object({
107
107
account_id: z.string(),
108
108
object: z.object({
···
136
136
export const zSessionStreamIngestionStoppedWebhookRequest = z.object({
137
137
body: z.optional(z.object({
138
138
event: z.enum(['session.stream_ingestion_stopped']),
139
-
event_ts: z.coerce.bigint(),
139
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
140
140
payload: z.object({
141
141
account_id: z.string(),
142
142
object: z.object({
···
161
161
export const zSessionUserRoomSystemCalloutRejectedWebhookRequest = z.object({
162
162
body: z.optional(z.object({
163
163
event: z.string(),
164
-
event_ts: z.coerce.bigint(),
164
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
165
165
payload: z.object({
166
166
account_id: z.string(),
167
167
object: z.object({
168
-
id: z.optional(z.coerce.bigint()),
168
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
169
169
uuid: z.optional(z.string()),
170
170
session_id: z.string(),
171
171
session_name: z.string(),
···
186
186
export const zSessionAlertWebhookRequest = z.object({
187
187
body: z.optional(z.object({
188
188
event: z.enum(['session.alert']),
189
-
event_ts: z.coerce.bigint(),
189
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
190
190
payload: z.object({
191
191
account_id: z.string(),
192
192
object: z.object({
···
211
211
export const zSessionSharingEndedWebhookRequest = z.object({
212
212
body: z.optional(z.object({
213
213
event: z.enum(['session.sharing_ended']),
214
-
event_ts: z.coerce.bigint(),
214
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
215
215
payload: z.object({
216
216
account_id: z.string(),
217
217
object: z.object({
···
243
243
export const zSessionRecordingPausedWebhookRequest = z.object({
244
244
body: z.optional(z.object({
245
245
event: z.enum(['session.recording_paused']),
246
-
event_ts: z.coerce.bigint(),
246
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
247
247
payload: z.object({
248
248
account_id: z.string(),
249
249
object: z.object({
···
266
266
export const zSessionEndedWebhookRequest = z.object({
267
267
body: z.optional(z.object({
268
268
event: z.enum(['session.ended']),
269
-
event_ts: z.coerce.bigint(),
269
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
270
270
payload: z.object({
271
271
account_id: z.string(),
272
272
object: z.object({
···
286
286
export const zSessionStartedWebhookRequest = z.object({
287
287
body: z.optional(z.object({
288
288
event: z.enum(['session.started']),
289
-
event_ts: z.coerce.bigint(),
289
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
290
290
payload: z.object({
291
291
account_id: z.string(),
292
292
object: z.object({
···
305
305
export const zSessionStreamIngestionUnbindWebhookRequest = z.object({
306
306
body: z.optional(z.object({
307
307
event: z.enum(['session.stream_ingestion_unbind']),
308
-
event_ts: z.coerce.bigint(),
308
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
309
309
payload: z.object({
310
310
account_id: z.string(),
311
311
object: z.object({
···
330
330
export const zSessionLiveStreamingStartedWebhookRequest = z.object({
331
331
body: z.optional(z.object({
332
332
event: z.enum(['session.live_streaming_started']),
333
-
event_ts: z.coerce.bigint(),
333
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
334
334
payload: z.object({
335
335
account_id: z.string(),
336
336
object: z.object({
···
364
364
export const zSessionUserRoomSystemCalloutMissedWebhookRequest = z.object({
365
365
body: z.optional(z.object({
366
366
event: z.string(),
367
-
event_ts: z.coerce.bigint(),
367
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
368
368
payload: z.object({
369
369
account_id: z.string(),
370
370
object: z.object({
371
-
id: z.optional(z.coerce.bigint()),
371
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
372
372
uuid: z.optional(z.string()),
373
373
session_id: z.string(),
374
374
session_name: z.string(),
···
389
389
export const zSessionUserPhoneCalloutAcceptedWebhookRequest = z.object({
390
390
body: z.optional(z.object({
391
391
event: z.string(),
392
-
event_ts: z.coerce.bigint(),
392
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
393
393
payload: z.object({
394
394
account_id: z.string(),
395
395
object: z.object({
396
-
id: z.optional(z.coerce.bigint()),
396
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
397
397
uuid: z.optional(z.string()),
398
398
session_id: z.string(),
399
399
session_name: z.string(),
···
402
402
host_id: z.string(),
403
403
participant: z.object({
404
404
invitee_name: z.string(),
405
-
phone_number: z.coerce.bigint(),
406
-
from_number: z.coerce.bigint()
405
+
phone_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
406
+
from_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })
407
407
})
408
408
})
409
409
})
···
415
415
export const zSessionUserLeftWebhookRequest = z.object({
416
416
body: z.optional(z.object({
417
417
event: z.enum(['session.user_left']),
418
-
event_ts: z.coerce.bigint(),
418
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
419
419
payload: z.object({
420
420
account_id: z.string(),
421
421
object: z.object({
···
442
442
export const zSessionSharingStartedWebhookRequest = z.object({
443
443
body: z.optional(z.object({
444
444
event: z.enum(['session.sharing_started']),
445
-
event_ts: z.coerce.bigint(),
445
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
446
446
payload: z.object({
447
447
account_id: z.string(),
448
448
object: z.object({
···
474
474
export const zSessionUserPhoneCalloutCanceledWebhookRequest = z.object({
475
475
body: z.optional(z.object({
476
476
event: z.string(),
477
-
event_ts: z.coerce.bigint(),
477
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
478
478
payload: z.object({
479
479
account_id: z.string(),
480
480
object: z.object({
···
484
484
user_key: z.string(),
485
485
participant: z.object({
486
486
invitee_name: z.string(),
487
-
phone_number: z.coerce.bigint(),
488
-
from_number: z.coerce.bigint()
487
+
phone_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
488
+
from_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })
489
489
})
490
490
})
491
491
})
···
497
497
export const zSessionRecordingTranscriptCompletedWebhookRequest = z.object({
498
498
body: z.optional(z.object({
499
499
event: z.enum(['session.recording_transcript_completed']),
500
-
event_ts: z.coerce.bigint(),
500
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
501
501
download_token: z.string(),
502
502
payload: z.object({
503
503
account_id: z.string(),
···
566
566
export const zSessionRecordingDeletedWebhookRequest = z.object({
567
567
body: z.optional(z.object({
568
568
event: z.enum(['session.recording_deleted']),
569
-
event_ts: z.coerce.bigint(),
569
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
570
570
payload: z.object({
571
571
account_id: z.string(),
572
572
operator: z.email(),
···
587
587
export const zSessionUserRoomSystemCalloutFailedWebhookRequest = z.object({
588
588
body: z.optional(z.object({
589
589
event: z.string(),
590
-
event_ts: z.coerce.bigint(),
590
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
591
591
payload: z.object({
592
592
account_id: z.string(),
593
593
object: z.object({
594
-
id: z.optional(z.coerce.bigint()),
594
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
595
595
uuid: z.optional(z.string()),
596
596
session_id: z.string(),
597
597
session_name: z.string(),
···
627
627
export const zSessionRecordingCompletedWebhookRequest = z.object({
628
628
body: z.optional(z.object({
629
629
event: z.enum(['session.recording_completed']),
630
-
event_ts: z.coerce.bigint(),
630
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
631
631
download_token: z.string(),
632
632
payload: z.object({
633
633
account_id: z.string(),
···
760
760
export const zSessionRecordingTranscriptFailedWebhookRequest = z.object({
761
761
body: z.optional(z.object({
762
762
event: z.enum(['session.recording_transcript_failed']),
763
-
event_ts: z.coerce.bigint(),
763
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
764
764
payload: z.object({
765
765
account_id: z.string(),
766
766
object: z.object({
···
779
779
export const zSessionRecordingTrashedWebhookRequest = z.object({
780
780
body: z.optional(z.object({
781
781
event: z.enum(['session.recording_trashed']),
782
-
event_ts: z.coerce.bigint(),
782
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
783
783
payload: z.object({
784
784
account_id: z.string(),
785
785
operator: z.email(),
···
800
800
export const zSessionUserJoinedWebhookRequest = z.object({
801
801
body: z.optional(z.object({
802
802
event: z.enum(['session.user_joined']),
803
-
event_ts: z.coerce.bigint(),
803
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
804
804
payload: z.object({
805
805
account_id: z.string(),
806
806
object: z.object({
···
826
826
export const zSessionStreamIngestionStartedWebhookRequest = z.object({
827
827
body: z.optional(z.object({
828
828
event: z.enum(['session.stream_ingestion_started']),
829
-
event_ts: z.coerce.bigint(),
829
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
830
830
payload: z.object({
831
831
account_id: z.string(),
832
832
object: z.object({
···
851
851
export const zSessionStreamIngestionConnectedWebhookRequest = z.object({
852
852
body: z.optional(z.object({
853
853
event: z.enum(['session.stream_ingestion_connected']),
854
-
event_ts: z.coerce.bigint(),
854
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
855
855
payload: z.object({
856
856
account_id: z.string(),
857
857
object: z.object({
···
876
876
export const zSessionStreamIngestionDisconnectedWebhookRequest = z.object({
877
877
body: z.optional(z.object({
878
878
event: z.enum(['session.stream_ingestion_disconnected']),
879
-
event_ts: z.coerce.bigint(),
879
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
880
880
payload: z.object({
881
881
account_id: z.string(),
882
882
object: z.object({
···
901
901
export const zSessionRecordingRecoveredWebhookRequest = z.object({
902
902
body: z.optional(z.object({
903
903
event: z.enum(['session.recording_recovered']),
904
-
event_ts: z.coerce.bigint(),
904
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
905
905
payload: z.object({
906
906
account_id: z.string(),
907
907
operator: z.email(),
···
922
922
export const zSessionUserPhoneCalloutMissedWebhookRequest = z.object({
923
923
body: z.optional(z.object({
924
924
event: z.string(),
925
-
event_ts: z.coerce.bigint(),
925
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
926
926
payload: z.object({
927
927
account_id: z.string(),
928
928
object: z.object({
929
-
id: z.optional(z.coerce.bigint()),
929
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
930
930
uuid: z.optional(z.string()),
931
931
session_id: z.string(),
932
932
session_name: z.string(),
···
935
935
host_id: z.string(),
936
936
participant: z.object({
937
937
invitee_name: z.string(),
938
-
phone_number: z.coerce.bigint(),
939
-
from_number: z.coerce.bigint()
938
+
phone_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
939
+
from_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })
940
940
})
941
941
})
942
942
})
···
948
948
export const zSessionUserPhoneCalloutRejectedWebhookRequest = z.object({
949
949
body: z.optional(z.object({
950
950
event: z.string(),
951
-
event_ts: z.coerce.bigint(),
951
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
952
952
payload: z.object({
953
953
account_id: z.string(),
954
954
object: z.object({
955
-
id: z.optional(z.coerce.bigint()),
955
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
956
956
uuid: z.optional(z.string()),
957
957
session_id: z.string(),
958
958
session_name: z.string(),
···
961
961
host_id: z.string(),
962
962
participant: z.object({
963
963
invitee_name: z.string(),
964
-
phone_number: z.coerce.bigint(),
965
-
from_number: z.coerce.bigint()
964
+
phone_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
965
+
from_number: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })
966
966
})
967
967
})
968
968
})
···
974
974
export const zSessionUserRoomSystemCalloutAcceptedWebhookRequest = z.object({
975
975
body: z.optional(z.object({
976
976
event: z.string(),
977
-
event_ts: z.coerce.bigint(),
977
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
978
978
payload: z.object({
979
979
account_id: z.string(),
980
980
object: z.object({
981
-
id: z.optional(z.coerce.bigint()),
981
+
id: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })),
982
982
uuid: z.optional(z.string()),
983
983
session_id: z.string(),
984
984
session_name: z.string(),
···
999
999
export const zSessionRecordingStoppedWebhookRequest = z.object({
1000
1000
body: z.optional(z.object({
1001
1001
event: z.enum(['session.recording_stopped']),
1002
-
event_ts: z.coerce.bigint(),
1002
+
event_ts: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
1003
1003
payload: z.object({
1004
1004
account_id: z.string(),
1005
1005
object: z.object({
+9
-9
packages/openapi-ts-tests/main/test/plugins/@tanstack/meta-function.test.ts
packages/openapi-ts-tests/main/test/meta-function.test.ts
+9
-9
packages/openapi-ts-tests/main/test/plugins/@tanstack/meta-function.test.ts
packages/openapi-ts-tests/main/test/meta-function.test.ts
···
5
5
import { createClient, type UserConfig } from '@hey-api/openapi-ts';
6
6
import { describe, expect, it } from 'vitest';
7
7
8
-
import { getFilePaths, getSpecsPath } from '../../../../utils';
8
+
import { getFilePaths, getSpecsPath } from '../../utils';
9
9
10
10
const __filename = fileURLToPath(import.meta.url);
11
11
const __dirname = path.dirname(__filename);
12
12
13
-
describe('TanStack Query Meta Function Customization', () => {
14
-
const version = '3.1.x';
15
-
const namespace = 'plugins';
13
+
const version = '3.1.x';
14
+
const namespace = 'plugins';
15
+
const outputDir = path.join(__dirname, 'generated', version, namespace);
16
16
17
+
// TODO: further clean up
18
+
describe('TanStack Query Meta Function Customization', () => {
17
19
const createConfig = (
18
20
userConfig: Omit<UserConfig, 'input'> & Pick<Partial<UserConfig>, 'input'>,
19
21
): UserConfig => ({
···
57
59
const scenarios = frameworks.map((framework) => ({
58
60
config: createConfig({
59
61
output: path.join(
60
-
__dirname,
61
-
'generated',
62
-
version,
63
-
namespace,
62
+
outputDir,
64
63
'@tanstack',
65
-
`${framework.output}/meta-function`,
64
+
framework.output,
65
+
'meta-function',
66
66
),
67
67
plugins: [
68
68
{
+3
-4
packages/openapi-ts-tests/main/test/plugins/valibot/spec/numberTypeToValibotSchema/const-values.yaml
specs/3.1.x/const-values.yaml
+3
-4
packages/openapi-ts-tests/main/test/plugins/valibot/spec/numberTypeToValibotSchema/const-values.yaml
specs/3.1.x/const-values.yaml
+3
-3
packages/openapi-ts-tests/main/test/plugins/valibot/spec/numberTypeToValibotSchema/formats.yaml
specs/3.1.x/formats.yaml
+3
-3
packages/openapi-ts-tests/main/test/plugins/valibot/spec/numberTypeToValibotSchema/formats.yaml
specs/3.1.x/formats.yaml
+3
-4
packages/openapi-ts-tests/main/test/plugins/valibot/spec/numberTypeToValibotSchema/min-max-constraints.yaml
specs/3.1.x/min-max-constraints.yaml
+3
-4
packages/openapi-ts-tests/main/test/plugins/valibot/spec/numberTypeToValibotSchema/min-max-constraints.yaml
specs/3.1.x/min-max-constraints.yaml
+3
-21
packages/openapi-ts-tests/main/test/plugins/valibot/spec/objectAdditionalProperties/additional-properties.yaml
specs/3.1.x/additional-properties.yaml
+3
-21
packages/openapi-ts-tests/main/test/plugins/valibot/spec/objectAdditionalProperties/additional-properties.yaml
specs/3.1.x/additional-properties.yaml
···
1
-
openapi: '3.1.0'
1
+
openapi: 3.1.0
2
2
info:
3
-
title: Object Additional Properties Test API
4
-
version: '1.0.0'
5
-
paths: {}
3
+
title: OpenAPI 3.1.0 additional properties example
4
+
version: '1'
6
5
components:
7
6
schemas:
8
-
# Test case from the issue: object with additionalProperties type string
9
7
ObjectWithAdditionalPropertiesString:
10
8
type: object
11
9
properties:
···
13
11
type: object
14
12
additionalProperties:
15
13
type: string
16
-
17
-
# Object with no properties, only additionalProperties with string type
18
14
ObjectOnlyAdditionalPropertiesString:
19
15
type: object
20
16
additionalProperties:
21
17
type: string
22
-
23
-
# Object with no properties, only additionalProperties with number type
24
18
ObjectOnlyAdditionalPropertiesNumber:
25
19
type: object
26
20
additionalProperties:
27
21
type: number
28
-
29
-
# Object with no properties, only additionalProperties with boolean type
30
22
ObjectOnlyAdditionalPropertiesBoolean:
31
23
type: object
32
24
additionalProperties:
33
25
type: boolean
34
-
35
-
# Object with properties and additionalProperties number
36
26
ObjectWithPropertiesAndAdditionalPropertiesNumber:
37
27
type: object
38
28
properties:
···
42
32
type: integer
43
33
additionalProperties:
44
34
type: number
45
-
46
-
# Object with additionalProperties as object type
47
35
ObjectWithAdditionalPropertiesObject:
48
36
type: object
49
37
properties:
···
54
42
properties:
55
43
value:
56
44
type: string
57
-
58
-
# Already working case: object with no properties and additionalProperties object
59
45
ObjectOnlyAdditionalPropertiesObject:
60
46
type: object
61
47
additionalProperties:
···
63
49
properties:
64
50
name:
65
51
type: string
66
-
67
-
# Object with additionalProperties set to false (no additional properties allowed)
68
52
ObjectWithAdditionalPropertiesFalse:
69
53
type: object
70
54
properties:
···
73
57
count:
74
58
type: integer
75
59
additionalProperties: false
76
-
77
-
# Object with nested object that has additionalProperties: false
78
60
ObjectWithNestedAdditionalPropertiesFalse:
79
61
type: object
80
62
properties:
-211
packages/openapi-ts-tests/main/test/plugins/valibot/test-helper.ts
-211
packages/openapi-ts-tests/main/test/plugins/valibot/test-helper.ts
···
1
-
/**
2
-
* Test helper for Valibot plugin tests
3
-
* Provides common functionality for schema generation and loading
4
-
*/
5
-
6
-
import fs from 'node:fs';
7
-
import path from 'node:path';
8
-
9
-
import { createClient } from '@hey-api/openapi-ts';
10
-
import * as v from 'valibot';
11
-
12
-
/**
13
-
* Detect test name from the calling file
14
-
*/
15
-
function detectTestName(): string {
16
-
const stack = new Error().stack;
17
-
if (!stack) {
18
-
throw new Error('Unable to detect test name: no stack trace available');
19
-
}
20
-
21
-
// Find the first stack frame that contains a .test.ts file
22
-
const testFileMatch = stack.match(/([^\\/]+)\.test\.ts/);
23
-
if (!testFileMatch || !testFileMatch[1]) {
24
-
throw new Error(
25
-
'Unable to detect test name: no .test.ts file found in stack trace',
26
-
);
27
-
}
28
-
29
-
return testFileMatch[1];
30
-
}
31
-
32
-
/**
33
-
* Detect base directory from the calling file
34
-
*/
35
-
function detectBaseDir(): string {
36
-
const stack = new Error().stack;
37
-
if (!stack) {
38
-
throw new Error(
39
-
'Unable to detect base directory: no stack trace available',
40
-
);
41
-
}
42
-
43
-
// Try multiple regex patterns to match different stack trace formats
44
-
const patterns = [
45
-
/at .* \(([^)]+\.test\.ts):\d+:\d+\)/, // Original pattern
46
-
/at ([^:]+\.test\.ts):\d+:\d+/, // Alternative pattern without parentheses
47
-
/([^:\s]+\.test\.ts):\d+:\d+/, // Simple pattern
48
-
];
49
-
50
-
for (const pattern of patterns) {
51
-
const testFileMatch = stack.match(pattern);
52
-
if (testFileMatch && testFileMatch[1]) {
53
-
return path.dirname(testFileMatch[1]);
54
-
}
55
-
}
56
-
57
-
throw new Error(
58
-
'Unable to detect base directory: no .test.ts file found in stack trace',
59
-
);
60
-
}
61
-
62
-
/**
63
-
* Detect function name from the test file path
64
-
* Extracts the directory name between 'test/' and the test file
65
-
* e.g., from 'test/plugins/valibot/test/numberTypeToValibotSchema/formats.test.ts'
66
-
* extracts 'numberTypeToValibotSchema'
67
-
*/
68
-
function detectFunctionName(): string {
69
-
const stack = new Error().stack;
70
-
if (!stack) {
71
-
throw new Error('Unable to detect function name: no stack trace available');
72
-
}
73
-
74
-
// Try multiple regex patterns to match different stack trace formats
75
-
const patterns = [
76
-
/at .* \(([^)]+\.test\.ts):\d+:\d+\)/, // Original pattern
77
-
/at ([^:]+\.test\.ts):\d+:\d+/, // Alternative pattern without parentheses
78
-
/([^:\s]+\.test\.ts):\d+:\d+/, // Simple pattern
79
-
];
80
-
81
-
for (const pattern of patterns) {
82
-
const testFileMatch = stack.match(pattern);
83
-
if (testFileMatch && testFileMatch[1]) {
84
-
const testFilePath = testFileMatch[1];
85
-
86
-
// Extract function name from path pattern: .../test/[FUNCTION_NAME]/[TEST_NAME].test.ts
87
-
const pathParts = testFilePath.split(/[/\\]/);
88
-
const testIndex = pathParts.lastIndexOf('test');
89
-
90
-
if (testIndex !== -1 && testIndex < pathParts.length - 2) {
91
-
const functionName = pathParts[testIndex + 1];
92
-
if (functionName) {
93
-
return functionName;
94
-
}
95
-
}
96
-
97
-
throw new Error(
98
-
`Unable to extract function name from test path: ${testFilePath}\n` +
99
-
`Expected path pattern: .../test/[FUNCTION_NAME]/[TEST_NAME].test.ts`,
100
-
);
101
-
}
102
-
}
103
-
104
-
throw new Error(
105
-
'Unable to detect function name: no .test.ts file found in stack trace',
106
-
);
107
-
}
108
-
109
-
/**
110
-
* Load and evaluate the generated schemas
111
-
*/
112
-
function loadGeneratedSchemas(generatedPath: string): any {
113
-
if (!fs.existsSync(generatedPath)) {
114
-
throw new Error(
115
-
`Generated schema file not found: ${generatedPath}\n` +
116
-
`Schema generation may have failed. Check the input schema file for errors.`,
117
-
);
118
-
}
119
-
120
-
try {
121
-
const generatedCode = fs.readFileSync(generatedPath, 'utf-8');
122
-
123
-
// Extract all export statements and create a proper return object
124
-
const exportMatches = generatedCode.match(/export const (\w+)/g);
125
-
if (!exportMatches) {
126
-
// noinspection ExceptionCaughtLocallyJS
127
-
throw new Error('No exported schemas found in generated code');
128
-
}
129
-
130
-
// Create evaluation code that returns an object with all exports
131
-
const schemaNames = exportMatches.map((match: string) =>
132
-
match.replace('export const ', ''),
133
-
);
134
-
const evalCode =
135
-
generatedCode
136
-
.replace(/import \* as v from 'valibot';/, '')
137
-
.replace(/export const/g, 'const')
138
-
.replace(/v\./g, 'vModule.') +
139
-
`\n\nreturn { ${schemaNames.join(', ')} };`;
140
-
141
-
// Wrap in a function to capture the return value
142
-
const schemaFunction = new Function('vModule', evalCode);
143
-
return schemaFunction(v);
144
-
} catch (error) {
145
-
throw new Error(
146
-
`Failed to load generated schemas from ${generatedPath}: ${error instanceof Error ? error.message : String(error)}\n` +
147
-
`The generated file may contain syntax errors or be malformed.`,
148
-
);
149
-
}
150
-
}
151
-
152
-
/**
153
-
* Setup function for Valibot tests
154
-
* Automatically detects test name and paths, generates schemas, and returns them
155
-
*/
156
-
export async function setupValibotTest(): Promise<any> {
157
-
// Detect test name, function name, and base directory from calling file
158
-
const testName = detectTestName();
159
-
const functionName = detectFunctionName();
160
-
const baseDir = detectBaseDir();
161
-
162
-
// Construct paths dynamically based on detected function name
163
-
const schemaPath = path.join(
164
-
baseDir,
165
-
'..',
166
-
'..',
167
-
'spec',
168
-
functionName,
169
-
`${testName}.yaml`,
170
-
);
171
-
const outputPath = path.join(
172
-
baseDir,
173
-
'..',
174
-
'..',
175
-
'generated',
176
-
functionName,
177
-
testName,
178
-
);
179
-
180
-
// Check if spec file exists
181
-
if (!fs.existsSync(schemaPath)) {
182
-
throw new Error(
183
-
`Schema file not found: ${schemaPath}\n` +
184
-
`Expected schema file for test '${testName}' in function '${functionName}' at the above location.\n` +
185
-
`Please ensure the spec file exists and matches the test name.`,
186
-
);
187
-
}
188
-
189
-
try {
190
-
// Create output directory
191
-
fs.mkdirSync(outputPath, { recursive: true });
192
-
193
-
// Generate Valibot schemas
194
-
await createClient({
195
-
input: schemaPath,
196
-
logs: { level: 'silent' },
197
-
output: outputPath,
198
-
plugins: ['valibot'],
199
-
});
200
-
201
-
// Load and return the generated schemas
202
-
const generatedPath = path.join(outputPath, 'valibot.gen.ts');
203
-
return loadGeneratedSchemas(generatedPath);
204
-
} catch (error) {
205
-
throw new Error(
206
-
`Failed to generate schemas for test '${testName}' in function '${functionName}': ${error instanceof Error ? error.message : String(error)}\n` +
207
-
`Schema path: ${schemaPath}\n` +
208
-
`Output path: ${outputPath}`,
209
-
);
210
-
}
211
-
}
+6
-2
packages/openapi-ts-tests/main/test/plugins/valibot/test/numberTypeToValibotSchema/const-values.test.ts
packages/openapi-ts-tests/main/test/const-values.test.ts
+6
-2
packages/openapi-ts-tests/main/test/plugins/valibot/test/numberTypeToValibotSchema/const-values.test.ts
packages/openapi-ts-tests/main/test/const-values.test.ts
···
1
1
import * as v from 'valibot';
2
2
import { beforeAll, describe, expect, it } from 'vitest';
3
3
4
-
import { setupValibotTest } from '../../test-helper';
4
+
import { setupValibotTest } from './test-helper';
5
5
6
+
// TODO: further clean up
6
7
describe('Number Type Const Values Tests', () => {
7
8
let generatedSchemas: any;
8
9
9
10
beforeAll(async () => {
10
-
generatedSchemas = await setupValibotTest();
11
+
generatedSchemas = await setupValibotTest(
12
+
'const-values.yaml',
13
+
'const-values',
14
+
);
11
15
});
12
16
13
17
describe('Number Type Const Validation', () => {
+19
-18
packages/openapi-ts-tests/main/test/plugins/valibot/test/numberTypeToValibotSchema/formats.test.ts
packages/openapi-ts-tests/main/test/formats.test.ts
+19
-18
packages/openapi-ts-tests/main/test/plugins/valibot/test/numberTypeToValibotSchema/formats.test.ts
packages/openapi-ts-tests/main/test/formats.test.ts
···
1
1
import * as v from 'valibot';
2
2
import { beforeAll, describe, expect, it } from 'vitest';
3
3
4
-
import { setupValibotTest } from '../../test-helper';
4
+
import { setupValibotTest } from './test-helper';
5
5
6
+
// TODO: further clean up
6
7
describe('Number Type Formats Tests', () => {
7
8
let generatedSchemas: any;
8
9
9
10
beforeAll(async () => {
10
-
generatedSchemas = await setupValibotTest();
11
+
generatedSchemas = await setupValibotTest('formats.yaml', 'formats');
11
12
});
12
13
13
14
// Format bounds and error messages from INTEGER_FORMATS
14
15
const FORMAT_BOUNDS = {
15
16
int16: {
16
17
max: 32767,
17
-
maxError: 'Expected int16 to be <= 2^15-1',
18
+
maxError: 'Invalid value: Expected int16 to be <= 32767',
18
19
min: -32768,
19
-
minError: 'Expected int16 to be >= -2^15',
20
+
minError: 'Invalid value: Expected int16 to be >= -32768',
20
21
},
21
22
int32: {
22
23
max: 2147483647,
23
-
maxError: 'Expected int32 to be <= 2^31-1',
24
+
maxError: 'Invalid value: Expected int32 to be <= 2147483647',
24
25
min: -2147483648,
25
-
minError: 'Expected int32 to be >= -2^31',
26
+
minError: 'Invalid value: Expected int32 to be >= -2147483648',
26
27
},
27
28
int64: {
28
29
max: '9223372036854775807',
29
-
maxError: 'Expected int64 to be <= 2^63-1',
30
+
maxError: 'Invalid value: Expected int64 to be <= 9223372036854775807',
30
31
min: '-9223372036854775808',
31
-
minError: 'Expected int64 to be >= -2^63',
32
+
minError: 'Invalid value: Expected int64 to be >= -9223372036854775808',
32
33
},
33
34
int8: {
34
35
max: 127,
35
-
maxError: 'Expected int8 to be <= 2^7-1',
36
+
maxError: 'Invalid value: Expected int8 to be <= 127',
36
37
min: -128,
37
-
minError: 'Expected int8 to be >= -2^7',
38
+
minError: 'Invalid value: Expected int8 to be >= -128',
38
39
},
39
40
uint16: {
40
41
max: 65535,
41
-
maxError: 'Expected uint16 to be <= 2^16-1',
42
+
maxError: 'Invalid value: Expected uint16 to be <= 65535',
42
43
min: 0,
43
-
minError: 'Expected uint16 to be >= 0',
44
+
minError: 'Invalid value: Expected uint16 to be >= 0',
44
45
},
45
46
uint32: {
46
47
max: 4294967295,
47
-
maxError: 'Expected uint32 to be <= 2^32-1',
48
+
maxError: 'Invalid value: Expected uint32 to be <= 4294967295',
48
49
min: 0,
49
-
minError: 'Expected uint32 to be >= 0',
50
+
minError: 'Invalid value: Expected uint32 to be >= 0',
50
51
},
51
52
uint64: {
52
53
max: '18446744073709551615',
53
-
maxError: 'Expected uint64 to be <= 2^64-1',
54
+
maxError: 'Invalid value: Expected uint64 to be <= 18446744073709551615',
54
55
min: '0',
55
-
minError: 'Expected uint64 to be >= 0',
56
+
minError: 'Invalid value: Expected uint64 to be >= 0',
56
57
},
57
58
uint8: {
58
59
max: 255,
59
-
maxError: 'Expected uint8 to be <= 2^8-1',
60
+
maxError: 'Invalid value: Expected uint8 to be <= 255',
60
61
min: 0,
61
-
minError: 'Expected uint8 to be >= 0',
62
+
minError: 'Invalid value: Expected uint8 to be >= 0',
62
63
},
63
64
};
64
65
+6
-2
packages/openapi-ts-tests/main/test/plugins/valibot/test/numberTypeToValibotSchema/min-max-constraints.test.ts
packages/openapi-ts-tests/main/test/min-max-constraints.test.ts
+6
-2
packages/openapi-ts-tests/main/test/plugins/valibot/test/numberTypeToValibotSchema/min-max-constraints.test.ts
packages/openapi-ts-tests/main/test/min-max-constraints.test.ts
···
1
1
import * as v from 'valibot';
2
2
import { beforeAll, describe, expect, it } from 'vitest';
3
3
4
-
import { setupValibotTest } from '../../test-helper';
4
+
import { setupValibotTest } from './test-helper';
5
5
6
+
// TODO: further clean up
6
7
describe('Number Type Min/Max Constraints Tests', () => {
7
8
let generatedSchemas: any;
8
9
9
10
beforeAll(async () => {
10
-
generatedSchemas = await setupValibotTest();
11
+
generatedSchemas = await setupValibotTest(
12
+
'min-max-constraints.yaml',
13
+
'min-max-constraints',
14
+
);
11
15
});
12
16
13
17
describe('Basic Number Constraints', () => {
+6
-2
packages/openapi-ts-tests/main/test/plugins/valibot/test/objectAdditionalProperties/additional-properties.test.ts
packages/openapi-ts-tests/main/test/additional-properties.test.ts
+6
-2
packages/openapi-ts-tests/main/test/plugins/valibot/test/objectAdditionalProperties/additional-properties.test.ts
packages/openapi-ts-tests/main/test/additional-properties.test.ts
···
1
1
import * as v from 'valibot';
2
2
import { beforeAll, describe, expect, it } from 'vitest';
3
3
4
-
import { setupValibotTest } from '../../test-helper';
4
+
import { setupValibotTest } from './test-helper';
5
5
6
+
// TODO: further clean up
6
7
describe('Object Additional Properties Tests', () => {
7
8
let generatedSchemas: any;
8
9
9
10
beforeAll(async () => {
10
-
generatedSchemas = await setupValibotTest();
11
+
generatedSchemas = await setupValibotTest(
12
+
'additional-properties.yaml',
13
+
'additional-properties',
14
+
);
11
15
});
12
16
13
17
describe('ObjectWithAdditionalPropertiesString', () => {
+80
packages/openapi-ts-tests/main/test/test-helper.ts
+80
packages/openapi-ts-tests/main/test/test-helper.ts
···
1
+
import fs from 'node:fs';
2
+
import path from 'node:path';
3
+
import { fileURLToPath } from 'node:url';
4
+
5
+
import { createClient } from '@hey-api/openapi-ts';
6
+
import * as v from 'valibot';
7
+
8
+
import { getSpecsPath } from '../../utils';
9
+
10
+
const __filename = fileURLToPath(import.meta.url);
11
+
const __dirname = path.dirname(__filename);
12
+
13
+
const version = '3.1.x';
14
+
15
+
const outputDir = path.join(__dirname, 'generated', version);
16
+
17
+
/**
18
+
* Load and evaluate the generated schemas
19
+
*/
20
+
function loadGeneratedSchemas(generatedPath: string): any {
21
+
if (!fs.existsSync(generatedPath)) {
22
+
throw new Error(
23
+
`Generated schema file not found: ${generatedPath}\n` +
24
+
`Schema generation may have failed. Check the input schema file for errors.`,
25
+
);
26
+
}
27
+
28
+
try {
29
+
const generatedCode = fs.readFileSync(generatedPath, 'utf-8');
30
+
31
+
// Extract all export statements and create a proper return object
32
+
const exportMatches = generatedCode.match(/export const (\w+)/g);
33
+
if (!exportMatches) {
34
+
// noinspection ExceptionCaughtLocallyJS
35
+
throw new Error('No exported schemas found in generated code');
36
+
}
37
+
38
+
// Create evaluation code that returns an object with all exports
39
+
const schemaNames = exportMatches.map((match: string) =>
40
+
match.replace('export const ', ''),
41
+
);
42
+
const evalCode =
43
+
generatedCode
44
+
.replace(/import \* as v from 'valibot';/, '')
45
+
.replace(/export const/g, 'const')
46
+
.replace(/v\./g, 'vModule.') +
47
+
`\n\nreturn { ${schemaNames.join(', ')} };`;
48
+
49
+
// Wrap in a function to capture the return value
50
+
const schemaFunction = new Function('vModule', evalCode);
51
+
return schemaFunction(v);
52
+
} catch (error) {
53
+
throw new Error(
54
+
`Failed to load generated schemas from ${generatedPath}: ${error instanceof Error ? error.message : String(error)}\n` +
55
+
`The generated file may contain syntax errors or be malformed.`,
56
+
);
57
+
}
58
+
}
59
+
60
+
// TODO: further clean up
61
+
export async function setupValibotTest(
62
+
input: string,
63
+
output: string,
64
+
): Promise<any> {
65
+
const inputPath = path.join(getSpecsPath(), version, input);
66
+
const outputPath = path.join(outputDir, output);
67
+
68
+
fs.mkdirSync(outputPath, { recursive: true });
69
+
70
+
await createClient({
71
+
input: inputPath,
72
+
logs: { level: 'silent' },
73
+
output: outputPath,
74
+
plugins: ['valibot'],
75
+
});
76
+
77
+
// Load and return the generated schemas
78
+
const generatedPath = path.join(outputPath, 'valibot.gen.ts');
79
+
return loadGeneratedSchemas(generatedPath);
80
+
}
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts
···
722
722
export const zTypesData = z.object({
723
723
body: z.optional(z.never()),
724
724
path: z.optional(z.object({
725
-
id: z.optional(z.int())
725
+
id: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))
726
726
})),
727
727
query: z.object({
728
728
parameterNumber: z._default(z.number(), 123),
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z._default(z.coerce.bigint(), BigInt(0)),
7
+
foo: z._default(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })), BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts
···
720
720
export const zTypesData = z.object({
721
721
body: z.never().optional(),
722
722
path: z.object({
723
-
id: z.number().int().optional()
723
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).optional()
724
724
}).optional(),
725
725
query: z.object({
726
726
parameterNumber: z.number().default(123),
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.number().int().optional(),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts
···
722
722
export const zTypesData = z.object({
723
723
body: z.optional(z.never()),
724
724
path: z.optional(z.object({
725
-
id: z.optional(z.int())
725
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }))
726
726
})),
727
727
query: z.object({
728
728
parameterNumber: z.number().default(123),
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts
···
710
710
});
711
711
712
712
export const zPageable = z.object({
713
-
page: z._default(z.optional(z.int().check(z.gte(0))), 0),
714
-
size: z.optional(z.int().check(z.gte(1))),
713
+
page: z._default(z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(0))), 0),
714
+
size: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(1))),
715
715
sort: z.optional(z.array(z.string()))
716
716
});
717
717
···
1127
1127
})
1128
1128
]), z.object({
1129
1129
baz: z.union([
1130
-
z.int().check(z.gte(0)),
1130
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1131
1131
z.null()
1132
1132
]),
1133
-
qux: z.int().check(z.gte(0))
1133
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1134
1134
}));
1135
1135
1136
1136
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1138
1138
zNonAsciiStringæøåÆøÅöôêÊ字符串
1139
1139
]), z.object({
1140
1140
baz: z.union([
1141
-
z.int().check(z.gte(0)),
1141
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1142
1142
z.null()
1143
1143
]),
1144
-
qux: z.int().check(z.gte(0))
1144
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1145
1145
}));
1146
1146
1147
1147
/**
···
1585
1585
export const zTypesData = z.object({
1586
1586
body: z.optional(z.never()),
1587
1587
path: z.optional(z.object({
1588
-
id: z.optional(z.int())
1588
+
id: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))
1589
1589
})),
1590
1590
query: z.object({
1591
1591
parameterNumber: z._default(z.number(), 123),
···
1731
1731
zModelWithDictionary
1732
1732
]),
1733
1733
user: z.optional(z.readonly(z.object({
1734
-
id: z.optional(z.readonly(z.int())),
1734
+
id: z.optional(z.readonly(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))),
1735
1735
name: z.optional(z.readonly(z.union([
1736
1736
z.readonly(z.string()),
1737
1737
z.null()
···
1739
1739
})))
1740
1740
})),
1741
1741
path: z.object({
1742
-
id: z.int(),
1742
+
id: z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })),
1743
1743
'api-version': z.string()
1744
1744
}),
1745
1745
query: z.optional(z.never())
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z._default(z.coerce.bigint(), BigInt(0)),
7
+
foo: z._default(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })), BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts
···
708
708
});
709
709
710
710
export const zPageable = z.object({
711
-
page: z.number().int().gte(0).optional().default(0),
712
-
size: z.number().int().gte(1).optional(),
711
+
page: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0).optional().default(0),
712
+
size: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1).optional(),
713
713
sort: z.array(z.string()).optional()
714
714
});
715
715
···
1125
1125
})
1126
1126
]), z.object({
1127
1127
baz: z.union([
1128
-
z.number().int().gte(0),
1128
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1129
1129
z.null()
1130
1130
]),
1131
-
qux: z.number().int().gte(0)
1131
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1132
1132
}));
1133
1133
1134
1134
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1136
1136
zNonAsciiStringæøåÆøÅöôêÊ字符串
1137
1137
]), z.object({
1138
1138
baz: z.union([
1139
-
z.number().int().gte(0),
1139
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1140
1140
z.null()
1141
1141
]),
1142
-
qux: z.number().int().gte(0)
1142
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1143
1143
}));
1144
1144
1145
1145
/**
···
1583
1583
export const zTypesData = z.object({
1584
1584
body: z.never().optional(),
1585
1585
path: z.object({
1586
-
id: z.number().int().optional()
1586
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).optional()
1587
1587
}).optional(),
1588
1588
query: z.object({
1589
1589
parameterNumber: z.number().default(123),
···
1729
1729
zModelWithDictionary
1730
1730
]),
1731
1731
user: z.object({
1732
-
id: z.number().int().readonly().optional(),
1732
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly().optional(),
1733
1733
name: z.union([
1734
1734
z.string().readonly(),
1735
1735
z.null()
···
1737
1737
}).readonly().optional()
1738
1738
}).optional(),
1739
1739
path: z.object({
1740
-
id: z.number().int(),
1740
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }),
1741
1741
'api-version': z.string()
1742
1742
}),
1743
1743
query: z.never().optional()
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.number().int().optional(),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts
···
710
710
});
711
711
712
712
export const zPageable = z.object({
713
-
page: z.optional(z.int().gte(0)).default(0),
714
-
size: z.optional(z.int().gte(1)),
713
+
page: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0)).default(0),
714
+
size: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1)),
715
715
sort: z.optional(z.array(z.string()))
716
716
});
717
717
···
1127
1127
})
1128
1128
]), z.object({
1129
1129
baz: z.union([
1130
-
z.int().gte(0),
1130
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1131
1131
z.null()
1132
1132
]),
1133
-
qux: z.int().gte(0)
1133
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1134
1134
}));
1135
1135
1136
1136
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1138
1138
zNonAsciiStringæøåÆøÅöôêÊ字符串
1139
1139
]), z.object({
1140
1140
baz: z.union([
1141
-
z.int().gte(0),
1141
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1142
1142
z.null()
1143
1143
]),
1144
-
qux: z.int().gte(0)
1144
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1145
1145
}));
1146
1146
1147
1147
/**
···
1585
1585
export const zTypesData = z.object({
1586
1586
body: z.optional(z.never()),
1587
1587
path: z.optional(z.object({
1588
-
id: z.optional(z.int())
1588
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }))
1589
1589
})),
1590
1590
query: z.object({
1591
1591
parameterNumber: z.number().default(123),
···
1731
1731
zModelWithDictionary
1732
1732
]),
1733
1733
user: z.optional(z.object({
1734
-
id: z.optional(z.int().readonly()),
1734
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly()),
1735
1735
name: z.optional(z.union([
1736
1736
z.string().readonly(),
1737
1737
z.null()
···
1739
1739
}).readonly())
1740
1740
})),
1741
1741
path: z.object({
1742
-
id: z.int(),
1742
+
id: z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }),
1743
1743
'api-version': z.string()
1744
1744
}),
1745
1745
query: z.optional(z.never())
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts
···
707
707
});
708
708
709
709
export const zPageable = z.object({
710
-
page: z._default(z.optional(z.int().check(z.gte(0))), 0),
711
-
size: z.optional(z.int().check(z.gte(1))),
710
+
page: z._default(z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(0))), 0),
711
+
size: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(1))),
712
712
sort: z.optional(z.array(z.string()))
713
713
});
714
714
···
1133
1133
})
1134
1134
]), z.object({
1135
1135
baz: z.union([
1136
-
z.int().check(z.gte(0)),
1136
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1137
1137
z.null()
1138
1138
]),
1139
-
qux: z.int().check(z.gte(0))
1139
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1140
1140
}));
1141
1141
1142
1142
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1144
1144
zNonAsciiStringæøåÆøÅöôêÊ字符串
1145
1145
]), z.object({
1146
1146
baz: z.union([
1147
-
z.int().check(z.gte(0)),
1147
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1148
1148
z.null()
1149
1149
]),
1150
-
qux: z.int().check(z.gte(0))
1150
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1151
1151
}));
1152
1152
1153
1153
/**
···
1600
1600
export const zTypesData = z.object({
1601
1601
body: z.optional(z.never()),
1602
1602
path: z.optional(z.object({
1603
-
id: z.optional(z.int())
1603
+
id: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))
1604
1604
})),
1605
1605
query: z.object({
1606
1606
parameterNumber: z._default(z.number(), 123),
···
1747
1747
zModelWithDictionary
1748
1748
]),
1749
1749
user: z.optional(z.readonly(z.object({
1750
-
id: z.optional(z.readonly(z.int())),
1750
+
id: z.optional(z.readonly(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))),
1751
1751
name: z.optional(z.readonly(z.union([
1752
1752
z.readonly(z.string()),
1753
1753
z.null()
···
1755
1755
})))
1756
1756
})),
1757
1757
path: z.object({
1758
-
id: z.int(),
1758
+
id: z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })),
1759
1759
'api-version': z.string()
1760
1760
}),
1761
1761
query: z.optional(z.never())
+7
-7
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts
+7
-7
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts
···
15
15
z.literal(true)
16
16
])),
17
17
corge: z.optional(z.record(z.string(), z.unknown())),
18
-
garply: z.optional(z.coerce.bigint()),
18
+
garply: z.optional(z.literal(BigInt('10'))),
19
19
numberInt8: z.optional(z.literal(100)),
20
20
numberInt16: z.optional(z.literal(1000)),
21
21
numberInt32: z.optional(z.literal(100000)),
22
-
numberInt64: z.optional(z.literal(1000000000000)),
22
+
numberInt64: z.optional(z.literal(BigInt(1000000000000))),
23
23
numberUint8: z.optional(z.literal(200)),
24
24
numberUint16: z.optional(z.literal(50000)),
25
25
numberUint32: z.optional(z.literal(3000000000)),
26
-
numberUint64: z.optional(z.literal(18000000000000000000)),
26
+
numberUint64: z.optional(z.literal(BigInt(18000000000000000000))),
27
27
integerInt8: z.optional(z.literal(-100)),
28
28
integerInt16: z.optional(z.literal(-1000)),
29
29
integerInt32: z.optional(z.literal(-100000)),
30
-
integerInt64: z.optional(z.literal(-1000000000000)),
30
+
integerInt64: z.optional(z.literal(BigInt(-1000000000000))),
31
31
integerUint8: z.optional(z.literal(255)),
32
32
integerUint16: z.optional(z.literal(65535)),
33
33
integerUint32: z.optional(z.literal(4294967295)),
34
-
integerUint64: z.optional(z.int()),
35
-
stringInt64: z.optional(z.literal('-9223372036854775808')),
36
-
stringUint64: z.optional(z.literal('18446744073709551615'))
34
+
integerUint64: z.optional(z.literal(BigInt('18446744073709551615'))),
35
+
stringInt64: z.optional(z.literal(BigInt('-9223372036854775808'))),
36
+
stringUint64: z.optional(z.literal(BigInt('18446744073709551615')))
37
37
});
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z._default(z.coerce.bigint(), BigInt(0)),
7
+
foo: z._default(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })), BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts
···
3
3
import * as z from 'zod/v4-mini';
4
4
5
5
export const zFoo = z.object({
6
-
foo: z.optional(z.coerce.bigint().check(z.gte(BigInt(0)), z.lte(BigInt(100))))
6
+
foo: z.optional(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }), z.gte(BigInt(0)), z.lte(BigInt(100))))
7
7
});
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/default/zod.gen.ts
···
705
705
});
706
706
707
707
export const zPageable = z.object({
708
-
page: z.number().int().gte(0).optional().default(0),
709
-
size: z.number().int().gte(1).optional(),
708
+
page: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0).optional().default(0),
709
+
size: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1).optional(),
710
710
sort: z.array(z.string()).optional()
711
711
});
712
712
···
1131
1131
})
1132
1132
]), z.object({
1133
1133
baz: z.union([
1134
-
z.number().int().gte(0),
1134
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1135
1135
z.null()
1136
1136
]),
1137
-
qux: z.number().int().gte(0)
1137
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1138
1138
}));
1139
1139
1140
1140
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1142
1142
zNonAsciiStringæøåÆøÅöôêÊ字符串
1143
1143
]), z.object({
1144
1144
baz: z.union([
1145
-
z.number().int().gte(0),
1145
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1146
1146
z.null()
1147
1147
]),
1148
-
qux: z.number().int().gte(0)
1148
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1149
1149
}));
1150
1150
1151
1151
/**
···
1598
1598
export const zTypesData = z.object({
1599
1599
body: z.never().optional(),
1600
1600
path: z.object({
1601
-
id: z.number().int().optional()
1601
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).optional()
1602
1602
}).optional(),
1603
1603
query: z.object({
1604
1604
parameterNumber: z.number().default(123),
···
1745
1745
zModelWithDictionary
1746
1746
]),
1747
1747
user: z.object({
1748
-
id: z.number().int().readonly().optional(),
1748
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly().optional(),
1749
1749
name: z.union([
1750
1750
z.string().readonly(),
1751
1751
z.null()
···
1753
1753
}).readonly().optional()
1754
1754
}).optional(),
1755
1755
path: z.object({
1756
-
id: z.number().int(),
1756
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }),
1757
1757
'api-version': z.string()
1758
1758
}),
1759
1759
query: z.never().optional()
+7
-7
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts
+7
-7
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts
···
15
15
z.literal(true)
16
16
]).optional(),
17
17
corge: z.record(z.unknown()).optional(),
18
-
garply: z.coerce.bigint().optional(),
18
+
garply: z.literal(BigInt('10')).optional(),
19
19
numberInt8: z.literal(100).optional(),
20
20
numberInt16: z.literal(1000).optional(),
21
21
numberInt32: z.literal(100000).optional(),
22
-
numberInt64: z.literal(1000000000000).optional(),
22
+
numberInt64: z.literal(BigInt(1000000000000)).optional(),
23
23
numberUint8: z.literal(200).optional(),
24
24
numberUint16: z.literal(50000).optional(),
25
25
numberUint32: z.literal(3000000000).optional(),
26
-
numberUint64: z.literal(18000000000000000000).optional(),
26
+
numberUint64: z.literal(BigInt(18000000000000000000)).optional(),
27
27
integerInt8: z.literal(-100).optional(),
28
28
integerInt16: z.literal(-1000).optional(),
29
29
integerInt32: z.literal(-100000).optional(),
30
-
integerInt64: z.literal(-1000000000000).optional(),
30
+
integerInt64: z.literal(BigInt(-1000000000000)).optional(),
31
31
integerUint8: z.literal(255).optional(),
32
32
integerUint16: z.literal(65535).optional(),
33
33
integerUint32: z.literal(4294967295).optional(),
34
-
integerUint64: z.number().int().optional(),
35
-
stringInt64: z.literal('-9223372036854775808').optional(),
36
-
stringUint64: z.literal('18446744073709551615').optional()
34
+
integerUint64: z.literal(BigInt('18446744073709551615')).optional(),
35
+
stringInt64: z.literal(BigInt('-9223372036854775808')).optional(),
36
+
stringUint64: z.literal(BigInt('18446744073709551615')).optional()
37
37
});
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.number().int().optional(),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts
···
3
3
import { z } from 'zod';
4
4
5
5
export const zFoo = z.object({
6
-
foo: z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100)).optional()
6
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).gte(BigInt(0)).lte(BigInt(100)).optional()
7
7
});
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts
···
707
707
});
708
708
709
709
export const zPageable = z.object({
710
-
page: z.optional(z.int().gte(0)).default(0),
711
-
size: z.optional(z.int().gte(1)),
710
+
page: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0)).default(0),
711
+
size: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1)),
712
712
sort: z.optional(z.array(z.string()))
713
713
});
714
714
···
1133
1133
})
1134
1134
]), z.object({
1135
1135
baz: z.union([
1136
-
z.int().gte(0),
1136
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1137
1137
z.null()
1138
1138
]),
1139
-
qux: z.int().gte(0)
1139
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1140
1140
}));
1141
1141
1142
1142
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1144
1144
zNonAsciiStringæøåÆøÅöôêÊ字符串
1145
1145
]), z.object({
1146
1146
baz: z.union([
1147
-
z.int().gte(0),
1147
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1148
1148
z.null()
1149
1149
]),
1150
-
qux: z.int().gte(0)
1150
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1151
1151
}));
1152
1152
1153
1153
/**
···
1600
1600
export const zTypesData = z.object({
1601
1601
body: z.optional(z.never()),
1602
1602
path: z.optional(z.object({
1603
-
id: z.optional(z.int())
1603
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }))
1604
1604
})),
1605
1605
query: z.object({
1606
1606
parameterNumber: z.number().default(123),
···
1747
1747
zModelWithDictionary
1748
1748
]),
1749
1749
user: z.optional(z.object({
1750
-
id: z.optional(z.int().readonly()),
1750
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly()),
1751
1751
name: z.optional(z.union([
1752
1752
z.string().readonly(),
1753
1753
z.null()
···
1755
1755
}).readonly())
1756
1756
})),
1757
1757
path: z.object({
1758
-
id: z.int(),
1758
+
id: z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }),
1759
1759
'api-version': z.string()
1760
1760
}),
1761
1761
query: z.optional(z.never())
+7
-7
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts
+7
-7
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts
···
15
15
z.literal(true)
16
16
])),
17
17
corge: z.optional(z.record(z.string(), z.unknown())),
18
-
garply: z.optional(z.coerce.bigint()),
18
+
garply: z.optional(z.literal(BigInt('10'))),
19
19
numberInt8: z.optional(z.literal(100)),
20
20
numberInt16: z.optional(z.literal(1000)),
21
21
numberInt32: z.optional(z.literal(100000)),
22
-
numberInt64: z.optional(z.literal(1000000000000)),
22
+
numberInt64: z.optional(z.literal(BigInt(1000000000000))),
23
23
numberUint8: z.optional(z.literal(200)),
24
24
numberUint16: z.optional(z.literal(50000)),
25
25
numberUint32: z.optional(z.literal(3000000000)),
26
-
numberUint64: z.optional(z.literal(18000000000000000000)),
26
+
numberUint64: z.optional(z.literal(BigInt(18000000000000000000))),
27
27
integerInt8: z.optional(z.literal(-100)),
28
28
integerInt16: z.optional(z.literal(-1000)),
29
29
integerInt32: z.optional(z.literal(-100000)),
30
-
integerInt64: z.optional(z.literal(-1000000000000)),
30
+
integerInt64: z.optional(z.literal(BigInt(-1000000000000))),
31
31
integerUint8: z.optional(z.literal(255)),
32
32
integerUint16: z.optional(z.literal(65535)),
33
33
integerUint32: z.optional(z.literal(4294967295)),
34
-
integerUint64: z.optional(z.int()),
35
-
stringInt64: z.optional(z.literal('-9223372036854775808')),
36
-
stringUint64: z.optional(z.literal('18446744073709551615'))
34
+
integerUint64: z.optional(z.literal(BigInt('18446744073709551615'))),
35
+
stringInt64: z.optional(z.literal(BigInt('-9223372036854775808'))),
36
+
stringUint64: z.optional(z.literal(BigInt('18446744073709551615')))
37
37
});
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts
···
3
3
import { z } from 'zod/v4';
4
4
5
5
export const zFoo = z.object({
6
-
foo: z.optional(z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100)))
6
+
foo: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).gte(BigInt(0)).lte(BigInt(100)))
7
7
});
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts
···
722
722
export const zTypesData = z.object({
723
723
body: z.optional(z.never()),
724
724
path: z.optional(z.object({
725
-
id: z.optional(z.int())
725
+
id: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))
726
726
})),
727
727
query: z.object({
728
728
parameterNumber: z._default(z.number(), 123),
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z._default(z.coerce.bigint(), BigInt(0)),
7
+
foo: z._default(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })), BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts
···
720
720
export const zTypesData = z.object({
721
721
body: z.never().optional(),
722
722
path: z.object({
723
-
id: z.number().int().optional()
723
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).optional()
724
724
}).optional(),
725
725
query: z.object({
726
726
parameterNumber: z.number().default(123),
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.number().int().optional(),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts
···
722
722
export const zTypesData = z.object({
723
723
body: z.optional(z.never()),
724
724
path: z.optional(z.object({
725
-
id: z.optional(z.int())
725
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }))
726
726
})),
727
727
query: z.object({
728
728
parameterNumber: z.number().default(123),
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts
···
710
710
});
711
711
712
712
export const zPageable = z.object({
713
-
page: z._default(z.optional(z.int().check(z.gte(0))), 0),
714
-
size: z.optional(z.int().check(z.gte(1))),
713
+
page: z._default(z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(0))), 0),
714
+
size: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(1))),
715
715
sort: z.optional(z.array(z.string()))
716
716
});
717
717
···
1127
1127
})
1128
1128
]), z.object({
1129
1129
baz: z.union([
1130
-
z.int().check(z.gte(0)),
1130
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1131
1131
z.null()
1132
1132
]),
1133
-
qux: z.int().check(z.gte(0))
1133
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1134
1134
}));
1135
1135
1136
1136
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1138
1138
zNonAsciiStringæøåÆøÅöôêÊ字符串
1139
1139
]), z.object({
1140
1140
baz: z.union([
1141
-
z.int().check(z.gte(0)),
1141
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1142
1142
z.null()
1143
1143
]),
1144
-
qux: z.int().check(z.gte(0))
1144
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1145
1145
}));
1146
1146
1147
1147
/**
···
1585
1585
export const zTypesData = z.object({
1586
1586
body: z.optional(z.never()),
1587
1587
path: z.optional(z.object({
1588
-
id: z.optional(z.int())
1588
+
id: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))
1589
1589
})),
1590
1590
query: z.object({
1591
1591
parameterNumber: z._default(z.number(), 123),
···
1731
1731
zModelWithDictionary
1732
1732
]),
1733
1733
user: z.optional(z.readonly(z.object({
1734
-
id: z.optional(z.readonly(z.int())),
1734
+
id: z.optional(z.readonly(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))),
1735
1735
name: z.optional(z.readonly(z.union([
1736
1736
z.readonly(z.string()),
1737
1737
z.null()
···
1739
1739
})))
1740
1740
})),
1741
1741
path: z.object({
1742
-
id: z.int(),
1742
+
id: z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })),
1743
1743
'api-version': z.string()
1744
1744
}),
1745
1745
query: z.optional(z.never())
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z._default(z.coerce.bigint(), BigInt(0)),
7
+
foo: z._default(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })), BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts
···
708
708
});
709
709
710
710
export const zPageable = z.object({
711
-
page: z.number().int().gte(0).optional().default(0),
712
-
size: z.number().int().gte(1).optional(),
711
+
page: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0).optional().default(0),
712
+
size: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1).optional(),
713
713
sort: z.array(z.string()).optional()
714
714
});
715
715
···
1125
1125
})
1126
1126
]), z.object({
1127
1127
baz: z.union([
1128
-
z.number().int().gte(0),
1128
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1129
1129
z.null()
1130
1130
]),
1131
-
qux: z.number().int().gte(0)
1131
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1132
1132
}));
1133
1133
1134
1134
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1136
1136
zNonAsciiStringæøåÆøÅöôêÊ字符串
1137
1137
]), z.object({
1138
1138
baz: z.union([
1139
-
z.number().int().gte(0),
1139
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1140
1140
z.null()
1141
1141
]),
1142
-
qux: z.number().int().gte(0)
1142
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1143
1143
}));
1144
1144
1145
1145
/**
···
1583
1583
export const zTypesData = z.object({
1584
1584
body: z.never().optional(),
1585
1585
path: z.object({
1586
-
id: z.number().int().optional()
1586
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).optional()
1587
1587
}).optional(),
1588
1588
query: z.object({
1589
1589
parameterNumber: z.number().default(123),
···
1729
1729
zModelWithDictionary
1730
1730
]),
1731
1731
user: z.object({
1732
-
id: z.number().int().readonly().optional(),
1732
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly().optional(),
1733
1733
name: z.union([
1734
1734
z.string().readonly(),
1735
1735
z.null()
···
1737
1737
}).readonly().optional()
1738
1738
}).optional(),
1739
1739
path: z.object({
1740
-
id: z.number().int(),
1740
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }),
1741
1741
'api-version': z.string()
1742
1742
}),
1743
1743
query: z.never().optional()
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.number().int().optional(),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts
···
710
710
});
711
711
712
712
export const zPageable = z.object({
713
-
page: z.optional(z.int().gte(0)).default(0),
714
-
size: z.optional(z.int().gte(1)),
713
+
page: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0)).default(0),
714
+
size: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1)),
715
715
sort: z.optional(z.array(z.string()))
716
716
});
717
717
···
1127
1127
})
1128
1128
]), z.object({
1129
1129
baz: z.union([
1130
-
z.int().gte(0),
1130
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1131
1131
z.null()
1132
1132
]),
1133
-
qux: z.int().gte(0)
1133
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1134
1134
}));
1135
1135
1136
1136
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1138
1138
zNonAsciiStringæøåÆøÅöôêÊ字符串
1139
1139
]), z.object({
1140
1140
baz: z.union([
1141
-
z.int().gte(0),
1141
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1142
1142
z.null()
1143
1143
]),
1144
-
qux: z.int().gte(0)
1144
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1145
1145
}));
1146
1146
1147
1147
/**
···
1585
1585
export const zTypesData = z.object({
1586
1586
body: z.optional(z.never()),
1587
1587
path: z.optional(z.object({
1588
-
id: z.optional(z.int())
1588
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }))
1589
1589
})),
1590
1590
query: z.object({
1591
1591
parameterNumber: z.number().default(123),
···
1731
1731
zModelWithDictionary
1732
1732
]),
1733
1733
user: z.optional(z.object({
1734
-
id: z.optional(z.int().readonly()),
1734
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly()),
1735
1735
name: z.optional(z.union([
1736
1736
z.string().readonly(),
1737
1737
z.null()
···
1739
1739
}).readonly())
1740
1740
})),
1741
1741
path: z.object({
1742
-
id: z.int(),
1742
+
id: z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }),
1743
1743
'api-version': z.string()
1744
1744
}),
1745
1745
query: z.optional(z.never())
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts
···
707
707
});
708
708
709
709
export const zPageable = z.object({
710
-
page: z._default(z.optional(z.int().check(z.gte(0))), 0),
711
-
size: z.optional(z.int().check(z.gte(1))),
710
+
page: z._default(z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(0))), 0),
711
+
size: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }), z.gte(1))),
712
712
sort: z.optional(z.array(z.string()))
713
713
});
714
714
···
1133
1133
})
1134
1134
]), z.object({
1135
1135
baz: z.union([
1136
-
z.int().check(z.gte(0)),
1136
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1137
1137
z.null()
1138
1138
]),
1139
-
qux: z.int().check(z.gte(0))
1139
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1140
1140
}));
1141
1141
1142
1142
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1144
1144
zNonAsciiStringæøåÆøÅöôêÊ字符串
1145
1145
]), z.object({
1146
1146
baz: z.union([
1147
-
z.int().check(z.gte(0)),
1147
+
z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint16 to be >= 0' }), z.maximum(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }), z.gte(0)),
1148
1148
z.null()
1149
1149
]),
1150
-
qux: z.int().check(z.gte(0))
1150
+
qux: z.int().check(z.minimum(0, { error: 'Invalid value: Expected uint8 to be >= 0' }), z.maximum(255, { error: 'Invalid value: Expected uint8 to be <= 255' }), z.gte(0))
1151
1151
}));
1152
1152
1153
1153
/**
···
1600
1600
export const zTypesData = z.object({
1601
1601
body: z.optional(z.never()),
1602
1602
path: z.optional(z.object({
1603
-
id: z.optional(z.int())
1603
+
id: z.optional(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))
1604
1604
})),
1605
1605
query: z.object({
1606
1606
parameterNumber: z._default(z.number(), 123),
···
1747
1747
zModelWithDictionary
1748
1748
]),
1749
1749
user: z.optional(z.readonly(z.object({
1750
-
id: z.optional(z.readonly(z.int())),
1750
+
id: z.optional(z.readonly(z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })))),
1751
1751
name: z.optional(z.readonly(z.union([
1752
1752
z.readonly(z.string()),
1753
1753
z.null()
···
1755
1755
})))
1756
1756
})),
1757
1757
path: z.object({
1758
-
id: z.int(),
1758
+
id: z.int().check(z.minimum(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }), z.maximum(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })),
1759
1759
'api-version': z.string()
1760
1760
}),
1761
1761
query: z.optional(z.never())
+7
-7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts
+7
-7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts
···
15
15
z.literal(true)
16
16
])),
17
17
corge: z.optional(z.record(z.string(), z.unknown())),
18
-
garply: z.optional(z.coerce.bigint()),
18
+
garply: z.optional(z.literal(BigInt('10'))),
19
19
numberInt8: z.optional(z.literal(100)),
20
20
numberInt16: z.optional(z.literal(1000)),
21
21
numberInt32: z.optional(z.literal(100000)),
22
-
numberInt64: z.optional(z.literal(1000000000000)),
22
+
numberInt64: z.optional(z.literal(BigInt(1000000000000))),
23
23
numberUint8: z.optional(z.literal(200)),
24
24
numberUint16: z.optional(z.literal(50000)),
25
25
numberUint32: z.optional(z.literal(3000000000)),
26
-
numberUint64: z.optional(z.literal(18000000000000000000)),
26
+
numberUint64: z.optional(z.literal(BigInt(18000000000000000000))),
27
27
integerInt8: z.optional(z.literal(-100)),
28
28
integerInt16: z.optional(z.literal(-1000)),
29
29
integerInt32: z.optional(z.literal(-100000)),
30
-
integerInt64: z.optional(z.literal(-1000000000000)),
30
+
integerInt64: z.optional(z.literal(BigInt(-1000000000000))),
31
31
integerUint8: z.optional(z.literal(255)),
32
32
integerUint16: z.optional(z.literal(65535)),
33
33
integerUint32: z.optional(z.literal(4294967295)),
34
-
integerUint64: z.optional(z.int()),
35
-
stringInt64: z.optional(z.literal('-9223372036854775808')),
36
-
stringUint64: z.optional(z.literal('18446744073709551615'))
34
+
integerUint64: z.optional(z.literal(BigInt('18446744073709551615'))),
35
+
stringInt64: z.optional(z.literal(BigInt('-9223372036854775808'))),
36
+
stringUint64: z.optional(z.literal(BigInt('18446744073709551615')))
37
37
});
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z._default(z.coerce.bigint(), BigInt(0)),
7
+
foo: z._default(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' })), BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts
···
3
3
import * as z from 'zod/mini';
4
4
5
5
export const zFoo = z.object({
6
-
foo: z.optional(z.coerce.bigint().check(z.gte(BigInt(0)), z.lte(BigInt(100))))
6
+
foo: z.optional(z.coerce.bigint().check(z.minimum(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }), z.maximum(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }), z.gte(BigInt(0)), z.lte(BigInt(100))))
7
7
});
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts
···
705
705
});
706
706
707
707
export const zPageable = z.object({
708
-
page: z.number().int().gte(0).optional().default(0),
709
-
size: z.number().int().gte(1).optional(),
708
+
page: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0).optional().default(0),
709
+
size: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1).optional(),
710
710
sort: z.array(z.string()).optional()
711
711
});
712
712
···
1131
1131
})
1132
1132
]), z.object({
1133
1133
baz: z.union([
1134
-
z.number().int().gte(0),
1134
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1135
1135
z.null()
1136
1136
]),
1137
-
qux: z.number().int().gte(0)
1137
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1138
1138
}));
1139
1139
1140
1140
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1142
1142
zNonAsciiStringæøåÆøÅöôêÊ字符串
1143
1143
]), z.object({
1144
1144
baz: z.union([
1145
-
z.number().int().gte(0),
1145
+
z.number().int().min(0, { message: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { message: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1146
1146
z.null()
1147
1147
]),
1148
-
qux: z.number().int().gte(0)
1148
+
qux: z.number().int().min(0, { message: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { message: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1149
1149
}));
1150
1150
1151
1151
/**
···
1598
1598
export const zTypesData = z.object({
1599
1599
body: z.never().optional(),
1600
1600
path: z.object({
1601
-
id: z.number().int().optional()
1601
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).optional()
1602
1602
}).optional(),
1603
1603
query: z.object({
1604
1604
parameterNumber: z.number().default(123),
···
1745
1745
zModelWithDictionary
1746
1746
]),
1747
1747
user: z.object({
1748
-
id: z.number().int().readonly().optional(),
1748
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly().optional(),
1749
1749
name: z.union([
1750
1750
z.string().readonly(),
1751
1751
z.null()
···
1753
1753
}).readonly().optional()
1754
1754
}).optional(),
1755
1755
path: z.object({
1756
-
id: z.number().int(),
1756
+
id: z.number().int().min(-2147483648, { message: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { message: 'Invalid value: Expected int32 to be <= 2147483647' }),
1757
1757
'api-version': z.string()
1758
1758
}),
1759
1759
query: z.never().optional()
+7
-7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts
+7
-7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts
···
15
15
z.literal(true)
16
16
]).optional(),
17
17
corge: z.record(z.unknown()).optional(),
18
-
garply: z.coerce.bigint().optional(),
18
+
garply: z.literal(BigInt('10')).optional(),
19
19
numberInt8: z.literal(100).optional(),
20
20
numberInt16: z.literal(1000).optional(),
21
21
numberInt32: z.literal(100000).optional(),
22
-
numberInt64: z.literal(1000000000000).optional(),
22
+
numberInt64: z.literal(BigInt(1000000000000)).optional(),
23
23
numberUint8: z.literal(200).optional(),
24
24
numberUint16: z.literal(50000).optional(),
25
25
numberUint32: z.literal(3000000000).optional(),
26
-
numberUint64: z.literal(18000000000000000000).optional(),
26
+
numberUint64: z.literal(BigInt(18000000000000000000)).optional(),
27
27
integerInt8: z.literal(-100).optional(),
28
28
integerInt16: z.literal(-1000).optional(),
29
29
integerInt32: z.literal(-100000).optional(),
30
-
integerInt64: z.literal(-1000000000000).optional(),
30
+
integerInt64: z.literal(BigInt(-1000000000000)).optional(),
31
31
integerUint8: z.literal(255).optional(),
32
32
integerUint16: z.literal(65535).optional(),
33
33
integerUint32: z.literal(4294967295).optional(),
34
-
integerUint64: z.number().int().optional(),
35
-
stringInt64: z.literal('-9223372036854775808').optional(),
36
-
stringUint64: z.literal('18446744073709551615').optional()
34
+
integerUint64: z.literal(BigInt('18446744073709551615')).optional(),
35
+
stringInt64: z.literal(BigInt('-9223372036854775808')).optional(),
36
+
stringUint64: z.literal(BigInt('18446744073709551615')).optional()
37
37
});
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.number().int().optional(),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts
···
3
3
import { z } from 'zod/v3';
4
4
5
5
export const zFoo = z.object({
6
-
foo: z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100)).optional()
6
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).gte(BigInt(0)).lte(BigInt(100)).optional()
7
7
});
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts
+9
-9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts
···
707
707
});
708
708
709
709
export const zPageable = z.object({
710
-
page: z.optional(z.int().gte(0)).default(0),
711
-
size: z.optional(z.int().gte(1)),
710
+
page: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(0)).default(0),
711
+
size: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).gte(1)),
712
712
sort: z.optional(z.array(z.string()))
713
713
});
714
714
···
1133
1133
})
1134
1134
]), z.object({
1135
1135
baz: z.union([
1136
-
z.int().gte(0),
1136
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1137
1137
z.null()
1138
1138
]),
1139
-
qux: z.int().gte(0)
1139
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1140
1140
}));
1141
1141
1142
1142
export const zModelWithOneOfAndProperties = z.intersection(z.union([
···
1144
1144
zNonAsciiStringæøåÆøÅöôêÊ字符串
1145
1145
]), z.object({
1146
1146
baz: z.union([
1147
-
z.int().gte(0),
1147
+
z.int().min(0, { error: 'Invalid value: Expected uint16 to be >= 0' }).max(65535, { error: 'Invalid value: Expected uint16 to be <= 65535' }).gte(0),
1148
1148
z.null()
1149
1149
]),
1150
-
qux: z.int().gte(0)
1150
+
qux: z.int().min(0, { error: 'Invalid value: Expected uint8 to be >= 0' }).max(255, { error: 'Invalid value: Expected uint8 to be <= 255' }).gte(0)
1151
1151
}));
1152
1152
1153
1153
/**
···
1600
1600
export const zTypesData = z.object({
1601
1601
body: z.optional(z.never()),
1602
1602
path: z.optional(z.object({
1603
-
id: z.optional(z.int())
1603
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }))
1604
1604
})),
1605
1605
query: z.object({
1606
1606
parameterNumber: z.number().default(123),
···
1747
1747
zModelWithDictionary
1748
1748
]),
1749
1749
user: z.optional(z.object({
1750
-
id: z.optional(z.int().readonly()),
1750
+
id: z.optional(z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }).readonly()),
1751
1751
name: z.optional(z.union([
1752
1752
z.string().readonly(),
1753
1753
z.null()
···
1755
1755
}).readonly())
1756
1756
})),
1757
1757
path: z.object({
1758
-
id: z.int(),
1758
+
id: z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' }),
1759
1759
'api-version': z.string()
1760
1760
}),
1761
1761
query: z.optional(z.never())
+7
-7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts
+7
-7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts
···
15
15
z.literal(true)
16
16
])),
17
17
corge: z.optional(z.record(z.string(), z.unknown())),
18
-
garply: z.optional(z.coerce.bigint()),
18
+
garply: z.optional(z.literal(BigInt('10'))),
19
19
numberInt8: z.optional(z.literal(100)),
20
20
numberInt16: z.optional(z.literal(1000)),
21
21
numberInt32: z.optional(z.literal(100000)),
22
-
numberInt64: z.optional(z.literal(1000000000000)),
22
+
numberInt64: z.optional(z.literal(BigInt(1000000000000))),
23
23
numberUint8: z.optional(z.literal(200)),
24
24
numberUint16: z.optional(z.literal(50000)),
25
25
numberUint32: z.optional(z.literal(3000000000)),
26
-
numberUint64: z.optional(z.literal(18000000000000000000)),
26
+
numberUint64: z.optional(z.literal(BigInt(18000000000000000000))),
27
27
integerInt8: z.optional(z.literal(-100)),
28
28
integerInt16: z.optional(z.literal(-1000)),
29
29
integerInt32: z.optional(z.literal(-100000)),
30
-
integerInt64: z.optional(z.literal(-1000000000000)),
30
+
integerInt64: z.optional(z.literal(BigInt(-1000000000000))),
31
31
integerUint8: z.optional(z.literal(255)),
32
32
integerUint16: z.optional(z.literal(65535)),
33
33
integerUint32: z.optional(z.literal(4294967295)),
34
-
integerUint64: z.optional(z.int()),
35
-
stringInt64: z.optional(z.literal('-9223372036854775808')),
36
-
stringUint64: z.optional(z.literal('18446744073709551615'))
34
+
integerUint64: z.optional(z.literal(BigInt('18446744073709551615'))),
35
+
stringInt64: z.optional(z.literal(BigInt('-9223372036854775808'))),
36
+
stringUint64: z.optional(z.literal(BigInt('18446744073709551615')))
37
37
});
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts
···
4
4
5
5
export const zFoo = z.object({
6
6
bar: z.optional(z.int()),
7
-
foo: z.coerce.bigint().default(BigInt(0)),
7
+
foo: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).default(BigInt(0)),
8
8
id: z.string()
9
9
});
10
10
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts
+1
-1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts
···
3
3
import { z } from 'zod';
4
4
5
5
export const zFoo = z.object({
6
-
foo: z.optional(z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100)))
6
+
foo: z.optional(z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).gte(BigInt(0)).lte(BigInt(100)))
7
7
});
+23
packages/openapi-ts/src/plugins/valibot/types.d.ts
+23
packages/openapi-ts/src/plugins/valibot/types.d.ts
···
359
359
360
360
type Resolvers = Plugin.Resolvers<{
361
361
/**
362
+
* Resolvers for number schemas.
363
+
*
364
+
* Allows customization of how number types are rendered, including
365
+
* per-format handling.
366
+
*/
367
+
number?: {
368
+
/**
369
+
* Resolvers for number formats (e.g., `float`, `double`, `int32`).
370
+
*
371
+
* Each key represents a specific format name with a custom
372
+
* resolver function that controls how that format is rendered.
373
+
*
374
+
* Example path: `~resolvers.number.formats.float`
375
+
*
376
+
* Returning `undefined` from a resolver will apply the default
377
+
* generation behavior for that format.
378
+
*/
379
+
formats?: Record<
380
+
string,
381
+
(args: FormatResolverArgs) => boolean | number | undefined
382
+
>;
383
+
};
384
+
/**
362
385
* Resolvers for object schemas.
363
386
*
364
387
* Allows customization of how object types are rendered.
+10
-11
packages/openapi-ts/src/plugins/valibot/v1/plugin.ts
+10
-11
packages/openapi-ts/src/plugins/valibot/v1/plugin.ts
···
5
5
import type { IR } from '~/ir/types';
6
6
import { buildName } from '~/openApi/shared/utils/name';
7
7
import type { SchemaWithType } from '~/plugins';
8
+
import { maybeBigInt } from '~/plugins/shared/utils/coerce';
8
9
import { $ } from '~/ts-dsl';
9
10
import { pathToJsonPointer, refToName } from '~/utils/ref';
10
11
11
12
import { exportAst } from '../shared/export';
12
-
import { numberParameter } from '../shared/numbers';
13
13
import { irOperationToAst } from '../shared/operation';
14
14
import { pipesToAst } from '../shared/pipesToAst';
15
15
import type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';
···
87
87
path: ref([...fromRef(state.path), 'items', index]),
88
88
},
89
89
});
90
-
return pipesToAst({ pipes: itemAst.pipes, plugin });
90
+
return pipesToAst(itemAst.pipes, plugin);
91
91
});
92
92
93
93
if (schema.logicalOperator === 'and') {
···
124
124
ast.pipes.push(readonlyExpression);
125
125
}
126
126
127
-
let callParameter: ReturnType<typeof $.fromValue> | undefined;
128
-
129
127
if (schema.default !== undefined) {
130
-
const isBigInt = schema.type === 'integer' && schema.format === 'int64';
131
-
callParameter = numberParameter({ isBigInt, value: schema.default });
132
128
ast.pipes = [
133
129
$(v)
134
130
.attr(identifiers.schemas.optional)
135
-
.call(pipesToAst({ pipes: ast.pipes, plugin }), callParameter),
131
+
.call(
132
+
pipesToAst(ast.pipes, plugin),
133
+
schema.type === 'integer' || schema.type === 'number'
134
+
? maybeBigInt(schema.default, schema.format)
135
+
: $.fromValue(schema.default),
136
+
),
136
137
];
137
-
}
138
-
139
-
if (optional && !callParameter) {
138
+
} else if (optional) {
140
139
ast.pipes = [
141
140
$(v)
142
141
.attr(identifiers.schemas.optional)
143
-
.call(pipesToAst({ pipes: ast.pipes, plugin })),
142
+
.call(pipesToAst(ast.pipes, plugin)),
144
143
];
145
144
}
146
145
}
+1
-1
packages/openapi-ts/src/plugins/valibot/v1/toAst/array.ts
+1
-1
packages/openapi-ts/src/plugins/valibot/v1/toAst/array.ts
+2
-2
packages/openapi-ts/src/plugins/valibot/v1/toAst/boolean.ts
+2
-2
packages/openapi-ts/src/plugins/valibot/v1/toAst/boolean.ts
···
22
22
pipes.push(
23
23
$(v).attr(identifiers.schemas.literal).call($.literal(schema.const)),
24
24
);
25
-
return pipesToAst({ pipes, plugin });
25
+
return pipesToAst(pipes, plugin);
26
26
}
27
27
28
28
pipes.push($(v).attr(identifiers.schemas.boolean).call());
29
-
return pipesToAst({ pipes, plugin });
29
+
return pipesToAst(pipes, plugin);
30
30
};
+22
-25
packages/openapi-ts/src/plugins/valibot/v1/toAst/index.ts
+22
-25
packages/openapi-ts/src/plugins/valibot/v1/toAst/index.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
2
3
import type { $ } from '~/ts-dsl';
3
4
4
5
import { pipesToAst } from '../../shared/pipesToAst';
···
28
29
switch (schema.type) {
29
30
case 'array':
30
31
return {
31
-
expression: pipesToAst({
32
-
pipes: arrayToAst({
32
+
expression: pipesToAst(
33
+
arrayToAst({
33
34
...args,
34
35
schema: schema as SchemaWithType<'array'>,
35
36
}).pipes,
36
-
plugin: args.plugin,
37
-
}),
37
+
args.plugin,
38
+
),
38
39
};
39
40
case 'boolean':
40
41
return {
···
74
75
};
75
76
case 'object':
76
77
return {
77
-
expression: pipesToAst({
78
-
pipes: objectToAst({
78
+
expression: pipesToAst(
79
+
objectToAst({
79
80
...args,
80
81
schema: schema as SchemaWithType<'object'>,
81
82
}).pipes,
82
-
plugin: args.plugin,
83
-
}),
83
+
args.plugin,
84
+
),
84
85
};
85
86
case 'string':
86
-
// For string schemas with int64/uint64 formats, use number handler to generate union with transform
87
-
if (schema.format === 'int64' || schema.format === 'uint64') {
88
-
return {
89
-
expression: numberToAst({
90
-
...args,
91
-
schema: schema as SchemaWithType<'integer' | 'number'>,
92
-
}),
93
-
};
94
-
}
95
87
return {
96
-
expression: stringToAst({
97
-
...args,
98
-
schema: schema as SchemaWithType<'string'>,
99
-
}),
88
+
expression: shouldCoerceToBigInt(schema.format)
89
+
? numberToAst({
90
+
...args,
91
+
schema: { ...schema, type: 'number' },
92
+
})
93
+
: stringToAst({
94
+
...args,
95
+
schema: schema as SchemaWithType<'string'>,
96
+
}),
100
97
};
101
98
case 'tuple':
102
99
return {
103
-
expression: pipesToAst({
104
-
pipes: tupleToAst({
100
+
expression: pipesToAst(
101
+
tupleToAst({
105
102
...args,
106
103
schema: schema as SchemaWithType<'tuple'>,
107
104
}).pipes,
108
-
plugin: args.plugin,
109
-
}),
105
+
args.plugin,
106
+
),
110
107
};
111
108
case 'undefined':
112
109
return {
+64
-120
packages/openapi-ts/src/plugins/valibot/v1/toAst/number.ts
+64
-120
packages/openapi-ts/src/plugins/valibot/v1/toAst/number.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import {
3
+
maybeBigInt,
4
+
shouldCoerceToBigInt,
5
+
} from '~/plugins/shared/utils/coerce';
6
+
import { getIntegerLimit } from '~/plugins/shared/utils/formats';
2
7
import { $ } from '~/ts-dsl';
3
8
4
-
import {
5
-
INTEGER_FORMATS,
6
-
isIntegerFormat,
7
-
needsBigIntForFormat,
8
-
numberParameter,
9
-
} from '../../shared/numbers';
10
9
import { pipesToAst } from '../../shared/pipesToAst';
11
10
import type { IrSchemaToAstOptions } from '../../shared/types';
12
11
import { identifiers } from '../constants';
···
17
16
}: IrSchemaToAstOptions & {
18
17
schema: SchemaWithType<'integer' | 'number'>;
19
18
}) => {
20
-
const format = schema.format;
21
-
const isInteger = schema.type === 'integer';
22
-
const isBigInt = needsBigIntForFormat(format);
23
-
const formatInfo = isIntegerFormat(format) ? INTEGER_FORMATS[format] : null;
24
-
25
19
const v = plugin.referenceSymbol({
26
20
category: 'external',
27
21
resource: 'valibot.v',
28
22
});
29
23
30
-
// Return early if const is defined since we can create a literal type directly without additional validation
31
-
if (schema.const !== undefined && schema.const !== null) {
32
-
const constValue = schema.const;
33
-
let literalValue: ReturnType<typeof $.fromValue>;
34
-
35
-
// Case 1: Number with no format -> generate literal with the number
36
-
if (typeof constValue === 'number' && !format) {
37
-
literalValue = $.literal(constValue);
38
-
}
39
-
// Case 2: Number with format -> check if format needs BigInt, generate appropriate literal
40
-
else if (typeof constValue === 'number' && format) {
41
-
if (isBigInt) {
42
-
// Format requires BigInt, convert number to BigInt
43
-
literalValue = $('BigInt').call($.literal(constValue));
44
-
} else {
45
-
// Regular format, use number as-is
46
-
literalValue = $.literal(constValue);
47
-
}
48
-
}
49
-
// Case 3: Format that allows string -> generate BigInt literal (for int64/uint64 formats)
50
-
else if (typeof constValue === 'string' && isBigInt) {
51
-
// Remove 'n' suffix if present in string
52
-
const cleanString = constValue.endsWith('n')
53
-
? constValue.slice(0, -1)
54
-
: constValue;
55
-
literalValue = $('BigInt').call($.literal(cleanString));
56
-
}
57
-
// Case 4: Const is typeof bigint (literal) -> transform from literal to BigInt()
58
-
else if (typeof constValue === 'bigint') {
59
-
// Convert BigInt to string and remove 'n' suffix that toString() adds
60
-
const bigintString = constValue.toString();
61
-
const cleanString = bigintString.endsWith('n')
62
-
? bigintString.slice(0, -1)
63
-
: bigintString;
64
-
literalValue = $('BigInt').call($.literal(cleanString));
65
-
}
66
-
// Default case: use value as-is for other types
67
-
else {
68
-
literalValue = $.fromValue(constValue);
69
-
}
70
-
71
-
return $(v).attr(identifiers.schemas.literal).call(literalValue);
24
+
if (schema.const !== undefined) {
25
+
return $(v)
26
+
.attr(identifiers.schemas.literal)
27
+
.call(maybeBigInt(schema.const, schema.format));
72
28
}
73
29
74
30
const pipes: Array<ReturnType<typeof $.call>> = [];
75
31
76
-
// For bigint formats (int64, uint64), create union of number, string, and bigint with transform
77
-
if (isBigInt) {
78
-
const unionExpression = $(v)
79
-
.attr(identifiers.schemas.union)
80
-
.call(
81
-
$.array(
82
-
$(v).attr(identifiers.schemas.number).call(),
83
-
$(v).attr(identifiers.schemas.string).call(),
84
-
$(v).attr(identifiers.schemas.bigInt).call(),
32
+
if (shouldCoerceToBigInt(schema.format)) {
33
+
pipes.push(
34
+
$(v)
35
+
.attr(identifiers.schemas.union)
36
+
.call(
37
+
$.array(
38
+
$(v).attr(identifiers.schemas.number).call(),
39
+
$(v).attr(identifiers.schemas.string).call(),
40
+
$(v).attr(identifiers.schemas.bigInt).call(),
41
+
),
85
42
),
86
-
);
87
-
pipes.push(unionExpression);
88
-
89
-
// Add transform to convert to BigInt
90
-
const transformExpression = $(v)
91
-
.attr(identifiers.actions.transform)
92
-
.call($.func().param('x').do($('BigInt').call('x').return()));
93
-
pipes.push(transformExpression);
43
+
$(v)
44
+
.attr(identifiers.actions.transform)
45
+
.call($.func().param('x').do($('BigInt').call('x').return())),
46
+
);
94
47
} else {
95
-
// For regular number formats, use number schema
96
-
const expression = $(v).attr(identifiers.schemas.number).call();
97
-
pipes.push(expression);
48
+
pipes.push($(v).attr(identifiers.schemas.number).call());
49
+
if (schema.type === 'integer') {
50
+
pipes.push($(v).attr(identifiers.actions.integer).call());
51
+
}
98
52
}
99
53
100
-
// Add integer validation for integer types (except when using bigint union)
101
-
if (!isBigInt && isInteger) {
102
-
const expression = $(v).attr(identifiers.actions.integer).call();
103
-
pipes.push(expression);
104
-
}
105
-
106
-
// Add format-specific range validations
107
-
if (formatInfo) {
108
-
const minValue = formatInfo.min;
109
-
const maxValue = formatInfo.max;
110
-
const minErrorMessage = formatInfo.minError;
111
-
const maxErrorMessage = formatInfo.maxError;
112
-
113
-
// Add minimum value validation
114
-
const minExpression = $(v)
115
-
.attr(identifiers.actions.minValue)
116
-
.call(
117
-
isBigInt ? $('BigInt').call($.literal(minValue)) : $.literal(minValue),
118
-
$.literal(minErrorMessage),
119
-
);
120
-
pipes.push(minExpression);
121
-
122
-
// Add maximum value validation
123
-
const maxExpression = $(v)
124
-
.attr(identifiers.actions.maxValue)
125
-
.call(
126
-
isBigInt ? $('BigInt').call($.literal(maxValue)) : $.literal(maxValue),
127
-
$.literal(maxErrorMessage),
128
-
);
129
-
pipes.push(maxExpression);
54
+
const integerLimit = getIntegerLimit(schema.format);
55
+
if (integerLimit) {
56
+
pipes.push(
57
+
$(v)
58
+
.attr(identifiers.actions.minValue)
59
+
.call(
60
+
maybeBigInt(integerLimit.minValue, schema.format),
61
+
$.literal(integerLimit.minError),
62
+
),
63
+
$(v)
64
+
.attr(identifiers.actions.maxValue)
65
+
.call(
66
+
maybeBigInt(integerLimit.maxValue, schema.format),
67
+
$.literal(integerLimit.maxError),
68
+
),
69
+
);
130
70
}
131
71
132
72
if (schema.exclusiveMinimum !== undefined) {
133
-
const expression = $(v)
134
-
.attr(identifiers.actions.gtValue)
135
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMinimum }));
136
-
pipes.push(expression);
73
+
pipes.push(
74
+
$(v)
75
+
.attr(identifiers.actions.gtValue)
76
+
.call(maybeBigInt(schema.exclusiveMinimum, schema.format)),
77
+
);
137
78
} else if (schema.minimum !== undefined) {
138
-
const expression = $(v)
139
-
.attr(identifiers.actions.minValue)
140
-
.call(numberParameter({ isBigInt, value: schema.minimum }));
141
-
pipes.push(expression);
79
+
pipes.push(
80
+
$(v)
81
+
.attr(identifiers.actions.minValue)
82
+
.call(maybeBigInt(schema.minimum, schema.format)),
83
+
);
142
84
}
143
85
144
86
if (schema.exclusiveMaximum !== undefined) {
145
-
const expression = $(v)
146
-
.attr(identifiers.actions.ltValue)
147
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMaximum }));
148
-
pipes.push(expression);
87
+
pipes.push(
88
+
$(v)
89
+
.attr(identifiers.actions.ltValue)
90
+
.call(maybeBigInt(schema.exclusiveMaximum, schema.format)),
91
+
);
149
92
} else if (schema.maximum !== undefined) {
150
-
const expression = $(v)
151
-
.attr(identifiers.actions.maxValue)
152
-
.call(numberParameter({ isBigInt, value: schema.maximum }));
153
-
pipes.push(expression);
93
+
pipes.push(
94
+
$(v)
95
+
.attr(identifiers.actions.maxValue)
96
+
.call(maybeBigInt(schema.maximum, schema.format)),
97
+
);
154
98
}
155
99
156
-
return pipesToAst({ pipes, plugin });
100
+
return pipesToAst(pipes, plugin);
157
101
};
+3
-3
packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts
+3
-3
packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts
···
75
75
});
76
76
if (propertyAst.hasLazyExpression) result.hasLazyExpression = true;
77
77
78
-
shape.prop(name, pipesToAst({ pipes: propertyAst.pipes, plugin }));
78
+
shape.prop(name, pipesToAst(propertyAst.pipes, plugin));
79
79
}
80
80
81
81
let additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined;
···
92
92
},
93
93
});
94
94
if (additionalAst.hasLazyExpression) result.hasLazyExpression = true;
95
-
additional = pipesToAst({ pipes: additionalAst.pipes, plugin });
95
+
additional = pipesToAst(additionalAst.pipes, plugin);
96
96
}
97
97
}
98
98
···
107
107
const resolver = plugin.config['~resolvers']?.object?.base;
108
108
if (!resolver?.(args)) defaultObjectBaseResolver(args);
109
109
110
-
result.pipes = [pipesToAst({ pipes, plugin })];
110
+
result.pipes = [pipesToAst(pipes, plugin)];
111
111
return result as Omit<Ast, 'typeName'>;
112
112
};
+3
-7
packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts
+3
-7
packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts
···
43
43
}: IrSchemaToAstOptions & {
44
44
schema: SchemaWithType<'string'>;
45
45
}): ReturnType<typeof $.call | typeof $.expr> => {
46
-
const pipes: Array<ReturnType<typeof $.call>> = [];
47
-
48
46
const v = plugin.referenceSymbol({
49
47
category: 'external',
50
48
resource: 'valibot.v',
51
49
});
52
50
53
51
if (typeof schema.const === 'string') {
54
-
pipes.push(
55
-
$(v).attr(identifiers.schemas.literal).call($.literal(schema.const)),
56
-
);
57
-
return pipesToAst({ pipes, plugin });
52
+
return $(v).attr(identifiers.schemas.literal).call($.literal(schema.const));
58
53
}
59
54
55
+
const pipes: Array<ReturnType<typeof $.call>> = [];
60
56
pipes.push($(v).attr(identifiers.schemas.string).call());
61
57
62
58
if (schema.format) {
···
94
90
);
95
91
}
96
92
97
-
return pipesToAst({ pipes, plugin });
93
+
return pipesToAst(pipes, plugin);
98
94
};
+1
-1
packages/openapi-ts/src/plugins/valibot/v1/toAst/tuple.ts
+1
-1
packages/openapi-ts/src/plugins/valibot/v1/toAst/tuple.ts
+2
packages/openapi-ts/src/plugins/zod/constants.ts
+2
packages/openapi-ts/src/plugins/zod/constants.ts
+4
-6
packages/openapi-ts/src/plugins/zod/mini/plugin.ts
+4
-6
packages/openapi-ts/src/plugins/zod/mini/plugin.ts
···
5
5
import type { IR } from '~/ir/types';
6
6
import { buildName } from '~/openApi/shared/utils/name';
7
7
import type { SchemaWithType } from '~/plugins';
8
+
import { maybeBigInt } from '~/plugins/shared/utils/coerce';
8
9
import { $ } from '~/ts-dsl';
9
10
import { pathToJsonPointer, refToName } from '~/utils/ref';
10
11
11
12
import { identifiers } from '../constants';
12
13
import { exportAst } from '../shared/export';
13
14
import { getZodModule } from '../shared/module';
14
-
import { numberParameter } from '../shared/numbers';
15
15
import { irOperationToAst } from '../shared/operation';
16
16
import type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';
17
17
import { irWebhookToAst } from '../shared/webhook';
···
152
152
}
153
153
154
154
if (schema.default !== undefined) {
155
-
const isBigInt = schema.type === 'integer' && schema.format === 'int64';
156
155
ast.expression = $(z)
157
156
.attr(identifiers._default)
158
157
.call(
159
158
ast.expression,
160
-
numberParameter({
161
-
isBigInt,
162
-
value: schema.default,
163
-
}),
159
+
schema.type === 'integer' || schema.type === 'number'
160
+
? maybeBigInt(schema.default, schema.format)
161
+
: $.fromValue(schema.default),
164
162
);
165
163
}
166
164
}
+10
-4
packages/openapi-ts/src/plugins/zod/mini/toAst/index.ts
+10
-4
packages/openapi-ts/src/plugins/zod/mini/toAst/index.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
2
3
3
4
import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
4
5
import { arrayToAst } from './array';
···
58
59
schema: schema as SchemaWithType<'object'>,
59
60
});
60
61
case 'string':
61
-
return stringToAst({
62
-
...args,
63
-
schema: schema as SchemaWithType<'string'>,
64
-
});
62
+
return shouldCoerceToBigInt(schema.format)
63
+
? numberToAst({
64
+
...args,
65
+
schema: { ...schema, type: 'number' },
66
+
})
67
+
: stringToAst({
68
+
...args,
69
+
schema: schema as SchemaWithType<'string'>,
70
+
});
65
71
case 'tuple':
66
72
return tupleToAst({
67
73
...args,
+41
-18
packages/openapi-ts/src/plugins/zod/mini/toAst/number.ts
+41
-18
packages/openapi-ts/src/plugins/zod/mini/toAst/number.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import {
3
+
maybeBigInt,
4
+
shouldCoerceToBigInt,
5
+
} from '~/plugins/shared/utils/coerce';
6
+
import { getIntegerLimit } from '~/plugins/shared/utils/formats';
2
7
import { $ } from '~/ts-dsl';
3
8
4
9
import { identifiers } from '../../constants';
5
-
import { numberParameter } from '../../shared/numbers';
6
10
import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
7
11
8
12
export const numberToAst = ({
···
11
15
}: IrSchemaToAstOptions & {
12
16
schema: SchemaWithType<'integer' | 'number'>;
13
17
}): Omit<Ast, 'typeName'> => {
18
+
const result: Partial<Omit<Ast, 'typeName'>> = {};
19
+
14
20
const z = plugin.referenceSymbol({
15
21
category: 'external',
16
22
resource: 'zod.z',
17
23
});
18
24
19
-
const result: Partial<Omit<Ast, 'typeName'>> = {};
20
-
21
-
const isBigInt = schema.type === 'integer' && schema.format === 'int64';
22
-
23
-
if (typeof schema.const === 'number') {
24
-
// TODO: parser - handle bigint constants
25
+
if (schema.const !== undefined) {
25
26
result.expression = $(z)
26
27
.attr(identifiers.literal)
27
-
.call($.literal(schema.const));
28
+
.call(maybeBigInt(schema.const, schema.format));
28
29
return result as Omit<Ast, 'typeName'>;
29
30
}
30
31
31
-
result.expression = isBigInt
32
-
? $(z).attr(identifiers.coerce).attr(identifiers.bigint).call()
33
-
: $(z).attr(identifiers.number).call();
34
-
35
-
if (!isBigInt && schema.type === 'integer') {
36
-
result.expression = $(z).attr(identifiers.int).call();
32
+
if (shouldCoerceToBigInt(schema.format)) {
33
+
result.expression = $(z)
34
+
.attr(identifiers.coerce)
35
+
.attr(identifiers.bigint)
36
+
.call();
37
+
} else {
38
+
result.expression = $(z).attr(identifiers.number).call();
39
+
if (schema.type === 'integer') {
40
+
result.expression = $(z).attr(identifiers.int).call();
41
+
}
37
42
}
38
43
39
44
const checks: Array<ReturnType<typeof $.call>> = [];
40
45
46
+
const integerLimit = getIntegerLimit(schema.format);
47
+
if (integerLimit) {
48
+
checks.push(
49
+
$(z)
50
+
.attr(identifiers.minimum)
51
+
.call(
52
+
maybeBigInt(integerLimit.minValue, schema.format),
53
+
$.object().prop('error', $.literal(integerLimit.minError)),
54
+
),
55
+
$(z)
56
+
.attr(identifiers.maximum)
57
+
.call(
58
+
maybeBigInt(integerLimit.maxValue, schema.format),
59
+
$.object().prop('error', $.literal(integerLimit.maxError)),
60
+
),
61
+
);
62
+
}
63
+
41
64
if (schema.exclusiveMinimum !== undefined) {
42
65
checks.push(
43
66
$(z)
44
67
.attr(identifiers.gt)
45
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMinimum })),
68
+
.call(maybeBigInt(schema.exclusiveMinimum, schema.format)),
46
69
);
47
70
} else if (schema.minimum !== undefined) {
48
71
checks.push(
49
72
$(z)
50
73
.attr(identifiers.gte)
51
-
.call(numberParameter({ isBigInt, value: schema.minimum })),
74
+
.call(maybeBigInt(schema.minimum, schema.format)),
52
75
);
53
76
}
54
77
···
56
79
checks.push(
57
80
$(z)
58
81
.attr(identifiers.lt)
59
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMaximum })),
82
+
.call(maybeBigInt(schema.exclusiveMaximum, schema.format)),
60
83
);
61
84
} else if (schema.maximum !== undefined) {
62
85
checks.push(
63
86
$(z)
64
87
.attr(identifiers.lte)
65
-
.call(numberParameter({ isBigInt, value: schema.maximum })),
88
+
.call(maybeBigInt(schema.maximum, schema.format)),
66
89
);
67
90
}
68
91
+23
packages/openapi-ts/src/plugins/zod/types.d.ts
+23
packages/openapi-ts/src/plugins/zod/types.d.ts
···
783
783
784
784
type Resolvers = Plugin.Resolvers<{
785
785
/**
786
+
* Resolvers for number schemas.
787
+
*
788
+
* Allows customization of how number types are rendered, including
789
+
* per-format handling.
790
+
*/
791
+
number?: {
792
+
/**
793
+
* Resolvers for number formats (e.g., `float`, `double`, `int32`).
794
+
*
795
+
* Each key represents a specific format name with a custom
796
+
* resolver function that controls how that format is rendered.
797
+
*
798
+
* Example path: `~resolvers.number.formats.float`
799
+
*
800
+
* Returning `undefined` from a resolver will apply the default
801
+
* generation behavior for that format.
802
+
*/
803
+
formats?: Record<
804
+
string,
805
+
(args: FormatResolverArgs) => boolean | number | undefined
806
+
>;
807
+
};
808
+
/**
786
809
* Resolvers for object schemas.
787
810
*
788
811
* Allows customization of how object types are rendered.
+8
-8
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
+8
-8
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
···
5
5
import type { IR } from '~/ir/types';
6
6
import { buildName } from '~/openApi/shared/utils/name';
7
7
import type { SchemaWithType } from '~/plugins';
8
+
import { maybeBigInt } from '~/plugins/shared/utils/coerce';
8
9
import { $ } from '~/ts-dsl';
9
10
import { pathToJsonPointer, refToName } from '~/utils/ref';
10
11
11
12
import { identifiers } from '../constants';
12
13
import { exportAst } from '../shared/export';
13
14
import { getZodModule } from '../shared/module';
14
-
import { numberParameter } from '../shared/numbers';
15
15
import { irOperationToAst } from '../shared/operation';
16
16
import type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';
17
17
import { irWebhookToAst } from '../shared/webhook';
···
139
139
}
140
140
141
141
if (schema.default !== undefined) {
142
-
const isBigInt = schema.type === 'integer' && schema.format === 'int64';
143
-
ast.expression = ast.expression.attr(identifiers.default).call(
144
-
numberParameter({
145
-
isBigInt,
146
-
value: schema.default,
147
-
}),
148
-
);
142
+
ast.expression = ast.expression
143
+
.attr(identifiers.default)
144
+
.call(
145
+
schema.type === 'integer' || schema.type === 'number'
146
+
? maybeBigInt(schema.default, schema.format)
147
+
: $.fromValue(schema.default),
148
+
);
149
149
}
150
150
}
151
151
+10
-4
packages/openapi-ts/src/plugins/zod/v3/toAst/index.ts
+10
-4
packages/openapi-ts/src/plugins/zod/v3/toAst/index.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
2
3
3
4
import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
4
5
import { arrayToAst } from './array';
···
71
72
});
72
73
case 'string':
73
74
return {
74
-
expression: stringToAst({
75
-
...args,
76
-
schema: schema as SchemaWithType<'string'>,
77
-
}),
75
+
expression: shouldCoerceToBigInt(schema.format)
76
+
? numberToAst({
77
+
...args,
78
+
schema: { ...schema, type: 'number' },
79
+
})
80
+
: stringToAst({
81
+
...args,
82
+
schema: schema as SchemaWithType<'string'>,
83
+
}),
78
84
};
79
85
case 'tuple':
80
86
return tupleToAst({
+37
-15
packages/openapi-ts/src/plugins/zod/v3/toAst/number.ts
+37
-15
packages/openapi-ts/src/plugins/zod/v3/toAst/number.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import {
3
+
maybeBigInt,
4
+
shouldCoerceToBigInt,
5
+
} from '~/plugins/shared/utils/coerce';
6
+
import { getIntegerLimit } from '~/plugins/shared/utils/formats';
2
7
import { $ } from '~/ts-dsl';
3
8
4
9
import { identifiers } from '../../constants';
5
-
import { numberParameter } from '../../shared/numbers';
6
10
import type { IrSchemaToAstOptions } from '../../shared/types';
7
11
8
12
export const numberToAst = ({
···
16
20
resource: 'zod.z',
17
21
});
18
22
19
-
const isBigInt = schema.type === 'integer' && schema.format === 'int64';
20
-
21
-
if (typeof schema.const === 'number') {
22
-
// TODO: parser - handle bigint constants
23
+
if (schema.const !== undefined) {
23
24
const expression = $(z)
24
25
.attr(identifiers.literal)
25
-
.call($.literal(schema.const));
26
+
.call(maybeBigInt(schema.const, schema.format));
26
27
return expression;
27
28
}
28
29
29
-
let numberExpression = isBigInt
30
-
? $(z).attr(identifiers.coerce).attr(identifiers.bigint).call()
31
-
: $(z).attr(identifiers.number).call();
30
+
let numberExpression: ReturnType<typeof $.call>;
32
31
33
-
if (!isBigInt && schema.type === 'integer') {
34
-
numberExpression = numberExpression.attr(identifiers.int).call();
32
+
if (shouldCoerceToBigInt(schema.format)) {
33
+
numberExpression = $(z)
34
+
.attr(identifiers.coerce)
35
+
.attr(identifiers.bigint)
36
+
.call();
37
+
} else {
38
+
numberExpression = $(z).attr(identifiers.number).call();
39
+
if (schema.type === 'integer') {
40
+
numberExpression = numberExpression.attr(identifiers.int).call();
41
+
}
42
+
}
43
+
44
+
const integerLimit = getIntegerLimit(schema.format);
45
+
if (integerLimit) {
46
+
numberExpression = numberExpression
47
+
.attr(identifiers.min)
48
+
.call(
49
+
maybeBigInt(integerLimit.minValue, schema.format),
50
+
$.object().prop('message', $.literal(integerLimit.minError)),
51
+
)
52
+
.attr(identifiers.max)
53
+
.call(
54
+
maybeBigInt(integerLimit.maxValue, schema.format),
55
+
$.object().prop('message', $.literal(integerLimit.maxError)),
56
+
);
35
57
}
36
58
37
59
if (schema.exclusiveMinimum !== undefined) {
38
60
numberExpression = numberExpression
39
61
.attr(identifiers.gt)
40
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMinimum }));
62
+
.call(maybeBigInt(schema.exclusiveMinimum, schema.format));
41
63
} else if (schema.minimum !== undefined) {
42
64
numberExpression = numberExpression
43
65
.attr(identifiers.gte)
44
-
.call(numberParameter({ isBigInt, value: schema.minimum }));
66
+
.call(maybeBigInt(schema.minimum, schema.format));
45
67
}
46
68
47
69
if (schema.exclusiveMaximum !== undefined) {
48
70
numberExpression = numberExpression
49
71
.attr(identifiers.lt)
50
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMaximum }));
72
+
.call(maybeBigInt(schema.exclusiveMaximum, schema.format));
51
73
} else if (schema.maximum !== undefined) {
52
74
numberExpression = numberExpression
53
75
.attr(identifiers.lte)
54
-
.call(numberParameter({ isBigInt, value: schema.maximum }));
76
+
.call(maybeBigInt(schema.maximum, schema.format));
55
77
}
56
78
57
79
return numberExpression;
+8
-8
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
+8
-8
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
···
5
5
import type { IR } from '~/ir/types';
6
6
import { buildName } from '~/openApi/shared/utils/name';
7
7
import type { SchemaWithType } from '~/plugins';
8
+
import { maybeBigInt } from '~/plugins/shared/utils/coerce';
8
9
import { $ } from '~/ts-dsl';
9
10
import { pathToJsonPointer, refToName } from '~/utils/ref';
10
11
11
12
import { identifiers } from '../constants';
12
13
import { exportAst } from '../shared/export';
13
14
import { getZodModule } from '../shared/module';
14
-
import { numberParameter } from '../shared/numbers';
15
15
import { irOperationToAst } from '../shared/operation';
16
16
import type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';
17
17
import { irWebhookToAst } from '../shared/webhook';
···
155
155
}
156
156
157
157
if (schema.default !== undefined) {
158
-
const isBigInt = schema.type === 'integer' && schema.format === 'int64';
159
-
ast.expression = ast.expression.attr(identifiers.default).call(
160
-
numberParameter({
161
-
isBigInt,
162
-
value: schema.default,
163
-
}),
164
-
);
158
+
ast.expression = ast.expression
159
+
.attr(identifiers.default)
160
+
.call(
161
+
schema.type === 'integer' || schema.type === 'number'
162
+
? maybeBigInt(schema.default, schema.format)
163
+
: $.fromValue(schema.default),
164
+
);
165
165
}
166
166
}
167
167
+10
-4
packages/openapi-ts/src/plugins/zod/v4/toAst/index.ts
+10
-4
packages/openapi-ts/src/plugins/zod/v4/toAst/index.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
2
3
3
4
import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
4
5
import { arrayToAst } from './array';
···
58
59
schema: schema as SchemaWithType<'object'>,
59
60
});
60
61
case 'string':
61
-
return stringToAst({
62
-
...args,
63
-
schema: schema as SchemaWithType<'string'>,
64
-
});
62
+
return shouldCoerceToBigInt(schema.format)
63
+
? numberToAst({
64
+
...args,
65
+
schema: { ...schema, type: 'number' },
66
+
})
67
+
: stringToAst({
68
+
...args,
69
+
schema: schema as SchemaWithType<'string'>,
70
+
});
65
71
case 'tuple':
66
72
return tupleToAst({
67
73
...args,
+35
-15
packages/openapi-ts/src/plugins/zod/v4/toAst/number.ts
+35
-15
packages/openapi-ts/src/plugins/zod/v4/toAst/number.ts
···
1
1
import type { SchemaWithType } from '~/plugins';
2
+
import {
3
+
maybeBigInt,
4
+
shouldCoerceToBigInt,
5
+
} from '~/plugins/shared/utils/coerce';
6
+
import { getIntegerLimit } from '~/plugins/shared/utils/formats';
2
7
import { $ } from '~/ts-dsl';
3
8
4
9
import { identifiers } from '../../constants';
5
-
import { numberParameter } from '../../shared/numbers';
6
10
import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
7
11
8
12
export const numberToAst = ({
···
13
17
}): Omit<Ast, 'typeName'> => {
14
18
const result: Partial<Omit<Ast, 'typeName'>> = {};
15
19
16
-
const isBigInt = schema.type === 'integer' && schema.format === 'int64';
17
-
18
20
const z = plugin.referenceSymbol({
19
21
category: 'external',
20
22
resource: 'zod.z',
21
23
});
22
24
23
-
if (typeof schema.const === 'number') {
24
-
// TODO: parser - handle bigint constants
25
+
if (schema.const !== undefined) {
25
26
result.expression = $(z)
26
27
.attr(identifiers.literal)
27
-
.call($.literal(schema.const));
28
+
.call(maybeBigInt(schema.const, schema.format));
28
29
return result as Omit<Ast, 'typeName'>;
29
30
}
30
31
31
-
result.expression = isBigInt
32
-
? $(z).attr(identifiers.coerce).attr(identifiers.bigint).call()
33
-
: $(z).attr(identifiers.number).call();
32
+
if (shouldCoerceToBigInt(schema.format)) {
33
+
result.expression = $(z)
34
+
.attr(identifiers.coerce)
35
+
.attr(identifiers.bigint)
36
+
.call();
37
+
} else {
38
+
result.expression = $(z).attr(identifiers.number).call();
39
+
if (schema.type === 'integer') {
40
+
result.expression = $(z).attr(identifiers.int).call();
41
+
}
42
+
}
34
43
35
-
if (!isBigInt && schema.type === 'integer') {
36
-
result.expression = $(z).attr(identifiers.int).call();
44
+
const integerLimit = getIntegerLimit(schema.format);
45
+
if (integerLimit) {
46
+
result.expression = result.expression
47
+
.attr(identifiers.min)
48
+
.call(
49
+
maybeBigInt(integerLimit.minValue, schema.format),
50
+
$.object().prop('error', $.literal(integerLimit.minError)),
51
+
)
52
+
.attr(identifiers.max)
53
+
.call(
54
+
maybeBigInt(integerLimit.maxValue, schema.format),
55
+
$.object().prop('error', $.literal(integerLimit.maxError)),
56
+
);
37
57
}
38
58
39
59
if (schema.exclusiveMinimum !== undefined) {
40
60
result.expression = result.expression
41
61
.attr(identifiers.gt)
42
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMinimum }));
62
+
.call(maybeBigInt(schema.exclusiveMinimum, schema.format));
43
63
} else if (schema.minimum !== undefined) {
44
64
result.expression = result.expression
45
65
.attr(identifiers.gte)
46
-
.call(numberParameter({ isBigInt, value: schema.minimum }));
66
+
.call(maybeBigInt(schema.minimum, schema.format));
47
67
}
48
68
49
69
if (schema.exclusiveMaximum !== undefined) {
50
70
result.expression = result.expression
51
71
.attr(identifiers.lt)
52
-
.call(numberParameter({ isBigInt, value: schema.exclusiveMaximum }));
72
+
.call(maybeBigInt(schema.exclusiveMaximum, schema.format));
53
73
} else if (schema.maximum !== undefined) {
54
74
result.expression = result.expression
55
75
.attr(identifiers.lte)
56
-
.call(numberParameter({ isBigInt, value: schema.maximum }));
76
+
.call(maybeBigInt(schema.maximum, schema.format));
57
77
}
58
78
59
79
return result as Omit<Ast, 'typeName'>;
+3
-5
packages/openapi-ts/src/ts-dsl/expr/fromValue.ts
+3
-5
packages/openapi-ts/src/ts-dsl/expr/fromValue.ts
···
16
16
return input as TsDsl<ts.Expression>;
17
17
}
18
18
19
-
if (input === null) {
20
-
return new LiteralTsDsl(input);
21
-
}
22
-
23
19
if (
20
+
input === null ||
24
21
typeof input === 'number' ||
25
22
typeof input === 'boolean' ||
26
-
typeof input === 'string'
23
+
typeof input === 'string' ||
24
+
typeof input === 'bigint'
27
25
) {
28
26
return new LiteralTsDsl(input);
29
27
}
+7
-2
packages/openapi-ts/src/ts-dsl/expr/literal.ts
+7
-2
packages/openapi-ts/src/ts-dsl/expr/literal.ts
···
5
5
import { PrefixTsDsl } from '../expr/prefix';
6
6
import { AsMixin } from '../mixins/as';
7
7
8
+
export type LiteralValue = string | number | boolean | bigint | null;
9
+
8
10
const Mixed = AsMixin(TsDsl<ts.LiteralTypeNode['literal']>);
9
11
10
12
export class LiteralTsDsl extends Mixed {
11
13
readonly '~dsl' = 'LiteralTsDsl';
12
14
13
-
protected value: string | number | boolean | null;
15
+
protected value: LiteralValue;
14
16
15
-
constructor(value: string | number | boolean | null) {
17
+
constructor(value: LiteralValue) {
16
18
super();
17
19
this.value = value;
18
20
}
···
33
35
}
34
36
if (typeof this.value === 'string') {
35
37
return ts.factory.createStringLiteral(this.value, true);
38
+
}
39
+
if (typeof this.value === 'bigint') {
40
+
return ts.factory.createBigIntLiteral(this.value.toString());
36
41
}
37
42
if (this.value === null) {
38
43
return ts.factory.createNull();
-3
specs/3.1.x/array-items-all-of.yaml
-3
specs/3.1.x/array-items-all-of.yaml
···
4
4
version: '1'
5
5
components:
6
6
schemas:
7
-
# Test case 1: Array with allOf of object schemas
8
7
ArrayWithAllOfObjects:
9
8
type: array
10
9
items:
···
17
16
properties:
18
17
name:
19
18
type: string
20
-
# Test case 2: Array with allOf of primitives
21
19
ArrayWithAllOfPrimitives:
22
20
type: array
23
21
items:
24
22
allOf:
25
23
- type: number
26
24
- type: string
27
-
# Test case 3: Array with allOf including refs
28
25
ArrayWithAllOfRefs:
29
26
type: array
30
27
items: