Skip to content

Commit 30c8eca

Browse files
committed
fix(client-axios): stabilize beforeRequest typing across strictFunctionTypes
1 parent d7e660e commit 30c8eca

12 files changed

Lines changed: 48 additions & 36 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/client.gen.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client/client.gen.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/client/client.gen.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client/client.gen.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client/client.gen.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/client/client.gen.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const createClient = (config: Config = {}): Client => {
3535
return getConfig();
3636
};
3737

38-
const beforeRequest = async (options: RequestOptions) => {
38+
const beforeRequest = async <TData = unknown, Url extends string = string>(
39+
options: RequestOptions<TData, boolean, Url>,
40+
) => {
3941
const opts = {
4042
..._config,
4143
...options,
@@ -58,14 +60,13 @@ export const createClient = (config: Config = {}): Client => {
5860
opts.body = opts.bodySerializer(opts.body);
5961
}
6062

61-
const url = buildUrl(opts);
63+
const url = buildUrl(opts as RequestOptions<unknown, boolean, string>);
6264

6365
return { opts, url };
6466
};
6567

6668
// @ts-expect-error
6769
const request: Client['request'] = async (options) => {
68-
// @ts-expect-error
6970
const { opts, url } = await beforeRequest(options);
7071
try {
7172
// assign Axios here for consistency with fetch

0 commit comments

Comments
 (0)