From 6b2c666d70906d7da3338dcaaecaaff3bbed9e3b Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 4 Apr 2026 09:50:51 +0200 Subject: [PATCH] docs: add vite plugin --- docs/.vitepress/config/en.ts | 4 ++ docs/openapi-ts/clients/nuxt.md | 2 +- docs/openapi-ts/configuration/vite.md | 84 +++++++++++++++++++++++ docs/openapi-ts/get-started.md | 50 +++++++++++++- docs/openapi-ts/migrating.md | 2 +- docs/openapi-ts/plugins/sdk.md | 2 +- packages/json-schema-ref-parser/README.md | 3 +- packages/openapi-ts/CHANGELOG.md | 2 +- packages/openapi-ts/README.md | 52 +++++++++++++- 9 files changed, 194 insertions(+), 7 deletions(-) create mode 100644 docs/openapi-ts/configuration/vite.md diff --git a/docs/.vitepress/config/en.ts b/docs/.vitepress/config/en.ts index f4cc82868e..b60697788a 100644 --- a/docs/.vitepress/config/en.ts +++ b/docs/.vitepress/config/en.ts @@ -44,6 +44,10 @@ export default defineConfig({ link: '/openapi-ts/configuration/parser', text: 'Parser', }, + { + link: '/openapi-ts/configuration/vite', + text: 'Vite', + }, ], link: '/openapi-ts/configuration', text: 'Configuration', diff --git a/docs/openapi-ts/clients/nuxt.md b/docs/openapi-ts/clients/nuxt.md index ef8657b6a7..ed044b2f41 100644 --- a/docs/openapi-ts/clients/nuxt.md +++ b/docs/openapi-ts/clients/nuxt.md @@ -41,7 +41,7 @@ Start by adding `@hey-api/nuxt` to your dependencies. ::: code-group ```sh [npm] -npm install @hey-api/nuxt +npm add @hey-api/nuxt ``` ```sh [pnpm] diff --git a/docs/openapi-ts/configuration/vite.md b/docs/openapi-ts/configuration/vite.md new file mode 100644 index 0000000000..c6f4e5889e --- /dev/null +++ b/docs/openapi-ts/configuration/vite.md @@ -0,0 +1,84 @@ +--- +title: Vite Plugin +description: Integrate @hey-api/openapi-ts into your Vite build pipeline with the official Vite plugin. +--- + +# Vite + +### About + +[Vite](https://vite.dev) is a blazing fast frontend build tool powering the next generation of web applications. + +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. + +## Features + +- runs automatically as part of your Vite build +- reads your existing [configuration](/openapi-ts/get-started) (or accepts inline config) +- works with any Vite-based project + +## Installation + +You can download `@hey-api/vite-plugin` from npm using your favorite package manager. + +::: code-group + +```sh [npm] +npm add @hey-api/vite-plugin -D -E +``` + +```sh [pnpm] +pnpm add @hey-api/vite-plugin -D -E +``` + +```sh [yarn] +yarn add @hey-api/vite-plugin -D -E +``` + +```sh [bun] +bun add @hey-api/vite-plugin -D -E +``` + +::: + +## Usage + +Add the plugin to your `vite.config.ts`: + +::: code-group + +```ts [vite.config.ts] +import { heyApiPlugin } from '@hey-api/vite-plugin'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [heyApiPlugin()], +}); +``` + +::: + +The plugin will automatically pick up your [configuration](/openapi-ts/configuration) file. You can also pass options inline using the `config` option: + +::: code-group + +```ts [vite.config.ts] +import { heyApiPlugin } from '@hey-api/vite-plugin'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [ + heyApiPlugin({ + config: { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: 'src/client', + }, + }), + ], +}); +``` + +::: + + + diff --git a/docs/openapi-ts/get-started.md b/docs/openapi-ts/get-started.md index 9206020b8d..ac799b6543 100644 --- a/docs/openapi-ts/get-started.md +++ b/docs/openapi-ts/get-started.md @@ -51,7 +51,7 @@ You can download `@hey-api/openapi-ts` from npm using your favorite package mana ::: code-group ```sh [npm] -npm install @hey-api/openapi-ts -D -E +npm add @hey-api/openapi-ts -D -E ``` ```sh [pnpm] @@ -105,6 +105,54 @@ createClient({ ::: +### Vite + +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: + +::: code-group + +```sh [npm] +npm add @hey-api/vite-plugin -D -E +``` + +```sh [pnpm] +pnpm add @hey-api/vite-plugin -D -E +``` + +```sh [yarn] +yarn add @hey-api/vite-plugin -D -E +``` + +```sh [bun] +bun add @hey-api/vite-plugin -D -E +``` + +::: + +Then add the plugin to your Vite configuration: + +::: code-group + +```ts [vite.config.ts] +import { heyApiPlugin } from '@hey-api/vite-plugin'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [ + heyApiPlugin({ + config: { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: 'src/client', + }, + }), + ], +}); +``` + +::: + +See the [Vite](/openapi-ts/configuration/vite) page for full configuration options. + ### Configuration 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. diff --git a/docs/openapi-ts/migrating.md b/docs/openapi-ts/migrating.md index e4a3157ea0..9b61ead404 100644 --- a/docs/openapi-ts/migrating.md +++ b/docs/openapi-ts/migrating.md @@ -479,7 +479,7 @@ If you need to access individual fields, you can do so using the [`.shape`](http ### Bundle `@hey-api/client-*` plugins -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`. +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`. ```sh npm uninstall @hey-api/client-fetch diff --git a/docs/openapi-ts/plugins/sdk.md b/docs/openapi-ts/plugins/sdk.md index b53b2ef8cc..350c5a9a3c 100644 --- a/docs/openapi-ts/plugins/sdk.md +++ b/docs/openapi-ts/plugins/sdk.md @@ -540,7 +540,7 @@ export default { ### Display -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. +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. ## API diff --git a/packages/json-schema-ref-parser/README.md b/packages/json-schema-ref-parser/README.md index 76be414a7d..c611eb32df 100644 --- a/packages/json-schema-ref-parser/README.md +++ b/packages/json-schema-ref-parser/README.md @@ -7,7 +7,8 @@ Install using [npm](https://docs.npmjs.com/about-npm/): ```bash -npm install @hey-api/json-schema-ref-parser +npm add @hey-api/json-schema-ref-parser +pnpm add @hey-api/json-schema-ref-parser yarn add @hey-api/json-schema-ref-parser bun add @hey-api/json-schema-ref-parser ``` diff --git a/packages/openapi-ts/CHANGELOG.md b/packages/openapi-ts/CHANGELOG.md index a5c05482dd..07ad9419fc 100644 --- a/packages/openapi-ts/CHANGELOG.md +++ b/packages/openapi-ts/CHANGELOG.md @@ -1636,7 +1636,7 @@ export default { ### Bundle `@hey-api/client-*` plugins - 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`. + 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`. ```sh npm uninstall @hey-api/client-fetch diff --git a/packages/openapi-ts/README.md b/packages/openapi-ts/README.md index d4412a7a83..706e1b8424 100644 --- a/packages/openapi-ts/README.md +++ b/packages/openapi-ts/README.md @@ -171,7 +171,7 @@ You can download `@hey-api/openapi-ts` from npm using your favorite package mana #### npm ```sh -npm install @hey-api/openapi-ts -D -E +npm add @hey-api/openapi-ts -D -E ``` #### pnpm @@ -227,6 +227,56 @@ createClient({ }); ``` +### Vite + +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: + +#### npm + +```sh +npm add @hey-api/vite-plugin -D -E +``` + +#### pnpm + +```sh +pnpm add @hey-api/vite-plugin -D -E +``` + +#### yarn + +```sh +yarn add @hey-api/vite-plugin -D -E +``` + +#### bun + +```sh +bun add @hey-api/vite-plugin -D -E +``` + +Then add the plugin to your Vite configuration: + +#### `vite.config.ts` + +```ts +import { heyApiPlugin } from '@hey-api/vite-plugin'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [ + heyApiPlugin({ + config: { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: 'src/client', + }, + }), + ], +}); +``` + +See the [Vite](https://heyapi.dev/openapi-ts/configuration/vite) page for full configuration options. + ## Configuration `@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.