Skip to content

Commit 6b2c666

Browse files
committed
docs: add vite plugin
1 parent 549a42e commit 6b2c666

9 files changed

Lines changed: 194 additions & 7 deletions

File tree

docs/.vitepress/config/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export default defineConfig({
4444
link: '/openapi-ts/configuration/parser',
4545
text: 'Parser',
4646
},
47+
{
48+
link: '/openapi-ts/configuration/vite',
49+
text: 'Vite',
50+
},
4751
],
4852
link: '/openapi-ts/configuration',
4953
text: 'Configuration',

docs/openapi-ts/clients/nuxt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Start by adding `@hey-api/nuxt` to your dependencies.
4141
::: code-group
4242

4343
```sh [npm]
44-
npm install @hey-api/nuxt
44+
npm add @hey-api/nuxt
4545
```
4646

4747
```sh [pnpm]
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: Vite Plugin
3+
description: Integrate @hey-api/openapi-ts into your Vite build pipeline with the official Vite plugin.
4+
---
5+
6+
# Vite
7+
8+
### About
9+
10+
[Vite](https://vite.dev) is a blazing fast frontend build tool powering the next generation of web applications.
11+
12+
The Vite plugin integrates `@hey-api/openapi-ts` into the Vite build pipeline, running automatically whenever Vite resolves its configuration – no separate script or manual step required.
13+
14+
## Features
15+
16+
- runs automatically as part of your Vite build
17+
- reads your existing [configuration](/openapi-ts/get-started) (or accepts inline config)
18+
- works with any Vite-based project
19+
20+
## Installation
21+
22+
You can download `@hey-api/vite-plugin` from npm using your favorite package manager.
23+
24+
::: code-group
25+
26+
```sh [npm]
27+
npm add @hey-api/vite-plugin -D -E
28+
```
29+
30+
```sh [pnpm]
31+
pnpm add @hey-api/vite-plugin -D -E
32+
```
33+
34+
```sh [yarn]
35+
yarn add @hey-api/vite-plugin -D -E
36+
```
37+
38+
```sh [bun]
39+
bun add @hey-api/vite-plugin -D -E
40+
```
41+
42+
:::
43+
44+
## Usage
45+
46+
Add the plugin to your `vite.config.ts`:
47+
48+
::: code-group
49+
50+
```ts [vite.config.ts]
51+
import { heyApiPlugin } from '@hey-api/vite-plugin';
52+
import { defineConfig } from 'vite';
53+
54+
export default defineConfig({
55+
plugins: [heyApiPlugin()],
56+
});
57+
```
58+
59+
:::
60+
61+
The plugin will automatically pick up your [configuration](/openapi-ts/configuration) file. You can also pass options inline using the `config` option:
62+
63+
::: code-group
64+
65+
```ts [vite.config.ts]
66+
import { heyApiPlugin } from '@hey-api/vite-plugin';
67+
import { defineConfig } from 'vite';
68+
69+
export default defineConfig({
70+
plugins: [
71+
heyApiPlugin({
72+
config: {
73+
input: 'hey-api/backend', // sign up at app.heyapi.dev
74+
output: 'src/client',
75+
},
76+
}),
77+
],
78+
});
79+
```
80+
81+
:::
82+
83+
<!--@include: ../../partials/examples.md-->
84+
<!--@include: ../../partials/sponsors.md-->

docs/openapi-ts/get-started.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ You can download `@hey-api/openapi-ts` from npm using your favorite package mana
5151
::: code-group
5252

5353
```sh [npm]
54-
npm install @hey-api/openapi-ts -D -E
54+
npm add @hey-api/openapi-ts -D -E
5555
```
5656

5757
```sh [pnpm]
@@ -105,6 +105,54 @@ createClient({
105105

106106
:::
107107

108+
### Vite
109+
110+
If you're using [Vite](https://vite.dev), you can integrate `@hey-api/openapi-ts` directly into your build pipeline with `@hey-api/vite-plugin`. Install it alongside the main package:
111+
112+
::: code-group
113+
114+
```sh [npm]
115+
npm add @hey-api/vite-plugin -D -E
116+
```
117+
118+
```sh [pnpm]
119+
pnpm add @hey-api/vite-plugin -D -E
120+
```
121+
122+
```sh [yarn]
123+
yarn add @hey-api/vite-plugin -D -E
124+
```
125+
126+
```sh [bun]
127+
bun add @hey-api/vite-plugin -D -E
128+
```
129+
130+
:::
131+
132+
Then add the plugin to your Vite configuration:
133+
134+
::: code-group
135+
136+
```ts [vite.config.ts]
137+
import { heyApiPlugin } from '@hey-api/vite-plugin';
138+
import { defineConfig } from 'vite';
139+
140+
export default defineConfig({
141+
plugins: [
142+
heyApiPlugin({
143+
config: {
144+
input: 'hey-api/backend', // sign up at app.heyapi.dev
145+
output: 'src/client',
146+
},
147+
}),
148+
],
149+
});
150+
```
151+
152+
:::
153+
154+
See the [Vite](/openapi-ts/configuration/vite) page for full configuration options.
155+
108156
### Configuration
109157

110158
It's 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.

docs/openapi-ts/migrating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ If you need to access individual fields, you can do so using the [`.shape`](http
479479
480480
### Bundle `@hey-api/client-*` plugins
481481
482-
In previous releases, you had to install a separate client package to generate a fully working output, e.g., `npm install @hey-api/client-fetch`. This created a few challenges: getting started was slower, upgrading was sometimes painful, and bundling too. Beginning with v0.73.0, all Hey API clients are bundled by default and don't require installing any additional dependencies. You can remove any installed client packages and re-run `@hey-api/openapi-ts`.
482+
In previous releases, you had to install a separate client package to generate a fully working output, e.g., `npm add @hey-api/client-fetch`. This created a few challenges: getting started was slower, upgrading was sometimes painful, and bundling too. Beginning with v0.73.0, all Hey API clients are bundled by default and don't require installing any additional dependencies. You can remove any installed client packages and re-run `@hey-api/openapi-ts`.
483483
484484
```sh
485485
npm uninstall @hey-api/client-fetch

docs/openapi-ts/plugins/sdk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ export default {
540540
541541
### Display
542542
543-
Enabling examples does not produce visible output on its own. Examples are written into the source specification and can be consumed by documentation tools such as [Mintlify](https://kutt.to/6vrYy9) or [Scalar](https://kutt.to/skQUVd). To persist that specification, enable [Source](/openapi-ts/configuration/output#source) generation.
543+
Enabling examples does not produce visible output on its own. Examples are written into the source specification and can be consumed by documentation tools such as [Scalar](https://kutt.to/skQUVd). To persist that specification, enable [Source](/openapi-ts/configuration/output#source) generation.
544544
545545
## API
546546

packages/json-schema-ref-parser/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
Install using [npm](https://docs.npmjs.com/about-npm/):
88

99
```bash
10-
npm install @hey-api/json-schema-ref-parser
10+
npm add @hey-api/json-schema-ref-parser
11+
pnpm add @hey-api/json-schema-ref-parser
1112
yarn add @hey-api/json-schema-ref-parser
1213
bun add @hey-api/json-schema-ref-parser
1314
```

packages/openapi-ts/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ export default {
16361636

16371637
### Bundle `@hey-api/client-*` plugins
16381638

1639-
In previous releases, you had to install a separate client package to generate a fully working output, e.g. `npm install @hey-api/client-fetch`. This created a few challenges: getting started was slower, upgrading was sometimes painful, and bundling too. Beginning with v0.73.0, all Hey API clients are bundled by default and don't require installing any additional dependencies. You can remove any installed client packages and re-run `@hey-api/openapi-ts`.
1639+
In previous releases, you had to install a separate client package to generate a fully working output, e.g. `npm add @hey-api/client-fetch`. This created a few challenges: getting started was slower, upgrading was sometimes painful, and bundling too. Beginning with v0.73.0, all Hey API clients are bundled by default and don't require installing any additional dependencies. You can remove any installed client packages and re-run `@hey-api/openapi-ts`.
16401640

16411641
```sh
16421642
npm uninstall @hey-api/client-fetch

packages/openapi-ts/README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ You can download `@hey-api/openapi-ts` from npm using your favorite package mana
171171
#### npm
172172

173173
```sh
174-
npm install @hey-api/openapi-ts -D -E
174+
npm add @hey-api/openapi-ts -D -E
175175
```
176176

177177
#### pnpm
@@ -227,6 +227,56 @@ createClient({
227227
});
228228
```
229229

230+
### Vite
231+
232+
If you're using [Vite](https://vite.dev), you can integrate `@hey-api/openapi-ts` directly into your build pipeline with `@hey-api/vite-plugin`. Install it alongside the main package:
233+
234+
#### npm
235+
236+
```sh
237+
npm add @hey-api/vite-plugin -D -E
238+
```
239+
240+
#### pnpm
241+
242+
```sh
243+
pnpm add @hey-api/vite-plugin -D -E
244+
```
245+
246+
#### yarn
247+
248+
```sh
249+
yarn add @hey-api/vite-plugin -D -E
250+
```
251+
252+
#### bun
253+
254+
```sh
255+
bun add @hey-api/vite-plugin -D -E
256+
```
257+
258+
Then add the plugin to your Vite configuration:
259+
260+
#### `vite.config.ts`
261+
262+
```ts
263+
import { heyApiPlugin } from '@hey-api/vite-plugin';
264+
import { defineConfig } from 'vite';
265+
266+
export default defineConfig({
267+
plugins: [
268+
heyApiPlugin({
269+
config: {
270+
input: 'hey-api/backend', // sign up at app.heyapi.dev
271+
output: 'src/client',
272+
},
273+
}),
274+
],
275+
});
276+
```
277+
278+
See the [Vite](https://heyapi.dev/openapi-ts/configuration/vite) page for full configuration options.
279+
230280
## Configuration
231281

232282
`@hey-api/openapi-ts` supports loading configuration from any file inside your project root folder supported by [jiti loader](https://github.com/unjs/c12?tab=readme-ov-file#-features). Below are the most common file formats.

0 commit comments

Comments
 (0)