···11+---
22+'@hey-api/openapi-ts': minor
33+---
44+55+### Removed `typescript+namespace` enums mode
66+77+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.
+4
docs/openapi-ts/clients/axios.md
···222222223223You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom instance to be.
224224225225+## Config API
226226+227227+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.
228228+225229<!--@include: ../../examples.md-->
226230<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/clients/fetch.md
···299299300300You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
301301302302+## Config API
303303+304304+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.
305305+302306<!--@include: ../../examples.md-->
303307<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/clients/next-js.md
···286286287287You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
288288289289+## Config API
290290+291291+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.
292292+289293<!--@include: ../../examples.md-->
290294<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/clients/nuxt.md
···248248249249You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
250250251251+## Config API
252252+253253+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.
254254+251255<!--@include: ../../examples.md-->
252256<!--@include: ../../sponsors.md-->
+6
docs/openapi-ts/migrating.md
···7788While 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).
991010+## v0.79.0
1111+1212+### Removed `typescript+namespace` enums mode
1313+1414+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.
1515+1016## v0.78.0
11171218### Added `parser` options
+4
docs/openapi-ts/output/json-schema.md
···9696}
9797```
98989999+## Config API
100100+101101+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.
102102+99103<!--@include: ../../examples.md-->
100104<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/output/sdk.md
···224224225225Learn more about available validators on the [Validators](/openapi-ts/validators) page.
226226227227+## Config API
228228+229229+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.
230230+227231<!--@include: ../../examples.md-->
228232<!--@include: ../../sponsors.md-->
+62-40
docs/openapi-ts/output/typescript.md
···7788TypeScript 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).
991010-This file contains three different categories of interfaces created from your input:
1010+## Installation
11111212-- reusable components
1313-- operation request, response, and error data
1414-- enums
1212+In your [configuration](/openapi-ts/get-started), add `@hey-api/typescript` to your plugins and you'll be ready to generate TypeScript artifacts. :tada:
15131616-Depending on your input and configuration, some of these categories might be missing or differ in your output (and that's okay!).
1414+```js
1515+export default {
1616+ input: 'https://get.heyapi.dev/hey-api/backend',
1717+ output: 'src/client',
1818+ plugins: [
1919+ // ...other plugins
2020+ '@hey-api/typescript', // [!code ++]
2121+ ],
2222+};
2323+```
17241818-::: code-group
2525+:::tip
2626+The `@hey-api/typescript` plugin might be implicitly added to your `plugins` if another plugin depends on it.
2727+:::
2828+2929+## Output
3030+3131+The TypeScript plugin will generate the following artifacts, depending on the input specification.
3232+3333+## Requests
19342020-```ts [types.gen.ts]
2121-export type Pet = {
2222- id?: number;
2323- name: string;
2424-};
3535+A single request type is generated for each endpoint. It may contain a request body, parameters, and headers.
25363737+```ts
2638export type AddPetData = {
2727- body: Pet;
3939+ body: {
4040+ id?: number;
4141+ name: string;
4242+ };
4343+ path?: never;
4444+ query?: never;
4545+ url: '/pets';
2846};
2929-3030-export type AddPetResponse = Pet;
3147```
32483333-:::
4949+You can customize the naming and casing pattern for `requests` schemas using the `.name` and `.case` options.
34503535-Every generated interface inside `types.gen.ts` is exported. You can import individual exports in your application and use them as necessary.
5151+## Responses
36523737-## Configuration
5353+A single type is generated for all endpoint's responses.
38543939-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.
5555+```ts
5656+export type AddPetResponses = {
5757+ 200: {
5858+ id?: number;
5959+ name: string;
6060+ };
6161+};
40624141-```js
4242-import { defaultPlugins } from '@hey-api/openapi-ts';
6363+export type AddPetResponse = AddPetResponses[keyof AddPetResponses];
6464+```
43654444-export default {
4545- input: 'https://get.heyapi.dev/hey-api/backend',
4646- output: 'src/client',
4747- plugins: [
4848- ...defaultPlugins,
4949- {
5050- name: '@hey-api/typescript',
5151- // ...custom options // [!code ++]
5252- },
5353- ],
6666+You can customize the naming and casing pattern for `responses` schemas using the `.name` and `.case` options.
6767+6868+## Definitions
6969+7070+A type is generated for every reusable definition from your input.
7171+7272+```ts
7373+export type Pet = {
7474+ id?: number;
7575+ name: string;
5476};
5577```
7878+7979+You can customize the naming and casing pattern for `definitions` schemas using the `.name` and `.case` options.
56805781## Enums
58825959-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.
8383+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.
60846185::: code-group
62866387```js [disabled]
6464-import { defaultPlugins } from '@hey-api/openapi-ts';
6565-6688export default {
6789 input: 'https://get.heyapi.dev/hey-api/backend',
6890 output: 'src/client',
6991 plugins: [
7070- ...defaultPlugins,
9292+ // ...other plugins
7193 {
7294 enums: false, // default // [!code ++]
7395 name: '@hey-api/typescript',
···7799```
7810079101```js [javascript]
8080-import { defaultPlugins } from '@hey-api/openapi-ts';
8181-82102export default {
83103 input: 'https://get.heyapi.dev/hey-api/backend',
84104 output: 'src/client',
85105 plugins: [
8686- ...defaultPlugins,
106106+ // ...other plugins
87107 {
88108 enums: 'javascript', // [!code ++]
89109 name: '@hey-api/typescript',
···93113```
9411495115```js [typescript]
9696-import { defaultPlugins } from '@hey-api/openapi-ts';
9797-98116export default {
99117 input: 'https://get.heyapi.dev/hey-api/backend',
100118 output: 'src/client',
101119 plugins: [
102102- ...defaultPlugins,
120120+ // ...other plugins
103121 {
104122 enums: 'typescript', // [!code ++]
105123 name: '@hey-api/typescript',
···111129:::
112130113131We 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).
132132+133133+## Config API
134134+135135+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.
114136115137<!--@include: ../../examples.md-->
116138<!--@include: ../../sponsors.md-->
+2-2
docs/openapi-ts/plugins/custom.md
···3333```ts [types.d.ts]
3434import type { DefinePlugin } from '@hey-api/openapi-ts';
35353636-export type Config = {
3636+export type UserConfig = {
3737 /**
3838 * Plugin name. Must be unique.
3939 */
···5252 myOption?: boolean;
5353};
54545555-export type MyPlugin = DefinePlugin<Config>;
5555+export type MyPlugin = DefinePlugin<UserConfig>;
5656```
57575858:::
+4
docs/openapi-ts/plugins/fastify.md
···7575fastify.register(glue, { serviceHandlers });
7676```
77777878+## Config API
7979+8080+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/fastify/types.d.ts) interface.
8181+7882<!--@include: ../../examples.md-->
7983<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/plugins/tanstack-query.md
···200200201201You can customize the naming and casing pattern for `mutationOptions` functions using the `.name` and `.case` options.
202202203203+## Config API
204204+205205+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/@tanstack/react-query/types.d.ts) interface.
206206+203207<!--@include: ../../examples.md-->
204208<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/plugins/valibot.md
···142142};
143143```
144144145145+## Config API
146146+147147+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/valibot/types.d.ts) interface.
148148+145149<!--@include: ../../examples.md-->
146150<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/plugins/zod.md
···142142};
143143```
144144145145+## Config API
146146+147147+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/zod/types.d.ts) interface.
148148+145149<!--@include: ../../examples.md-->
146150<!--@include: ../../sponsors.md-->
+4
docs/openapi-ts/transformers.md
···139139140140:::
141141142142+## Config API
143143+144144+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/transformers/types.d.ts) interface.
145145+142146<!--@include: ../sponsors.md-->
···11-// This file is auto-generated by @hey-api/openapi-ts
22-export { ApiError } from './core/ApiError';
33-export { CancelablePromise, CancelError } from './core/CancelablePromise';
44-export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI';
55-export * from './sdk.gen';
66-export * from './types.gen';
···1414};
15151616export const getUniqueComponentName = ({
1717- base: _base,
1717+ base,
1818 components,
1919 extraComponents,
2020}: {
···2929 extraComponents?: Obj;
3030}): string => {
3131 let index = 2;
3232- // Strip trailing number. For example, if base is "foo2", the clean base will be "foo"
3333- const base = _base.replace(/\d+$/, '');
3432 let name = base;
3533 while (
3634 hasName(components, name) ||
···11import type { DefinePlugin, Plugin } from '../../types';
22import type { Client } from '../client-core/types';
3344-export type Config = Plugin.Name<'@hey-api/client-axios'> &
44+export type UserConfig = Plugin.Name<'@hey-api/client-axios'> &
55 Client.Config & {
66 /**
77 * Throw an error instead of returning it in the response?
···1111 throwOnError?: boolean;
1212 };
13131414-export type HeyApiClientAxiosPlugin = DefinePlugin<Config>;
1414+export type HeyApiClientAxiosPlugin = DefinePlugin<UserConfig>;
···11import type { DefinePlugin, Plugin } from '../../types';
22import type { Client } from '../client-core/types';
3344-export type Config = Plugin.Name<'@hey-api/client-fetch'> &
44+export type UserConfig = Plugin.Name<'@hey-api/client-fetch'> &
55 Client.Config & {
66 /**
77 * Throw an error instead of returning it in the response?
···1111 throwOnError?: boolean;
1212 };
13131414-export type HeyApiClientFetchPlugin = DefinePlugin<Config>;
1414+export type HeyApiClientFetchPlugin = DefinePlugin<UserConfig>;
···11import type { DefinePlugin, Plugin } from '../../types';
22import type { Client } from '../client-core/types';
3344-export type Config = Plugin.Name<'@hey-api/client-next'> &
44+export type UserConfig = Plugin.Name<'@hey-api/client-next'> &
55 Client.Config & {
66 /**
77 * Throw an error instead of returning it in the response?
···1111 throwOnError?: boolean;
1212 };
13131414-export type HeyApiClientNextPlugin = DefinePlugin<Config>;
1414+export type HeyApiClientNextPlugin = DefinePlugin<UserConfig>;
···11import type { DefinePlugin, Plugin } from '../../types';
22import type { Client } from '../client-core/types';
3344-export type Config = Plugin.Name<'@hey-api/client-nuxt'> & Client.Config;
44+export type UserConfig = Plugin.Name<'@hey-api/client-nuxt'> & Client.Config;
5566-export type HeyApiClientNuxtPlugin = DefinePlugin<Config>;
66+export type HeyApiClientNuxtPlugin = DefinePlugin<UserConfig>;
···11import type { DefinePlugin, Plugin } from '../../types';
22import type { Client } from '../client-core/types';
3344-export type Config = Plugin.Name<'legacy/angular'> &
44+export type UserConfig = Plugin.Name<'legacy/angular'> &
55 Pick<Client.Config, 'output'>;
6677-export type HeyApiClientLegacyAngularPlugin = DefinePlugin<Config>;
77+export type HeyApiClientLegacyAngularPlugin = DefinePlugin<UserConfig>;
···11import type { DefinePlugin, Plugin } from '../../types';
22import type { Client } from '../client-core/types';
3344-export type Config = Plugin.Name<'legacy/axios'> &
44+export type UserConfig = Plugin.Name<'legacy/axios'> &
55 Pick<Client.Config, 'output'>;
6677-export type HeyApiClientLegacyAxiosPlugin = DefinePlugin<Config>;
77+export type HeyApiClientLegacyAxiosPlugin = DefinePlugin<UserConfig>;
···11import type { DefinePlugin, Plugin } from '../../types';
22import type { Client } from '../client-core/types';
3344-export type Config = Plugin.Name<'legacy/fetch'> &
44+export type UserConfig = Plugin.Name<'legacy/fetch'> &
55 Pick<Client.Config, 'output'>;
6677-export type HeyApiClientLegacyFetchPlugin = DefinePlugin<Config>;
77+export type HeyApiClientLegacyFetchPlugin = DefinePlugin<UserConfig>;
···44import type { OpenApiV3_1_XTypes } from '../../../openApi/3.1.x';
55import type { DefinePlugin, Plugin } from '../../types';
6677-export type Config = Plugin.Name<'@hey-api/schemas'> & {
77+export type UserConfig = Plugin.Name<'@hey-api/schemas'> & {
88 /**
99 * Should the exports from the generated files be re-exported in the index
1010 * barrel file?
···4747 type?: 'form' | 'json';
4848};
49495050-export type HeyApiSchemasPlugin = DefinePlugin<Config>;
5050+export type HeyApiSchemasPlugin = DefinePlugin<UserConfig>;
···11import type { IR } from '../../../ir/types';
22+import type { StringName } from '../../../types/case';
23import type { Operation } from '../../../types/client';
34import type {
45 DefinePlugin,
···78 PluginValidatorNames,
89} from '../../types';
9101010-export type Config = Plugin.Name<'@hey-api/sdk'> & {
1111+export type UserConfig = Plugin.Name<'@hey-api/sdk'> & {
1112 /**
1213 * Group operation methods into classes? When enabled, you can select which
1314 * classes to export with `sdk.include` and/or transform their names with
···3435 *
3536 * This option has no effect if `sdk.asClass` is `false`.
3637 */
3737- classNameBuilder?: string | ((name: string) => string);
3838+ classNameBuilder?: StringName;
3839 /**
3940 * How should we structure your SDK? By default, we try to infer the ideal
4041 * structure using `operationId` keywords. If you prefer a flatter structure,
···180181 response?: 'body' | 'response';
181182};
182183183183-export type ResolvedConfig = Plugin.Name<'@hey-api/sdk'> & {
184184+export type Config = Plugin.Name<'@hey-api/sdk'> & {
184185 /**
185186 * Group operation methods into classes? When enabled, you can select which
186187 * classes to export with `sdk.include` and/or transform their names with
···207208 *
208209 * This option has no effect if `sdk.asClass` is `false`.
209210 */
210210- classNameBuilder: string | ((name: string) => string);
211211+ classNameBuilder: StringName;
211212 /**
212213 * How should we structure your SDK? By default, we try to infer the ideal
213214 * structure using `operationId` keywords. If you prefer a flatter structure,
···332333 response: 'body' | 'response';
333334};
334335335335-export type HeyApiSdkPlugin = DefinePlugin<Config, ResolvedConfig>;
336336+export type HeyApiSdkPlugin = DefinePlugin<UserConfig, Config>;
···11import type { DefinePlugin, Plugin } from '../types';
2233-export type Config = Plugin.Name<'fastify'> & {
33+export type UserConfig = Plugin.Name<'fastify'> & {
44 /**
55 * Should the exports from the generated files be re-exported in the index
66 * barrel file?
···1616 output?: string;
1717};
18181919-export type FastifyPlugin = DefinePlugin<Config>;
1919+export type FastifyPlugin = DefinePlugin<UserConfig>;
···66 OpenApiResponseObject,
77 OpenApiSchemaObject,
88} from '../openApi/types';
99-import type { StringCase } from './case';
99+import type { StringCase, StringName } from './case';
10101111type EnumsMode = 'inline' | 'root';
1212···8383 *
8484 * @default '{{name}}Enum'
8585 */
8686- name?: string | ((name: string) => string);
8686+ name?: StringName;
8787 };
8888 /**
8989 * Your schemas might contain read-only or write-only fields. Using such
···107107 enabled?: boolean;
108108 /**
109109 * Configuration for generated request-specific schemas.
110110+ *
111111+ * Can be:
112112+ * - `string` or `function`: Shorthand for `{ name: string | function }`
113113+ * - `object`: Full configuration object
110114 *
111115 * @default '{{name}}Writable'
112116 */
113117 requests?:
114114- | string
118118+ | StringName
115119 | {
116120 /**
117121 * The casing convention to use for generated names.
···125129 *
126130 * @default '{{name}}Writable'
127131 */
128128- name?: string | ((name: string) => string);
132132+ name?: StringName;
129133 };
130134 /**
131135 * Configuration for generated response-specific schemas.
132136 *
137137+ * Can be:
138138+ * - `string` or `function`: Shorthand for `{ name: string | function }`
139139+ * - `object`: Full configuration object
140140+ *
133141 * @default '{{name}}'
134142 */
135143 responses?:
136136- | string
144144+ | StringName
137145 | {
138146 /**
139147 * The casing convention to use for generated names.
···148156 *
149157 * @default '{{name}}'
150158 */
151151- name?: string | ((name: string) => string);
159159+ name?: StringName;
152160 };
153161 };
154162 };
···232240 *
233241 * @default '{{name}}Enum'
234242 */
235235- name: string | ((name: string) => string);
243243+ name: StringName;
236244 };
237245 /**
238246 * Your schemas might contain read-only or write-only fields. Using such
···266274 *
267275 * @default '{{name}}Writable'
268276 */
269269- name: string | ((name: string) => string);
277277+ name: StringName;
270278 };
271279 /**
272280 * Configuration for generated response-specific schemas.
···285293 *
286294 * @default '{{name}}'
287295 */
288288- name: string | ((name: string) => string);
296296+ name: StringName;
289297 };
290298 };
291299 };
+2-2
packages/openapi-ts/src/types/utils.d.ts
···11-import type { TypeScriptFile } from '../generate/files';
11+import type { GeneratedFile } from '../generate/file';
2233-export type Files = Record<string, TypeScriptFile>;
33+export type Files = Record<string, GeneratedFile>;