You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to a simpler TypeScript plugin implementation, the `typescript+namespace` enums mode is no longer necessary. This mode was used in the past to group inline enums under the same namespace. With the latest changes, this behavior is no longer supported. You can either choose to ignore inline enums (default), or use the `enums` transform (added in v0.78.0) to convert them into reusable components which will get exported as usual.
Copy file name to clipboardExpand all lines: docs/openapi-ts/clients/axios.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,5 +222,9 @@ client.setConfig({
222
222
223
223
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom instance to be.
224
224
225
+
## Config API
226
+
227
+
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-axios/types.d.ts) interface.
Copy file name to clipboardExpand all lines: docs/openapi-ts/clients/fetch.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -299,5 +299,9 @@ client.setConfig({
299
299
300
300
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
301
301
302
+
## Config API
303
+
304
+
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.d.ts) interface.
Copy file name to clipboardExpand all lines: docs/openapi-ts/clients/next-js.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,5 +286,9 @@ client.setConfig({
286
286
287
287
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
288
288
289
+
## Config API
290
+
291
+
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-next/types.d.ts) interface.
Copy file name to clipboardExpand all lines: docs/openapi-ts/clients/nuxt.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,5 +248,9 @@ client.setConfig({
248
248
249
249
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
250
250
251
+
## Config API
252
+
253
+
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.d.ts) interface.
Copy file name to clipboardExpand all lines: docs/openapi-ts/migrating.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,12 @@ description: Migrating to @hey-api/openapi-ts.
7
7
8
8
While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features. This page lists changes that require updates to your code. If you run into a problem with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
9
9
10
+
## v0.79.0
11
+
12
+
### Removed `typescript+namespace` enums mode
13
+
14
+
Due to a simpler TypeScript plugin implementation, the `typescript+namespace` enums mode is no longer necessary. This mode was used in the past to group inline enums under the same namespace. With the latest changes, this behavior is no longer supported. You can either choose to ignore inline enums (default), or use the `enums` transform (added in v0.78.0) to convert them into reusable components which will get exported as usual.
Copy file name to clipboardExpand all lines: docs/openapi-ts/output/json-schema.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,5 +96,9 @@ if (userInput.length > maxInputLength) {
96
96
}
97
97
```
98
98
99
+
## Config API
100
+
101
+
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts) interface.
Copy file name to clipboardExpand all lines: docs/openapi-ts/output/sdk.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -224,5 +224,9 @@ export default {
224
224
225
225
Learn more about available validators on the [Validators](/openapi-ts/validators) page.
226
226
227
+
## Config API
228
+
229
+
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts) interface.
Copy file name to clipboardExpand all lines: docs/openapi-ts/output/typescript.md
+62-40Lines changed: 62 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,67 +7,89 @@ description: Learn about files generated with @hey-api/openapi-ts.
7
7
8
8
TypeScript interfaces are located in the `types.gen.ts` file. This is the only file that does not impact your bundle size and runtime performance. It will get discarded during build time, unless you configured to emit runtime [enums](#enums).
9
9
10
-
This file contains three different categories of interfaces created from your input:
10
+
## Installation
11
11
12
-
- reusable components
13
-
- operation request, response, and error data
14
-
- enums
12
+
In your [configuration](/openapi-ts/get-started), add `@hey-api/typescript` to your plugins and you'll be ready to generate TypeScript artifacts. :tada:
15
13
16
-
Depending on your input and configuration, some of these categories might be missing or differ in your output (and that's okay!).
14
+
```js
15
+
exportdefault {
16
+
input:'https://get.heyapi.dev/hey-api/backend',
17
+
output:'src/client',
18
+
plugins: [
19
+
// ...other plugins
20
+
'@hey-api/typescript', // [!code ++]
21
+
],
22
+
};
23
+
```
17
24
18
-
::: code-group
25
+
:::tip
26
+
The `@hey-api/typescript` plugin might be implicitly added to your `plugins` if another plugin depends on it.
27
+
:::
19
28
20
-
```ts [types.gen.ts]
21
-
exporttypePet= {
22
-
id?:number;
23
-
name:string;
24
-
};
29
+
## Output
30
+
31
+
The TypeScript plugin will generate the following artifacts, depending on the input specification.
32
+
33
+
## Requests
25
34
35
+
A single request type is generated for each endpoint. It may contain a request body, parameters, and headers.
36
+
37
+
```ts
26
38
exporttypeAddPetData= {
27
-
body:Pet;
39
+
body: {
40
+
id?:number;
41
+
name:string;
42
+
};
43
+
path?:never;
44
+
query?:never;
45
+
url:'/pets';
28
46
};
29
-
30
-
exporttypeAddPetResponse=Pet;
31
47
```
32
48
33
-
:::
49
+
You can customize the naming and casing pattern for `requests` schemas using the `.name` and `.case` options.
34
50
35
-
Every generated interface inside `types.gen.ts` is exported. You can import individual exports in your application and use them as necessary.
51
+
## Responses
36
52
37
-
## Configuration
53
+
A single type is generated for all endpoint's responses.
38
54
39
-
You can modify the contents of `types.gen.ts` by configuring the `@hey-api/typescript` plugin. Note that you must specify the default plugins to preserve the default output.
You can customize the naming and casing pattern for `responses` schemas using the `.name` and `.case` options.
67
+
68
+
## Definitions
69
+
70
+
A type is generated for every reusable definition from your input.
71
+
72
+
```ts
73
+
exporttypePet= {
74
+
id?:number;
75
+
name:string;
54
76
};
55
77
```
56
78
79
+
You can customize the naming and casing pattern for `definitions` schemas using the `.name` and `.case` options.
80
+
57
81
## Enums
58
82
59
-
By default, `@hey-api/openapi-ts` will only emit enums as types. You may want to generate runtime artifacts. A good use case is iterating through possible field values without manually typing arrays. To emit runtime enums, set `enums` to a valid option.
83
+
By default, `@hey-api/typescript` will emit enums only as types. You may want to generate runtime artifacts. A good use case is iterating through possible field values without manually typing arrays. To emit runtime enums, set `enums` to a valid option.
We recommend exporting enums as plain JavaScript objects. [TypeScript enums](https://www.typescriptlang.org/docs/handbook/enums.html) are not a type-level extension of JavaScript and pose [typing challenges](https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh).
114
132
133
+
## Config API
134
+
135
+
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts) interface.
0 commit comments