@hey-api/openapi-ts 0.80.1 → 0.80.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { AxiosError, RawAxiosRequestHeaders } from 'axios';
1
+ import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios';
2
2
  import axios from 'axios';
3
3
 
4
4
  import type { Client, Config } from './types';
@@ -13,9 +13,15 @@ import {
13
13
  export const createClient = (config: Config = {}): Client => {
14
14
  let _config = mergeConfigs(createConfig(), config);
15
15
 
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- const { auth, ...configWithoutAuth } = _config;
18
- const instance = axios.create(configWithoutAuth);
16
+ let instance: AxiosInstance;
17
+
18
+ if (_config.axios && !('Axios' in _config.axios)) {
19
+ instance = _config.axios;
20
+ } else {
21
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
+ const { auth, ...configWithoutAuth } = _config;
23
+ instance = axios.create(configWithoutAuth);
24
+ }
19
25
 
20
26
  const getConfig = (): Config => ({ ..._config });
21
27
 
@@ -17,12 +17,12 @@ export interface Config<T extends ClientOptions = ClientOptions>
17
17
  extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>,
18
18
  CoreConfig {
19
19
  /**
20
- * Axios implementation. You can use this option to provide a custom
21
- * Axios instance.
20
+ * Axios implementation. You can use this option to provide either an
21
+ * `AxiosStatic` or an `AxiosInstance`.
22
22
  *
23
23
  * @default axios
24
24
  */
25
- axios?: AxiosStatic;
25
+ axios?: AxiosStatic | AxiosInstance;
26
26
  /**
27
27
  * Base URL for all requests made by this client.
28
28
  */