Skip to content

Commit 2eb77fb

Browse files
committed
chore: update example and test snapshots
1 parent bbb2ffd commit 2eb77fb

681 files changed

Lines changed: 24222 additions & 25639 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/openapi-ts-angular-common/src/client/client/client.gen.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,30 @@ export const createClient = (config: Config = {}): Client => {
122122
};
123123

124124
const request: Client['request'] = async (options) => {
125-
const { opts, req: initialReq } = await beforeRequest(options);
126-
127-
let req = initialReq;
128-
129-
for (const fn of interceptors.request.fns) {
130-
if (fn) {
131-
req = await fn(req, opts as any);
132-
}
133-
}
125+
const throwOnError = options.throwOnError ?? _config.throwOnError;
126+
const responseStyle = options.responseStyle ?? _config.responseStyle;
134127

135128
const result: {
136-
request: HttpRequest<unknown>;
129+
request?: HttpRequest<unknown>;
137130
response: any;
138131
} = {
139-
request: req,
132+
request: undefined,
140133
response: null,
141134
};
142135

143136
try {
137+
const { opts, req: initialReq } = await beforeRequest(options);
138+
139+
let req = initialReq;
140+
result.request = req;
141+
142+
for (const fn of interceptors.request.fns) {
143+
if (fn) {
144+
req = await fn(req, opts as any);
145+
result.request = req;
146+
}
147+
}
148+
144149
result.response = (await firstValueFrom(
145150
opts
146151
.httpClient!.request(req)
@@ -173,15 +178,20 @@ export const createClient = (config: Config = {}): Client => {
173178

174179
for (const fn of interceptors.error.fns) {
175180
if (fn) {
176-
finalError = (await fn(finalError, result.response as any, req, opts as any)) as string;
181+
finalError = (await fn(
182+
finalError,
183+
result.response as any,
184+
result.request,
185+
options as any,
186+
)) as string;
177187
}
178188
}
179189

180-
if (opts.throwOnError) {
190+
if (throwOnError) {
181191
throw finalError;
182192
}
183193

184-
return opts.responseStyle === 'data'
194+
return responseStyle === 'data'
185195
? undefined
186196
: {
187197
error: finalError,

examples/openapi-ts-angular-common/src/client/client/types.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export type RequestResult<
129129
| {
130130
data: undefined;
131131
error: TError[keyof TError];
132-
request: HttpRequest<unknown>;
132+
/** request may be undefined, because error may be from building the request object itself */
133+
request?: HttpRequest<unknown>;
133134
response: HttpErrorResponse & {
134135
error: TError[keyof TError] | null;
135136
};

examples/openapi-ts-angular-common/src/client/client/utils.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ export const mergeHeaders = (
312312
type ErrInterceptor<Err, Res, Req, Options> = (
313313
error: Err,
314314
response: Res,
315-
request: Req,
315+
/** request may be undefined, because error may be from building the request object itself */
316+
request: Req | undefined,
316317
options: Options,
317318
) => Err | Promise<Err>;
318319

examples/openapi-ts-angular/src/client/client/client.gen.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,30 @@ export const createClient = (config: Config = {}): Client => {
122122
};
123123

124124
const request: Client['request'] = async (options) => {
125-
const { opts, req: initialReq } = await beforeRequest(options);
126-
127-
let req = initialReq;
128-
129-
for (const fn of interceptors.request.fns) {
130-
if (fn) {
131-
req = await fn(req, opts as any);
132-
}
133-
}
125+
const throwOnError = options.throwOnError ?? _config.throwOnError;
126+
const responseStyle = options.responseStyle ?? _config.responseStyle;
134127

135128
const result: {
136-
request: HttpRequest<unknown>;
129+
request?: HttpRequest<unknown>;
137130
response: any;
138131
} = {
139-
request: req,
132+
request: undefined,
140133
response: null,
141134
};
142135

143136
try {
137+
const { opts, req: initialReq } = await beforeRequest(options);
138+
139+
let req = initialReq;
140+
result.request = req;
141+
142+
for (const fn of interceptors.request.fns) {
143+
if (fn) {
144+
req = await fn(req, opts as any);
145+
result.request = req;
146+
}
147+
}
148+
144149
result.response = (await firstValueFrom(
145150
opts
146151
.httpClient!.request(req)
@@ -173,15 +178,20 @@ export const createClient = (config: Config = {}): Client => {
173178

174179
for (const fn of interceptors.error.fns) {
175180
if (fn) {
176-
finalError = (await fn(finalError, result.response as any, req, opts as any)) as string;
181+
finalError = (await fn(
182+
finalError,
183+
result.response as any,
184+
result.request,
185+
options as any,
186+
)) as string;
177187
}
178188
}
179189

180-
if (opts.throwOnError) {
190+
if (throwOnError) {
181191
throw finalError;
182192
}
183193

184-
return opts.responseStyle === 'data'
194+
return responseStyle === 'data'
185195
? undefined
186196
: {
187197
error: finalError,

examples/openapi-ts-angular/src/client/client/types.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export type RequestResult<
129129
| {
130130
data: undefined;
131131
error: TError[keyof TError];
132-
request: HttpRequest<unknown>;
132+
/** request may be undefined, because error may be from building the request object itself */
133+
request?: HttpRequest<unknown>;
133134
response: HttpErrorResponse & {
134135
error: TError[keyof TError] | null;
135136
};

examples/openapi-ts-angular/src/client/client/utils.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ export const mergeHeaders = (
312312
type ErrInterceptor<Err, Res, Req, Options> = (
313313
error: Err,
314314
response: Res,
315-
request: Req,
315+
/** request may be undefined, because error may be from building the request object itself */
316+
request: Req | undefined,
316317
options: Options,
317318
) => Err | Promise<Err>;
318319

0 commit comments

Comments
 (0)