···1111 - theme: alt
1212 text: View Demo
1313 link: https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts
1414+ - theme: alt
1515+ text: Roadmap
1616+ link: https://github.com/orgs/hey-api/discussions/1495
1417 image:
1518 src: /logo.png
1619 alt: logo
+1-1
docs/openapi-ts/clients.md
···3333Don't see your client? Let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
34343535<!--@include: ../examples.md-->
3636-<!--@include: ../sponsorship.md-->
3636+<!--@include: ../sponsors.md-->
···278278You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/types/config.ts) interface.
279279280280<!--@include: ../examples.md-->
281281-<!--@include: ../sponsorship.md-->
281281+<!--@include: ../sponsors.md-->
+1-1
docs/openapi-ts/custom-plugin.md
···197197Congratulations! You've successfully created your own plugin! :tada:
198198199199<!--@include: ../examples.md-->
200200-<!--@include: ../sponsorship.md-->
200200+<!--@include: ../sponsors.md-->
+2-2
docs/openapi-ts/get-started.md
···1313This package is in initial development. The interface might change before it becomes stable. We encourage you to leave feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues).
1414:::
15151616-[@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) is an OpenAPI to TypeScript codegen trusted more than 700k times each month to generate reliable API clients and SDKs.
1616+[@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) is an OpenAPI to TypeScript codegen trusted more than 700k times each month to generate reliable API clients and SDKs. The code is [MIT-licensed](/license) and free to use. Discover available features below or view our [roadmap](https://github.com/orgs/hey-api/discussions/1495) to learn what's coming next.
17171818<button class="buttonLink" @click="(event) => embedProject('hey-api-example')(event)">
1919Live demo
···9999It is a good practice to extract your configuration into a separate file. Learn how to do that and discover available options on the [Configuration](/openapi-ts/configuration) page.
100100101101<!--@include: ../examples.md-->
102102-<!--@include: ../sponsorship.md-->
102102+<!--@include: ../sponsors.md-->
+1-1
docs/openapi-ts/mocks.md
···1919Don't see your framework? Let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
20202121<!--@include: ../examples.md-->
2222-<!--@include: ../sponsorship.md-->
2222+<!--@include: ../sponsors.md-->
+2-363
docs/openapi-ts/output.md
···2727└── package.json
2828```
29293030-Each file is an artifact generated by a Hey API plugin. This is the default output, we will cover customizing it on this page. These files also form the base for third-party plugins.
3030+Each file is an artifact generated by a Hey API plugin. This is the default output, we will cover customizing it in this section. These files also form the base for third-party plugins.
31313232Let's go through each file in the `src/client` folder and explain what it looks like, what it does, and how to use it.
33333434-## TypeScript
3535-3636-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](/openapi-ts/output#enums).
3737-3838-This file contains three different categories of interfaces created from your input:
3939-4040-- reusable components
4141-- operation request, response, and error data
4242-- enums
4343-4444-Depending on your input and configuration, some of these categories might be missing or differ in your output (and that's okay!).
4545-4646-::: code-group
4747-4848-```ts [types.gen.ts]
4949-export type Pet = {
5050- id?: number;
5151- name: string;
5252-};
5353-5454-export type AddPetData = {
5555- body: Pet;
5656-};
5757-5858-export type AddPetResponse = Pet;
5959-```
6060-6161-:::
6262-6363-As you can see, everything is exported from `types.gen.ts`. You can import individual exports in your application and use them as necessary.
6464-6565-### Configuration
6666-6767-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.
6868-6969-```js
7070-import { defaultPlugins } from '@hey-api/openapi-ts';
7171-7272-export default {
7373- client: '@hey-api/client-fetch',
7474- input: 'path/to/openapi.json',
7575- output: 'src/client',
7676- plugins: [
7777- ...defaultPlugins,
7878- {
7979- name: '@hey-api/typescript',
8080- // ...custom options // [!code ++]
8181- },
8282- ],
8383-};
8484-```
8585-8686-## Enums
8787-8888-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.
8989-9090-::: code-group
9191-9292-```js [disabled]
9393-import { defaultPlugins } from '@hey-api/openapi-ts';
9494-9595-export default {
9696- client: '@hey-api/client-fetch',
9797- input: 'path/to/openapi.json',
9898- output: 'src/client',
9999- plugins: [
100100- ...defaultPlugins,
101101- {
102102- enums: false, // default // [!code ++]
103103- name: '@hey-api/typescript',
104104- },
105105- ],
106106-};
107107-```
108108-109109-```js [javascript]
110110-import { defaultPlugins } from '@hey-api/openapi-ts';
111111-112112-export default {
113113- client: '@hey-api/client-fetch',
114114- input: 'path/to/openapi.json',
115115- output: 'src/client',
116116- plugins: [
117117- ...defaultPlugins,
118118- {
119119- enums: 'javascript', // [!code ++]
120120- name: '@hey-api/typescript',
121121- },
122122- ],
123123-};
124124-```
125125-126126-```js [typescript]
127127-import { defaultPlugins } from '@hey-api/openapi-ts';
128128-129129-export default {
130130- client: '@hey-api/client-fetch',
131131- input: 'path/to/openapi.json',
132132- output: 'src/client',
133133- plugins: [
134134- ...defaultPlugins,
135135- {
136136- enums: 'typescript', // [!code ++]
137137- name: '@hey-api/typescript',
138138- },
139139- ],
140140-};
141141-```
142142-143143-:::
144144-145145-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).
146146-147147-## SDKs
148148-149149-SDKs are located in the `sdk.gen.ts` file. SDKs are abstractions on top of clients and serve the same purpose. By default, `@hey-api/openapi-ts` will generate a flat SDK layer. Your choice to use SDKs depends on personal preferences and bundle size considerations.
150150-151151-### Flat SDKs
152152-153153-This is the default setting. Flat SDKs support tree-shaking and can lead to reduced bundle size over duplicated client calls. The function names are generated from operation IDs or operation location.
154154-155155-### Class SDKs
156156-157157-Class SDKs do not support tree-shaking which will lead to increased bundle sizes, but some people prefer this option for syntax reasons. The class names are generated from operation tags and method names are generated from operation IDs or operation location.
158158-159159-### No SDKs
160160-161161-If you prefer to use clients directly or do not need the SDK layer, define `plugins` manually and omit the `@hey-api/sdk` plugin. Type support for clients is currently limited due to popularity of other options. If you'd like to use this option and need better types, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
162162-163163-### Configuration
164164-165165-You can modify the contents of `sdk.gen.ts` by configuring the `@hey-api/sdk` plugin. Note that you must specify the default plugins to preserve the default output.
166166-167167-::: code-group
168168-169169-```js [flat]
170170-import { defaultPlugins } from '@hey-api/openapi-ts';
171171-172172-export default {
173173- client: '@hey-api/client-fetch',
174174- input: 'path/to/openapi.json',
175175- output: 'src/client',
176176- plugins: [
177177- ...defaultPlugins,
178178- {
179179- asClass: false, // default // [!code ++]
180180- name: '@hey-api/sdk',
181181- },
182182- ],
183183-};
184184-```
185185-186186-```js [class]
187187-import { defaultPlugins } from '@hey-api/openapi-ts';
188188-189189-export default {
190190- client: '@hey-api/client-fetch',
191191- input: 'path/to/openapi.json',
192192- output: 'src/client',
193193- plugins: [
194194- ...defaultPlugins,
195195- {
196196- asClass: true, // [!code ++]
197197- name: '@hey-api/sdk',
198198- },
199199- ],
200200-};
201201-```
202202-203203-```js [none]
204204-export default {
205205- client: '@hey-api/client-fetch',
206206- input: 'path/to/openapi.json',
207207- output: 'src/client',
208208- plugins: [
209209- '@hey-api/typescript',
210210- '@hey-api/sdk', // [!code --]
211211- ],
212212-};
213213-```
214214-215215-:::
216216-217217-### Output
218218-219219-Below are different outputs depending on your chosen style. No SDKs approach will not generate the `sdk.gen.ts` file.
220220-221221-::: code-group
222222-223223-```ts [flat]
224224-import { client, type Options } from '@hey-api/client-fetch';
225225-226226-import type { AddPetData, AddPetError, AddPetResponse } from './types.gen';
227227-228228-export const addPet = (options: Options<AddPetData>) =>
229229- (options?.client ?? client).post<AddPetResponse, AddPetError>({
230230- ...options,
231231- url: '/pet',
232232- });
233233-```
234234-235235-```ts [class]
236236-import { client, type Options } from '@hey-api/client-fetch';
237237-238238-import type { AddPetData, AddPetError, AddPetResponse } from './types.gen';
239239-240240-export class PetService {
241241- public static addPet(options: Options<AddPetData>) {
242242- return (options?.client ?? client).post<AddPetResponse, AddPetError>({
243243- ...options,
244244- url: '/pet',
245245- });
246246- }
247247-}
248248-```
249249-250250-:::
251251-252252-### Usage
253253-254254-This is how you'd make the same request using each approach.
255255-256256-::: code-group
257257-258258-```ts [flat]
259259-import { addPet } from './client/sdk.gen';
260260-261261-addPet({
262262- body: {
263263- name: 'Kitty',
264264- },
265265-});
266266-```
267267-268268-```ts [class]
269269-import { PetService } from './client/sdk.gen';
270270-271271-PetService.addPet({
272272- body: {
273273- name: 'Kitty',
274274- },
275275-});
276276-```
277277-278278-```ts [none]
279279-import { client } from '@hey-api/client-fetch';
280280-281281-client.post({
282282- body: {
283283- name: 'Kitty',
284284- },
285285- url: '/pet',
286286-});
287287-```
288288-289289-:::
290290-291291-## JSON Schemas
292292-293293-Schemas are located in the `schemas.gen.ts` file. This file contains runtime schemas generated from your OpenAPI specification definitions located in `#/components/schemas`. If you're using OpenAPI 3.1, your schemas are fully JSON Schema compliant and can be used with other tools supporting JSON Schema.
294294-295295-### Configuration
296296-297297-You can modify the contents of `schemas.gen.ts` by configuring the `@hey-api/schemas` plugin. Note that you must specify the default plugins to preserve the default output.
298298-299299-::: code-group
300300-301301-```js [json]
302302-import { defaultPlugins } from '@hey-api/openapi-ts';
303303-304304-export default {
305305- client: '@hey-api/client-fetch',
306306- input: 'path/to/openapi.json',
307307- output: 'src/client',
308308- plugins: [
309309- ...defaultPlugins,
310310- {
311311- name: '@hey-api/schemas',
312312- type: 'json', // [!code ++]
313313- },
314314- ],
315315-};
316316-```
317317-318318-```js [form]
319319-import { defaultPlugins } from '@hey-api/openapi-ts';
320320-321321-export default {
322322- client: '@hey-api/client-fetch',
323323- input: 'path/to/openapi.json',
324324- output: 'src/client',
325325- plugins: [
326326- ...defaultPlugins,
327327- {
328328- name: '@hey-api/schemas',
329329- type: 'form', // [!code ++]
330330- },
331331- ],
332332-};
333333-```
334334-335335-```js [disabled]
336336-import { defaultPlugins } from '@hey-api/openapi-ts';
337337-338338-export default {
339339- client: '@hey-api/client-fetch',
340340- input: 'path/to/openapi.json',
341341- output: 'src/client',
342342- plugins: [
343343- ...defaultPlugins,
344344- '@hey-api/schemas', // [!code --]
345345- ],
346346-};
347347-```
348348-349349-:::
350350-351351-### Output
352352-353353-Below is an example output generated in the `type: 'form'` style. Disabling schemas will not generate the `schemas.gen.ts` file.
354354-355355-```ts
356356-export const PetSchema = {
357357- required: ['name'],
358358- properties: {
359359- id: {
360360- type: 'integer',
361361- format: 'int64',
362362- example: 10,
363363- },
364364- name: {
365365- type: 'string',
366366- example: 'doggie',
367367- },
368368- },
369369- type: 'object',
370370-} as const;
371371-```
372372-373373-### Usage
374374-375375-A great use case for schemas is client-side form input validation.
376376-377377-```ts
378378-import { $Schema } from './client/schemas.gen';
379379-380380-const maxInputLength = $Schema.properties.text.maxLength;
381381-382382-if (userInput.length > maxInputLength) {
383383- throw new Error(`Text length can't exceed ${maxInputLength} characters!`);
384384-}
385385-```
386386-38734## Index
3883538936For convenience, every artifact generated by default plugins is re-exported from `index.ts`. However, we recommend importing artifacts from their files to avoid ambiguity.
···39340import type { Pet } from './client/types.gen'; // [!code ++] // 👍
39441```
39542396396-## Client
397397-398398-Client package files are located in the `client` folder. This folder will include different files depending on which client you're using. This folder isn't generated by default. If you want to bundle client packages into your output, read the [Bundling](/openapi-ts/clients/fetch#bundling) section.
399399-400400-## Plugins
401401-402402-The default output generated by Hey API plugins already allows you to build robust clients. However, you might be working with third-party packages and wishing to automate more of your boilerplate. The [Plugins](/openapi-ts/plugins) page covers this topic and more.
403403-40443<!--@include: ../examples.md-->
405405-<!--@include: ../sponsorship.md-->
4444+<!--@include: ../sponsors.md-->
+103
docs/openapi-ts/output/json-schema.md
···11+---
22+title: JSON Schema
33+description: Learn about files generated with @hey-api/openapi-ts.
44+---
55+66+# JSON Schemas
77+88+Schemas are located in the `schemas.gen.ts` file. This file contains runtime schemas generated from your OpenAPI specification definitions located in `#/components/schemas`. If you're using OpenAPI 3.1, your schemas are fully JSON Schema compliant and can be used with other tools supporting JSON Schema.
99+1010+## Configuration
1111+1212+You can modify the contents of `schemas.gen.ts` by configuring the `@hey-api/schemas` plugin. Note that you must specify the default plugins to preserve the default output.
1313+1414+::: code-group
1515+1616+```js [json]
1717+import { defaultPlugins } from '@hey-api/openapi-ts';
1818+1919+export default {
2020+ client: '@hey-api/client-fetch',
2121+ input: 'path/to/openapi.json',
2222+ output: 'src/client',
2323+ plugins: [
2424+ ...defaultPlugins,
2525+ {
2626+ name: '@hey-api/schemas',
2727+ type: 'json', // [!code ++]
2828+ },
2929+ ],
3030+};
3131+```
3232+3333+```js [form]
3434+import { defaultPlugins } from '@hey-api/openapi-ts';
3535+3636+export default {
3737+ client: '@hey-api/client-fetch',
3838+ input: 'path/to/openapi.json',
3939+ output: 'src/client',
4040+ plugins: [
4141+ ...defaultPlugins,
4242+ {
4343+ name: '@hey-api/schemas',
4444+ type: 'form', // [!code ++]
4545+ },
4646+ ],
4747+};
4848+```
4949+5050+```js [disabled]
5151+import { defaultPlugins } from '@hey-api/openapi-ts';
5252+5353+export default {
5454+ client: '@hey-api/client-fetch',
5555+ input: 'path/to/openapi.json',
5656+ output: 'src/client',
5757+ plugins: [
5858+ ...defaultPlugins,
5959+ '@hey-api/schemas', // [!code --]
6060+ ],
6161+};
6262+```
6363+6464+:::
6565+6666+## Output
6767+6868+Below is an example output generated in the `type: 'form'` style. Disabling schemas will not generate the `schemas.gen.ts` file.
6969+7070+```ts
7171+export const PetSchema = {
7272+ required: ['name'],
7373+ properties: {
7474+ id: {
7575+ type: 'integer',
7676+ format: 'int64',
7777+ example: 10,
7878+ },
7979+ name: {
8080+ type: 'string',
8181+ example: 'doggie',
8282+ },
8383+ },
8484+ type: 'object',
8585+} as const;
8686+```
8787+8888+## Usage
8989+9090+A great use case for schemas is client-side form input validation.
9191+9292+```ts
9393+import { $Schema } from './client/schemas.gen';
9494+9595+const maxInputLength = $Schema.properties.text.maxLength;
9696+9797+if (userInput.length > maxInputLength) {
9898+ throw new Error(`Text length can't exceed ${maxInputLength} characters!`);
9999+}
100100+```
101101+102102+<!--@include: ../../examples.md-->
103103+<!--@include: ../../sponsors.md-->
+151
docs/openapi-ts/output/sdk.md
···11+---
22+title: SDK
33+description: Learn about files generated with @hey-api/openapi-ts.
44+---
55+66+# SDKs
77+88+SDKs are located in the `sdk.gen.ts` file. SDKs are abstractions on top of clients and serve the same purpose. By default, `@hey-api/openapi-ts` will generate a flat SDK layer. Your choice to use SDKs depends on personal preferences and bundle size considerations.
99+1010+### Flat SDKs
1111+1212+This is the default setting. Flat SDKs support tree-shaking and can lead to reduced bundle size over duplicated client calls. The function names are generated from operation IDs or operation location.
1313+1414+### Class SDKs
1515+1616+Class SDKs do not support tree-shaking which will lead to increased bundle sizes, but some people prefer this option for syntax reasons. The class names are generated from operation tags and method names are generated from operation IDs or operation location.
1717+1818+### No SDKs
1919+2020+If you prefer to use clients directly or do not need the SDK layer, define `plugins` manually and omit the `@hey-api/sdk` plugin. Type support for clients is currently limited due to popularity of other options. If you'd like to use this option and need better types, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
2121+2222+## Configuration
2323+2424+You can modify the contents of `sdk.gen.ts` by configuring the `@hey-api/sdk` plugin. Note that you must specify the default plugins to preserve the default output.
2525+2626+::: code-group
2727+2828+```js [flat]
2929+import { defaultPlugins } from '@hey-api/openapi-ts';
3030+3131+export default {
3232+ client: '@hey-api/client-fetch',
3333+ input: 'path/to/openapi.json',
3434+ output: 'src/client',
3535+ plugins: [
3636+ ...defaultPlugins,
3737+ {
3838+ asClass: false, // default // [!code ++]
3939+ name: '@hey-api/sdk',
4040+ },
4141+ ],
4242+};
4343+```
4444+4545+```js [class]
4646+import { defaultPlugins } from '@hey-api/openapi-ts';
4747+4848+export default {
4949+ client: '@hey-api/client-fetch',
5050+ input: 'path/to/openapi.json',
5151+ output: 'src/client',
5252+ plugins: [
5353+ ...defaultPlugins,
5454+ {
5555+ asClass: true, // [!code ++]
5656+ name: '@hey-api/sdk',
5757+ },
5858+ ],
5959+};
6060+```
6161+6262+```js [none]
6363+export default {
6464+ client: '@hey-api/client-fetch',
6565+ input: 'path/to/openapi.json',
6666+ output: 'src/client',
6767+ plugins: [
6868+ '@hey-api/typescript',
6969+ '@hey-api/sdk', // [!code --]
7070+ ],
7171+};
7272+```
7373+7474+:::
7575+7676+## Output
7777+7878+Below are different outputs depending on your chosen style. No SDKs approach will not generate the `sdk.gen.ts` file.
7979+8080+::: code-group
8181+8282+```ts [flat]
8383+import { client, type Options } from '@hey-api/client-fetch';
8484+8585+import type { AddPetData, AddPetError, AddPetResponse } from './types.gen';
8686+8787+export const addPet = (options: Options<AddPetData>) =>
8888+ (options?.client ?? client).post<AddPetResponse, AddPetError>({
8989+ ...options,
9090+ url: '/pet',
9191+ });
9292+```
9393+9494+```ts [class]
9595+import { client, type Options } from '@hey-api/client-fetch';
9696+9797+import type { AddPetData, AddPetError, AddPetResponse } from './types.gen';
9898+9999+export class PetService {
100100+ public static addPet(options: Options<AddPetData>) {
101101+ return (options?.client ?? client).post<AddPetResponse, AddPetError>({
102102+ ...options,
103103+ url: '/pet',
104104+ });
105105+ }
106106+}
107107+```
108108+109109+:::
110110+111111+## Usage
112112+113113+This is how you'd make the same request using each approach.
114114+115115+::: code-group
116116+117117+```ts [flat]
118118+import { addPet } from './client/sdk.gen';
119119+120120+addPet({
121121+ body: {
122122+ name: 'Kitty',
123123+ },
124124+});
125125+```
126126+127127+```ts [class]
128128+import { PetService } from './client/sdk.gen';
129129+130130+PetService.addPet({
131131+ body: {
132132+ name: 'Kitty',
133133+ },
134134+});
135135+```
136136+137137+```ts [none]
138138+import { client } from '@hey-api/client-fetch';
139139+140140+client.post({
141141+ body: {
142142+ name: 'Kitty',
143143+ },
144144+ url: '/pet',
145145+});
146146+```
147147+148148+:::
149149+150150+<!--@include: ../../examples.md-->
151151+<!--@include: ../../sponsors.md-->
+120
docs/openapi-ts/output/typescript.md
···11+---
22+title: TypeScript
33+description: Learn about files generated with @hey-api/openapi-ts.
44+---
55+66+# TypeScript
77+88+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).
99+1010+This file contains three different categories of interfaces created from your input:
1111+1212+- reusable components
1313+- operation request, response, and error data
1414+- enums
1515+1616+Depending on your input and configuration, some of these categories might be missing or differ in your output (and that's okay!).
1717+1818+::: code-group
1919+2020+```ts [types.gen.ts]
2121+export type Pet = {
2222+ id?: number;
2323+ name: string;
2424+};
2525+2626+export type AddPetData = {
2727+ body: Pet;
2828+};
2929+3030+export type AddPetResponse = Pet;
3131+```
3232+3333+:::
3434+3535+As you can see, everything is exported from `types.gen.ts`. You can import individual exports in your application and use them as necessary.
3636+3737+## Configuration
3838+3939+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.
4040+4141+```js
4242+import { defaultPlugins } from '@hey-api/openapi-ts';
4343+4444+export default {
4545+ client: '@hey-api/client-fetch',
4646+ input: 'path/to/openapi.json',
4747+ output: 'src/client',
4848+ plugins: [
4949+ ...defaultPlugins,
5050+ {
5151+ name: '@hey-api/typescript',
5252+ // ...custom options // [!code ++]
5353+ },
5454+ ],
5555+};
5656+```
5757+5858+## Enums
5959+6060+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.
6161+6262+::: code-group
6363+6464+```js [disabled]
6565+import { defaultPlugins } from '@hey-api/openapi-ts';
6666+6767+export default {
6868+ client: '@hey-api/client-fetch',
6969+ input: 'path/to/openapi.json',
7070+ output: 'src/client',
7171+ plugins: [
7272+ ...defaultPlugins,
7373+ {
7474+ enums: false, // default // [!code ++]
7575+ name: '@hey-api/typescript',
7676+ },
7777+ ],
7878+};
7979+```
8080+8181+```js [javascript]
8282+import { defaultPlugins } from '@hey-api/openapi-ts';
8383+8484+export default {
8585+ client: '@hey-api/client-fetch',
8686+ input: 'path/to/openapi.json',
8787+ output: 'src/client',
8888+ plugins: [
8989+ ...defaultPlugins,
9090+ {
9191+ enums: 'javascript', // [!code ++]
9292+ name: '@hey-api/typescript',
9393+ },
9494+ ],
9595+};
9696+```
9797+9898+```js [typescript]
9999+import { defaultPlugins } from '@hey-api/openapi-ts';
100100+101101+export default {
102102+ client: '@hey-api/client-fetch',
103103+ input: 'path/to/openapi.json',
104104+ output: 'src/client',
105105+ plugins: [
106106+ ...defaultPlugins,
107107+ {
108108+ enums: 'typescript', // [!code ++]
109109+ name: '@hey-api/typescript',
110110+ },
111111+ ],
112112+};
113113+```
114114+115115+:::
116116+117117+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).
118118+119119+<!--@include: ../../examples.md-->
120120+<!--@include: ../../sponsors.md-->
+2-2
docs/openapi-ts/plugins.md
···5566# Plugins
7788-Every generated file in your output is created by a plugin. You already learned about the default plugins in [Output](/openapi-ts/output). This page contains all native and selected community plugins.
88+Every generated file in your output is created by a plugin. You already learned about the default plugins in [Output](/openapi-ts/output). However, you might be working with third-party packages and wishing to automate more of your boilerplate. This page lists all native and selected community plugins enabling you to do that.
991010## Hey API
1111···5858- [add plugin](https://github.com/hey-api/openapi-ts/pulls)
59596060<!--@include: ../examples.md-->
6161-<!--@include: ../sponsorship.md-->
6161+<!--@include: ../sponsors.md-->
+1-1
docs/openapi-ts/plugins/ajv.md
···11111212[Ajv](https://ajv.js.org/) is the fastest JSON validator for Node.js and browser.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/arktype.md
···11111212[Arktype](https://arktype.io/) is a TypeScript's 1:1 validator, optimized from editor to runtime.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/express.md
···11111212[Express](https://expressjs.com/) is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/faker.md
···11111212[Faker](https://fakerjs.dev/) is a popular library that generates fake (but reasonable) data that can be used for things such as unit testing, performance testing, building demos, and working without a completed backend.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
···11111212[Hono](https://hono.dev/) is a small, simple, and ultrafast web framework built on Web Standards. It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Netlify, AWS Lambda, Lambda@Edge, and Node.js.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/joi.md
···11111212[Joi](https://joi.dev/) is the most powerful schema description language and data validator for JavaScript.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/koa.md
···11111212[Koa](https://koajs.com/) is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/msw.md
···11111212[MSW](https://mswjs.io/) is an API mocking library that allows you to write client-agnostic mocks and reuse them across any frameworks, tools, and environments.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/nest.md
···11111212[Nest](https://nestjs.com/) is a progressive Node.js framework for building efficient, reliable and scalable server-side applications.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/nock.md
···11111212[Nock](https://github.com/nock/nock) is an HTTP server mocking and expectations library for Node.js.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/pinia-colada.md
···11111212[Pinia Colada](https://pinia-colada.esm.dev/) is the data fetching layer for Pinia.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/superstruct.md
···11111212[Superstruct](https://docs.superstructjs.org/) makes it easy to define interfaces and then validate JavaScript data against them.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/supertest.md
···11111212[Supertest](https://github.com/ladjs/supertest) is a super-agent driven library for testing node.js HTTP servers using a fluent API.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/swr.md
···11111212[SWR](https://swr.vercel.app/) is a strategy to first return the data from cache (stale), then send the fetch request (revalidate), and finally come with the up-to-date data.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
···11111212[TypeBox](https://github.com/sinclairzx81/typebox) is a JSON Schema type builder with static type resolution for TypeScript.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/valibot.md
···11111212[Valibot](https://valibot.dev/) is the open source schema library for TypeScript with bundle size, type safety and developer experience in mind.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/yup.md
···11111212[Yup](https://github.com/jquense/yup) is a schema builder for runtime value parsing and validation.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/zod.md
···7474More information will be provided as we finalize the plugin.
75757676<!--@include: ../../examples.md-->
7777-<!--@include: ../../sponsorship.md-->
7777+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/plugins/zustand.md
···11111212[Zustand](https://zustand-demo.pmnd.rs/) is a small, fast, and scalable bearbones state management solution.
13131414-<!--@include: ../../sponsorship.md-->
1414+<!--@include: ../../sponsors.md-->
+1-1
docs/openapi-ts/state-management.md
···1919Don't see your state manager? Let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
20202121<!--@include: ../examples.md-->
2222-<!--@include: ../sponsorship.md-->
2222+<!--@include: ../sponsors.md-->
···2020Don't see your framework? Let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
21212222<!--@include: ../examples.md-->
2323-<!--@include: ../sponsorship.md-->
2323+<!--@include: ../sponsors.md-->