Skip to content

Commit 0669e89

Browse files
authored
Merge pull request #1889 from hey-api/feat/client-custom-2
feat: support custom clients
2 parents 069bb0d + 67c385b commit 0669e89

Some content is hidden

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

85 files changed

+37581
-13
lines changed

.changeset/silver-mice-dance.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@hey-api/client-axios': minor
3+
'@hey-api/client-fetch': minor
4+
'@hey-api/client-next': minor
5+
'@hey-api/client-nuxt': minor
6+
---
7+
8+
fix: add @hey-api/openapi-ts to peer dependencies

.changeset/spotty-hats-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': minor
3+
---
4+
5+
feat: support custom clients

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
"@arethetypeswrong/cli": "0.17.2",
4646
"@changesets/changelog-github": "0.5.0",
4747
"@changesets/cli": "2.27.8",
48+
"@hey-api/client-axios": "workspace:*",
49+
"@hey-api/client-custom": "workspace:*",
50+
"@hey-api/client-fetch": "workspace:*",
51+
"@hey-api/client-next": "workspace:*",
52+
"@hey-api/client-nuxt": "workspace:*",
4853
"@types/node": "22.10.5",
4954
"@typescript-eslint/eslint-plugin": "7.18.0",
5055
"@vitest/coverage-v8": "1.6.0",

packages/client-axios/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@
6666
"typecheck": "vitest --typecheck --watch=false"
6767
},
6868
"peerDependencies": {
69+
"@hey-api/openapi-ts": "< 2",
6970
"axios": ">= 1.0.0 < 2"
7071
},
7172
"devDependencies": {
7273
"@hey-api/client-core": "workspace:*",
74+
"@hey-api/openapi-ts": "workspace:*",
7375
"axios": "1.7.9"
7476
}
7577
}

packages/client-custom/src/plugin.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import {
2+
type Client,
23
clientDefaultConfig,
34
clientPluginHandler,
45
type Plugin,
56
} from '@hey-api/openapi-ts';
67

7-
export interface Config {
8+
export interface Config extends Client.Config {
89
/**
910
* Plugin name. Must be unique.
1011
*/
11-
name: 'my-client';
12+
name: '@hey-api/client-custom';
1213
}
1314

1415
export const defaultConfig: Plugin.Config<Config> = {
1516
...clientDefaultConfig,
1617
_handler: clientPluginHandler,
1718
_handlerLegacy: () => {},
18-
name: 'my-client',
19+
name: '@hey-api/client-custom',
1920
};
2021

2122
/**
22-
* Type helper for `my-client` plugin, returns {@link Plugin.Config} object
23+
* Type helper for `@hey-api/client-custom` plugin, returns {@link Plugin.Config} object
2324
*/
2425
export const customClientPlugin: Plugin.DefineConfig<Config> = (config) => ({
2526
...defaultConfig,

packages/client-fetch/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
"test": "vitest run",
6666
"typecheck": "vitest --typecheck --watch=false"
6767
},
68+
"peerDependencies": {
69+
"@hey-api/openapi-ts": "< 2"
70+
},
6871
"devDependencies": {
69-
"@hey-api/client-core": "workspace:*"
72+
"@hey-api/client-core": "workspace:*",
73+
"@hey-api/openapi-ts": "workspace:*"
7074
}
7175
}

packages/client-next/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
"test": "vitest run",
6666
"typecheck": "vitest --typecheck --watch=false"
6767
},
68+
"peerDependencies": {
69+
"@hey-api/openapi-ts": "< 2"
70+
},
6871
"devDependencies": {
69-
"@hey-api/client-core": "workspace:*"
72+
"@hey-api/client-core": "workspace:*",
73+
"@hey-api/openapi-ts": "workspace:*"
7074
}
7175
}

packages/client-nuxt/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@
6161
"typecheck": "vitest --typecheck --watch=false"
6262
},
6363
"peerDependencies": {
64+
"@hey-api/openapi-ts": "< 2",
6465
"nuxt": ">= 3.0.0 < 4",
6566
"vue": ">= 3.5.13 < 4"
6667
},
6768
"devDependencies": {
6869
"@hey-api/client-core": "workspace:*",
70+
"@hey-api/openapi-ts": "workspace:*",
6971
"@nuxt/test-utils": "3.14.0",
7072
"vite": "6.0.9"
7173
}

packages/openapi-ts-tests/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@test/openapi-ts",
33
"version": "0.0.0",
4+
"private": true,
45
"type": "module",
56
"scripts": {
67
"test:coverage": "vitest run --config vitest.config.unit.ts --coverage",
@@ -29,6 +30,7 @@
2930
"@angular/platform-browser-dynamic": "19.2.0",
3031
"@angular/router": "19.2.0",
3132
"@hey-api/client-axios": "workspace:*",
33+
"@hey-api/client-core": "workspace:*",
3234
"@hey-api/client-custom": "workspace:*",
3335
"@hey-api/client-fetch": "workspace:*",
3436
"@hey-api/client-next": "workspace:*",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
import type { ClientOptions } from './types.gen';
4+
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-custom';
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 DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
15+
16+
export const client = createClient(createConfig<ClientOptions>());
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
export * from './types.gen';

0 commit comments

Comments
 (0)