Skip to content

Commit ccefe43

Browse files
committed
chore: add migration notes
1 parent e436bc5 commit ccefe43

File tree

116 files changed

+260
-129
lines changed

Some content is hidden

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

116 files changed

+260
-129
lines changed

.changeset/long-keys-refuse.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@hey-api/openapi-ts': minor
3+
---
4+
5+
feat: added `client.baseUrl` option
6+
7+
### Added `client.baseUrl` option
8+
9+
You can use this option to configure the default base URL for the generated client. By default, we will attempt to resolve the first defined server or infer the base URL from the input path. If you'd like to preserve the previous behavior, set `baseUrl` to `false`.
10+
11+
```js
12+
export default {
13+
input: 'path/to/openapi.json',
14+
output: 'src/client',
15+
plugins: [{
16+
baseUrl: false, // [!code ++]
17+
name: '@hey-api/client-fetch',
18+
}],
19+
};
20+
```

.changeset/unlucky-moles-dance.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
---
2-
'@hey-api/client-axios': patch
3-
'@hey-api/client-fetch': patch
4-
'@hey-api/client-next': patch
5-
'@hey-api/client-nuxt': patch
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+
'@hey-api/openapi-ts': minor
67
---
78

89
fix: make createConfig, CreateClientConfig, and Config accept ClientOptions generic
10+
11+
### Added `ClientOptions` interface
12+
13+
The `Config` interface now accepts an optional generic extending `ClientOptions` instead of `boolean` type `ThrowOnError`.
14+
15+
```ts
16+
type Foo = Config<false> // [!code --]
17+
type Foo = Config<{ throwOnError: false }> // [!code ++]
18+
```

docs/openapi-ts/clients/axios.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ In our custom file, we need to export a `createClientConfig()` method. This func
106106
::: code-group
107107

108108
```ts [hey-api.ts]
109-
import type { CreateClientConfig } from '@hey-api/client-axios';
109+
import type { CreateClientConfig } from './client/client.gen';
110110

111111
export const createClientConfig: CreateClientConfig = (config) => ({
112112
...config,

docs/openapi-ts/clients/fetch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ In our custom file, we need to export a `createClientConfig()` method. This func
106106
::: code-group
107107

108108
```ts [hey-api.ts]
109-
import type { CreateClientConfig } from '@hey-api/client-fetch';
109+
import type { CreateClientConfig } from './client/client.gen';
110110

111111
export const createClientConfig: CreateClientConfig = (config) => ({
112112
...config,

docs/openapi-ts/clients/next-js.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ In our custom file, we need to export a `createClientConfig()` method. This func
102102
::: code-group
103103

104104
```ts [hey-api.ts]
105-
import type { CreateClientConfig } from '@hey-api/client-next';
105+
import type { CreateClientConfig } from './client/client.gen';
106106

107107
export const createClientConfig: CreateClientConfig = (config) => ({
108108
...config,

docs/openapi-ts/clients/nuxt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ In our custom file, we need to export a `createClientConfig()` method. This func
102102
::: code-group
103103

104104
```ts [hey-api.ts]
105-
import type { CreateClientConfig } from '@hey-api/client-nuxt';
105+
import type { CreateClientConfig } from './client/client.gen';
106106

107107
export const createClientConfig: CreateClientConfig = (config) => ({
108108
...config,

docs/openapi-ts/migrating.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@ This config option is deprecated and will be removed in favor of [clients](./cli
2727

2828
This config option is deprecated and will be removed.
2929

30+
## v0.64.0
31+
32+
### Added `ClientOptions` interface
33+
34+
The `Config` interface now accepts an optional generic extending `ClientOptions` instead of `boolean` type `ThrowOnError`.
35+
36+
```ts
37+
type Foo = Config<false>; // [!code --]
38+
type Foo = Config<{ throwOnError: false }>; // [!code ++]
39+
```
40+
41+
### Added `client.baseUrl` option
42+
43+
You can use this option to configure the default base URL for the generated client. By default, we will attempt to resolve the first defined server or infer the base URL from the input path. If you'd like to preserve the previous behavior, set `baseUrl` to `false`.
44+
45+
```js
46+
export default {
47+
input: 'path/to/openapi.json',
48+
output: 'src/client',
49+
plugins: [
50+
{
51+
baseUrl: false, // [!code ++]
52+
name: '@hey-api/client-fetch',
53+
},
54+
],
55+
};
56+
```
57+
3058
## v0.63.0
3159

3260
### Client plugins
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
import { createClient, createConfig } from '@hey-api/client-next';
3+
import {
4+
type ClientOptions as DefaultClientOptions,
5+
type Config,
6+
createClient,
7+
createConfig,
8+
} from '@hey-api/client-next';
49

510
import { createClientConfig } from '../hey-api';
11+
import type { ClientOptions } from './types.gen';
612

7-
export const client = createClient(createClientConfig(createConfig()));
13+
/**
14+
* The `createClientConfig()` function will be called on client initialization
15+
* and the returned object will become the client's initial configuration.
16+
*
17+
* You may want to initialize your client this way instead of calling
18+
* `setConfig()`. This is useful for example if you're using Next.js
19+
* to ensure your client always has the correct values.
20+
*/
21+
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =
22+
(
23+
override?: Config<DefaultClientOptions & T>,
24+
) => Config<Required<DefaultClientOptions> & T>;
25+
26+
export const client = createClient(
27+
createClientConfig(createConfig<ClientOptions>()),
28+
);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,7 @@ export type UpdateUserResponses = {
561561
*/
562562
default: unknown;
563563
};
564+
565+
export type ClientOptions = {
566+
baseUrl: `${string}://${string}/v3` | (string & {});
567+
};

examples/openapi-ts-next/src/hey-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CreateClientConfig } from '@hey-api/client-next';
1+
import type { CreateClientConfig } from './client/client.gen';
22

33
export const createClientConfig: CreateClientConfig = (config) => ({
44
...config,

0 commit comments

Comments
 (0)