Skip to content

Commit 43e59ff

Browse files
brolnickijmrlubos
authored andcommitted
chore: bump snapshots
1 parent e1d6b27 commit 43e59ff

File tree

20 files changed

+520
-240
lines changed

20 files changed

+520
-240
lines changed

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/client/client.gen.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const createClient = (config: Config = {}): Client => {
4949
ResolvedRequestOptions
5050
>();
5151

52-
// Resolve final options, serialized body, network body and URL
52+
// precompute serialized / network body
5353
const resolveOptions = async (options: RequestOptions) => {
5454
const opts = {
5555
..._config,
@@ -73,28 +73,28 @@ export const createClient = (config: Config = {}): Client => {
7373
opts.serializedBody = opts.bodySerializer(opts.body);
7474
}
7575

76-
// remove Content-Type header if body is empty to avoid sending invalid requests
76+
// remove Content-Type if body is empty to avoid invalid requests
7777
if (opts.body === undefined || opts.serializedBody === '') {
7878
opts.headers.delete('Content-Type');
7979
}
8080

81-
// If user provides a raw body (no serializer), adjust Content-Type sensibly.
82-
// Avoid overriding explicit user-defined headers; only correct the default JSON header.
81+
// if a raw body is provided (no serializer), adjust Content-Type only when it
82+
// equals the default JSON value to better match the concrete body type
8383
if (
8484
opts.body !== undefined &&
8585
opts.bodySerializer === null &&
8686
(opts.headers.get('Content-Type') || '').toLowerCase() ===
87-
'application/json'
87+
'application/json'
8888
) {
8989
const b: unknown = opts.body;
9090
if (typeof FormData !== 'undefined' && b instanceof FormData) {
91-
// Let the runtime set proper boundary
91+
// let the runtime set the multipart boundary
9292
opts.headers.delete('Content-Type');
9393
} else if (
9494
typeof URLSearchParams !== 'undefined' &&
9595
b instanceof URLSearchParams
9696
) {
97-
// Set standard urlencoded content type with charset
97+
// standard urlencoded content type (+ charset)
9898
opts.headers.set(
9999
'Content-Type',
100100
'application/x-www-form-urlencoded;charset=UTF-8',
@@ -104,13 +104,13 @@ export const createClient = (config: Config = {}): Client => {
104104
if (t) {
105105
opts.headers.set('Content-Type', t);
106106
} else {
107-
// No known type for the blob: avoid sending misleading JSON header
107+
// unknown blob type: avoid sending a misleading JSON header
108108
opts.headers.delete('Content-Type');
109109
}
110110
}
111111
}
112112

113-
// Precompute network body for retries and consistent handling
113+
// precompute network body (stability for retries and interceptors)
114114
const networkBody = getValidRequestBody(opts) as
115115
| RequestInit['body']
116116
| null
@@ -121,7 +121,7 @@ export const createClient = (config: Config = {}): Client => {
121121
return { networkBody, opts, url };
122122
};
123123

124-
// Apply request interceptors to a Request and reflect header/method/signal
124+
// apply request interceptors and mirror header/method/signal back to opts
125125
const applyRequestInterceptors = async (
126126
request: Request,
127127
opts: ResolvedRequestOptions,
@@ -131,18 +131,17 @@ export const createClient = (config: Config = {}): Client => {
131131
request = await fn(request, opts);
132132
}
133133
}
134-
// Reflect any interceptor changes into opts used for network and downstream
134+
// reflect interceptor changes into opts used by the network layer
135135
opts.headers = request.headers;
136136
opts.method = request.method as Uppercase<HttpMethod>;
137-
// Note: we intentionally ignore request.body changes from interceptors to
138-
// avoid turning serialized bodies into streams. Body is sourced solely
139-
// from getValidRequestBody(options) for consistency.
140-
// Attempt to reflect possible signal changes
137+
// ignore request.body changes to avoid turning serialized bodies into streams
138+
// body comes only from getValidRequestBody(options)
139+
// reflect signal if present
141140
opts.signal = (request as any).signal as AbortSignal | undefined;
142141
return request;
143142
};
144143

145-
// Build ofetch options with stable retry logic based on body repeatability
144+
// build ofetch options with stable retry logic based on body repeatability
146145
const buildNetworkOptions = (
147146
opts: ResolvedRequestOptions,
148147
body: BodyInit | null | undefined,
@@ -160,13 +159,13 @@ export const createClient = (config: Config = {}): Client => {
160159
opts,
161160
url,
162161
} = await resolveOptions(options as any);
163-
// Compute response type mapping once
162+
// map parseAs -> ofetch responseType once per request
164163
const ofetchResponseType: OfetchResponseType | undefined =
165164
mapParseAsToResponseType(opts.parseAs, opts.responseType);
166165

167166
const $ofetch = opts.ofetch ?? ofetch;
168167

169-
// Always create Request pre-network (align with client-fetch)
168+
// create Request before network to run middleware consistently
170169
const networkBody = initialNetworkBody;
171170
const requestInit: ReqInit = {
172171
body: networkBody,
@@ -180,7 +179,7 @@ export const createClient = (config: Config = {}): Client => {
180179
request = await applyRequestInterceptors(request, opts);
181180
const finalUrl = request.url;
182181

183-
// Build ofetch options and perform the request
182+
// build ofetch options and perform the request (.raw keeps the Response)
184183
const responseOptions = buildNetworkOptions(
185184
opts as ResolvedRequestOptions,
186185
networkBody,
@@ -210,7 +209,7 @@ export const createClient = (config: Config = {}): Client => {
210209
}
211210
}
212211

213-
// Ensure error is never undefined after interceptors
212+
// ensure error is never undefined after interceptors
214213
finalError = (finalError as any) || ({} as string);
215214

216215
if (opts.throwOnError) {
@@ -228,7 +227,7 @@ export const createClient = (config: Config = {}): Client => {
228227
(method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
229228
const { networkBody, opts, url } = await resolveOptions(options);
230229
const optsForSse: any = { ...opts };
231-
delete optsForSse.body;
230+
delete optsForSse.body; // body is provided via serializedBody below
232231
return createSseClient({
233232
...optsForSse,
234233
fetch: opts.fetch,

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/client/types.gen.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,24 @@ export type ResponseStyle = 'data' | 'fields';
2222
export interface Config<T extends ClientOptions = ClientOptions>
2323
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
2424
CoreConfig {
25+
/**
26+
* HTTP(S) agent configuration (Node.js only). Passed through to ofetch.
27+
*/
2528
agent?: OfetchOptions['agent'];
2629
/**
2730
* Base URL for all requests made by this client.
2831
*/
2932
baseUrl?: T['baseUrl'];
30-
/** Node-only proxy/agent options */
33+
/**
34+
* Node-only proxy/agent options.
35+
*/
3136
dispatcher?: OfetchOptions['dispatcher'];
32-
/** Optional fetch instance used for SSE streaming */
37+
/**
38+
* Fetch API implementation. Used for SSE streaming. You can use this option
39+
* to provide a custom fetch instance.
40+
*
41+
* @default globalThis.fetch
42+
*/
3343
fetch?: typeof fetch;
3444
// No custom fetch option: provide custom instance via `ofetch` instead
3545
/**
@@ -44,10 +54,23 @@ export interface Config<T extends ClientOptions = ClientOptions>
4454
* be used for requests instead of the default `ofetch` export.
4555
*/
4656
ofetch?: typeof ofetch;
47-
/** ofetch interceptors and runtime options */
57+
/**
58+
* ofetch hook called before a request is sent.
59+
*/
4860
onRequest?: OfetchOptions['onRequest'];
61+
/**
62+
* ofetch hook called when a request fails before receiving a response
63+
* (e.g., network errors or aborted requests).
64+
*/
4965
onRequestError?: OfetchOptions['onRequestError'];
66+
/**
67+
* ofetch hook called after a successful response is received and parsed.
68+
*/
5069
onResponse?: OfetchOptions['onResponse'];
70+
/**
71+
* ofetch hook called when the response indicates an error (non-ok status)
72+
* or when response parsing fails.
73+
*/
5174
onResponseError?: OfetchOptions['onResponseError'];
5275
/**
5376
* Return the response data parsed in a specified format. By default, `auto`
@@ -82,7 +105,13 @@ export interface Config<T extends ClientOptions = ClientOptions>
82105
* Automatically retry failed requests.
83106
*/
84107
retry?: OfetchOptions['retry'];
108+
/**
109+
* Delay (in ms) between retry attempts.
110+
*/
85111
retryDelay?: OfetchOptions['retryDelay'];
112+
/**
113+
* HTTP status codes that should trigger a retry.
114+
*/
86115
retryStatusCodes?: OfetchOptions['retryStatusCodes'];
87116
/**
88117
* Throw an error instead of returning it in the response?

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/client/client.gen.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const createClient = (config: Config = {}): Client => {
4949
ResolvedRequestOptions
5050
>();
5151

52-
// Resolve final options, serialized body, network body and URL
52+
// precompute serialized / network body
5353
const resolveOptions = async (options: RequestOptions) => {
5454
const opts = {
5555
..._config,
@@ -73,28 +73,28 @@ export const createClient = (config: Config = {}): Client => {
7373
opts.serializedBody = opts.bodySerializer(opts.body);
7474
}
7575

76-
// remove Content-Type header if body is empty to avoid sending invalid requests
76+
// remove Content-Type if body is empty to avoid invalid requests
7777
if (opts.body === undefined || opts.serializedBody === '') {
7878
opts.headers.delete('Content-Type');
7979
}
8080

81-
// If user provides a raw body (no serializer), adjust Content-Type sensibly.
82-
// Avoid overriding explicit user-defined headers; only correct the default JSON header.
81+
// if a raw body is provided (no serializer), adjust Content-Type only when it
82+
// equals the default JSON value to better match the concrete body type
8383
if (
8484
opts.body !== undefined &&
8585
opts.bodySerializer === null &&
8686
(opts.headers.get('Content-Type') || '').toLowerCase() ===
87-
'application/json'
87+
'application/json'
8888
) {
8989
const b: unknown = opts.body;
9090
if (typeof FormData !== 'undefined' && b instanceof FormData) {
91-
// Let the runtime set proper boundary
91+
// let the runtime set the multipart boundary
9292
opts.headers.delete('Content-Type');
9393
} else if (
9494
typeof URLSearchParams !== 'undefined' &&
9595
b instanceof URLSearchParams
9696
) {
97-
// Set standard urlencoded content type with charset
97+
// standard urlencoded content type (+ charset)
9898
opts.headers.set(
9999
'Content-Type',
100100
'application/x-www-form-urlencoded;charset=UTF-8',
@@ -104,13 +104,13 @@ export const createClient = (config: Config = {}): Client => {
104104
if (t) {
105105
opts.headers.set('Content-Type', t);
106106
} else {
107-
// No known type for the blob: avoid sending misleading JSON header
107+
// unknown blob type: avoid sending a misleading JSON header
108108
opts.headers.delete('Content-Type');
109109
}
110110
}
111111
}
112112

113-
// Precompute network body for retries and consistent handling
113+
// precompute network body (stability for retries and interceptors)
114114
const networkBody = getValidRequestBody(opts) as
115115
| RequestInit['body']
116116
| null
@@ -121,7 +121,7 @@ export const createClient = (config: Config = {}): Client => {
121121
return { networkBody, opts, url };
122122
};
123123

124-
// Apply request interceptors to a Request and reflect header/method/signal
124+
// apply request interceptors and mirror header/method/signal back to opts
125125
const applyRequestInterceptors = async (
126126
request: Request,
127127
opts: ResolvedRequestOptions,
@@ -131,18 +131,17 @@ export const createClient = (config: Config = {}): Client => {
131131
request = await fn(request, opts);
132132
}
133133
}
134-
// Reflect any interceptor changes into opts used for network and downstream
134+
// reflect interceptor changes into opts used by the network layer
135135
opts.headers = request.headers;
136136
opts.method = request.method as Uppercase<HttpMethod>;
137-
// Note: we intentionally ignore request.body changes from interceptors to
138-
// avoid turning serialized bodies into streams. Body is sourced solely
139-
// from getValidRequestBody(options) for consistency.
140-
// Attempt to reflect possible signal changes
137+
// ignore request.body changes to avoid turning serialized bodies into streams
138+
// body comes only from getValidRequestBody(options)
139+
// reflect signal if present
141140
opts.signal = (request as any).signal as AbortSignal | undefined;
142141
return request;
143142
};
144143

145-
// Build ofetch options with stable retry logic based on body repeatability
144+
// build ofetch options with stable retry logic based on body repeatability
146145
const buildNetworkOptions = (
147146
opts: ResolvedRequestOptions,
148147
body: BodyInit | null | undefined,
@@ -160,13 +159,13 @@ export const createClient = (config: Config = {}): Client => {
160159
opts,
161160
url,
162161
} = await resolveOptions(options as any);
163-
// Compute response type mapping once
162+
// map parseAs -> ofetch responseType once per request
164163
const ofetchResponseType: OfetchResponseType | undefined =
165164
mapParseAsToResponseType(opts.parseAs, opts.responseType);
166165

167166
const $ofetch = opts.ofetch ?? ofetch;
168167

169-
// Always create Request pre-network (align with client-fetch)
168+
// create Request before network to run middleware consistently
170169
const networkBody = initialNetworkBody;
171170
const requestInit: ReqInit = {
172171
body: networkBody,
@@ -180,7 +179,7 @@ export const createClient = (config: Config = {}): Client => {
180179
request = await applyRequestInterceptors(request, opts);
181180
const finalUrl = request.url;
182181

183-
// Build ofetch options and perform the request
182+
// build ofetch options and perform the request (.raw keeps the Response)
184183
const responseOptions = buildNetworkOptions(
185184
opts as ResolvedRequestOptions,
186185
networkBody,
@@ -210,7 +209,7 @@ export const createClient = (config: Config = {}): Client => {
210209
}
211210
}
212211

213-
// Ensure error is never undefined after interceptors
212+
// ensure error is never undefined after interceptors
214213
finalError = (finalError as any) || ({} as string);
215214

216215
if (opts.throwOnError) {
@@ -228,7 +227,7 @@ export const createClient = (config: Config = {}): Client => {
228227
(method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
229228
const { networkBody, opts, url } = await resolveOptions(options);
230229
const optsForSse: any = { ...opts };
231-
delete optsForSse.body;
230+
delete optsForSse.body; // body is provided via serializedBody below
232231
return createSseClient({
233232
...optsForSse,
234233
fetch: opts.fetch,

0 commit comments

Comments
 (0)