Skip to content

Commit a1e1395

Browse files
authored
Merge pull request #2172 from hey-api/feat/client-bundle
feat: remove support for client packages
2 parents 16fb3c7 + cfc0abb commit a1e1395

File tree

2,065 files changed

+229499
-12556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,065 files changed

+229499
-12556
lines changed

.changeset/eleven-lions-own.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@hey-api/openapi-ts': minor
3+
---
4+
5+
feat: bundle `@hey-api/client-*` plugins
6+
7+
### Bundle `@hey-api/client-*` plugins
8+
9+
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`.
10+
11+
```sh
12+
npm uninstall @hey-api/client-fetch
13+
```

.changeset/mighty-bulldogs-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: respect logs setting if initialization fails

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ test/e2e/generated
2424

2525
# error files
2626
openapi-ts-error-*
27+
28+
# But DO NOT ignore generated snapshots!
29+
!test/__snapshots__/test/generated
30+
!test/__snapshots__/test/generated/**

README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,38 +120,35 @@ The fastest way to use `@hey-api/openapi-ts` is via npx
120120
```sh
121121
npx @hey-api/openapi-ts \
122122
-i https://get.heyapi.dev/hey-api/backend \
123-
-o src/client \
124-
-c @hey-api/client-fetch
123+
-o src/client
125124
```
126125

127126
Congratulations on creating your first client! 🎉 You can learn more about the generated files on the [Output](https://heyapi.dev/openapi-ts/output) page.
128127

129-
Before you can make API requests with the client you've just created, you need to install `@hey-api/client-fetch` and configure it.
130-
131128
## Installation
132129

133130
#### npm
134131

135132
```sh
136-
npm install @hey-api/client-fetch && npm install @hey-api/openapi-ts -D
133+
npm install @hey-api/openapi-ts -D
137134
```
138135

139136
#### pnpm
140137

141138
```sh
142-
pnpm add @hey-api/client-fetch && pnpm add @hey-api/openapi-ts -D
139+
pnpm add @hey-api/openapi-ts -D
143140
```
144141

145142
#### yarn
146143

147144
```sh
148-
yarn add @hey-api/client-fetch && yarn add @hey-api/openapi-ts -D
145+
yarn add @hey-api/openapi-ts -D
149146
```
150147

151148
#### bun
152149

153150
```sh
154-
bun add @hey-api/client-fetch && bun add @hey-api/openapi-ts -D
151+
bun add @hey-api/openapi-ts -D
155152
```
156153

157154
We recommend pinning an exact version so you can safely upgrade when you're ready. This package is in [initial development](https://semver.org/spec/v0.1.0.html#spec-item-5) and its API might change before v1.
@@ -178,7 +175,6 @@ import { createClient } from '@hey-api/openapi-ts';
178175
createClient({
179176
input: 'https://get.heyapi.dev/hey-api/backend',
180177
output: 'src/client',
181-
plugins: ['@hey-api/client-fetch'],
182178
});
183179
```
184180

@@ -194,7 +190,6 @@ import { defineConfig } from '@hey-api/openapi-ts';
194190
export default defineConfig({
195191
input: 'https://get.heyapi.dev/hey-api/backend',
196192
output: 'src/client',
197-
plugins: ['@hey-api/client-fetch'],
198193
});
199194
```
200195

@@ -205,7 +200,6 @@ export default defineConfig({
205200
module.exports = {
206201
input: 'https://get.heyapi.dev/hey-api/backend',
207202
output: 'src/client',
208-
plugins: ['@hey-api/client-fetch'],
209203
};
210204
```
211205

@@ -216,7 +210,6 @@ module.exports = {
216210
export default {
217211
input: 'https://get.heyapi.dev/hey-api/backend',
218212
output: 'src/client',
219-
plugins: ['@hey-api/client-fetch'],
220213
};
221214
```
222215

docs/.vitepress/config/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default defineConfig({
4141
link: '/openapi-ts/output/sdk',
4242
text: 'SDK',
4343
},
44+
{
45+
link: '/openapi-ts/output/client',
46+
text: 'Client',
47+
},
4448
{
4549
link: '/openapi-ts/output/json-schema',
4650
text: 'JSON Schema',

docs/openapi-ts/clients/axios.md

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,6 @@ Launch demo
3535

3636
## Installation
3737

38-
Start by adding `@hey-api/client-axios` to your dependencies.
39-
40-
::: code-group
41-
42-
```sh [npm]
43-
npm install @hey-api/client-axios
44-
```
45-
46-
```sh [pnpm]
47-
pnpm add @hey-api/client-axios
48-
```
49-
50-
```sh [yarn]
51-
yarn add @hey-api/client-axios
52-
```
53-
54-
```sh [bun]
55-
bun add @hey-api/client-axios
56-
```
57-
58-
:::
59-
6038
In your [configuration](/openapi-ts/get-started), add `@hey-api/client-axios` to your plugins and you'll be ready to generate client artifacts. :tada:
6139

6240
::: code-group
@@ -137,7 +115,7 @@ With this approach, `client.gen.ts` will call `createClientConfig()` before init
137115
You can also create your own client instance. You can use it to manually send requests or point it to a different domain.
138116

139117
```js
140-
import { createClient } from '@hey-api/client-axios';
118+
import { createClient } from './client/client';
141119

142120
const myClient = createClient({
143121
baseURL: 'https://example.com',
@@ -228,22 +206,5 @@ const url = client.buildUrl<FooData>({
228206
console.log(url); // prints '/foo/1?bar=baz'
229207
```
230208

231-
## Bundling
232-
233-
Sometimes, you may not want to declare client packages as a dependency. This scenario is common if you're using Hey API to generate output that is repackaged and published for other consumers under your own brand. For such cases, our clients support bundling through the `client.bundle` configuration option.
234-
235-
```js
236-
export default {
237-
input: 'https://get.heyapi.dev/hey-api/backend',
238-
output: 'src/client',
239-
plugins: [
240-
{
241-
bundle: true, // [!code ++]
242-
name: '@hey-api/client-axios',
243-
},
244-
],
245-
};
246-
```
247-
248209
<!--@include: ../../examples.md-->
249210
<!--@include: ../../sponsors.md-->

docs/openapi-ts/clients/fetch.md

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,6 @@ Launch demo
3535

3636
## Installation
3737

38-
Start by adding `@hey-api/client-fetch` to your dependencies.
39-
40-
::: code-group
41-
42-
```sh [npm]
43-
npm install @hey-api/client-fetch
44-
```
45-
46-
```sh [pnpm]
47-
pnpm add @hey-api/client-fetch
48-
```
49-
50-
```sh [yarn]
51-
yarn add @hey-api/client-fetch
52-
```
53-
54-
```sh [bun]
55-
bun add @hey-api/client-fetch
56-
```
57-
58-
:::
59-
6038
In your [configuration](/openapi-ts/get-started), add `@hey-api/client-fetch` to your plugins and you'll be ready to generate client artifacts. :tada:
6139

6240
::: code-group
@@ -78,6 +56,12 @@ npx @hey-api/openapi-ts \
7856

7957
:::
8058

59+
::: tip
60+
61+
This step is optional because Fetch is the default client.
62+
63+
:::
64+
8165
## Configuration
8266

8367
The Fetch client is built as a thin wrapper on top of Fetch API, extending its functionality to work with Hey API. If you're already familiar with Fetch, configuring your client will feel like working directly with Fetch API.
@@ -137,7 +121,7 @@ With this approach, `client.gen.ts` will call `createClientConfig()` before init
137121
You can also create your own client instance. You can use it to manually send requests or point it to a different domain.
138122

139123
```js
140-
import { createClient } from '@hey-api/client-fetch';
124+
import { createClient } from './client/client';
141125

142126
const myClient = createClient({
143127
baseUrl: 'https://example.com',
@@ -299,22 +283,5 @@ const url = client.buildUrl<FooData>({
299283
console.log(url); // prints '/foo/1?bar=baz'
300284
```
301285

302-
## Bundling
303-
304-
Sometimes, you may not want to declare client packages as a dependency. This scenario is common if you're using Hey API to generate output that is repackaged and published for other consumers under your own brand. For such cases, our clients support bundling through the `client.bundle` configuration option.
305-
306-
```js
307-
export default {
308-
input: 'https://get.heyapi.dev/hey-api/backend',
309-
output: 'src/client',
310-
plugins: [
311-
{
312-
bundle: true, // [!code ++]
313-
name: '@hey-api/client-fetch',
314-
},
315-
],
316-
};
317-
```
318-
319286
<!--@include: ../../examples.md-->
320287
<!--@include: ../../sponsors.md-->

docs/openapi-ts/clients/next-js.md

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,6 @@ Launch demo
2929

3030
## Installation
3131

32-
Start by adding `@hey-api/client-next` to your dependencies.
33-
34-
::: code-group
35-
36-
```sh [npm]
37-
npm install @hey-api/client-next
38-
```
39-
40-
```sh [pnpm]
41-
pnpm add @hey-api/client-next
42-
```
43-
44-
```sh [yarn]
45-
yarn add @hey-api/client-next
46-
```
47-
48-
```sh [bun]
49-
bun add @hey-api/client-next
50-
```
51-
52-
:::
53-
5432
In your [configuration](/openapi-ts/get-started), add `@hey-api/client-next` to your plugins and you'll be ready to generate client artifacts. :tada:
5533

5634
::: code-group
@@ -131,7 +109,7 @@ The disadvantage of this approach is that your code may call the `client` instan
131109
You can also create your own client instance. You can use it to manually send requests or point it to a different domain.
132110

133111
```js
134-
import { createClient } from '@hey-api/client-next';
112+
import { createClient } from './client/client';
135113

136114
const myClient = createClient({
137115
baseUrl: 'https://example.com',
@@ -292,22 +270,5 @@ const url = client.buildUrl<FooData>({
292270
console.log(url); // prints '/foo/1?bar=baz'
293271
```
294272

295-
## Bundling
296-
297-
Sometimes, you may not want to declare client packages as a dependency. This scenario is common if you're using Hey API to generate output that is repackaged and published for other consumers under your own brand. For such cases, our clients support bundling through the `client.bundle` configuration option.
298-
299-
```js
300-
export default {
301-
input: 'https://get.heyapi.dev/hey-api/backend',
302-
output: 'src/client',
303-
plugins: [
304-
{
305-
bundle: true, // [!code ++]
306-
name: '@hey-api/client-next',
307-
},
308-
],
309-
};
310-
```
311-
312273
<!--@include: ../../examples.md-->
313274
<!--@include: ../../sponsors.md-->

docs/openapi-ts/clients/nuxt.md

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ Nuxt client is currently in beta. The interface might change before it becomes s
1313

1414
[Nuxt](https://nuxt.com) is an open source framework that makes web development intuitive and powerful.
1515

16-
::: tip
17-
You might be interested in the [Nuxt module](https://www.npmjs.com/package/@hey-api/nuxt) instead. It offers all the features mentioned in this guide in a more familiar way.
18-
:::
19-
2016
<!-- <button class="buttonLink" @click="(event) => embedProject('hey-api-client-fetch-example')(event)">
2117
Launch demo
2218
</button> -->
@@ -33,24 +29,24 @@ Launch demo
3329

3430
## Installation
3531

36-
Start by adding `@hey-api/client-nuxt` to your dependencies.
32+
Start by adding `@hey-api/nuxt` to your dependencies.
3733

3834
::: code-group
3935

4036
```sh [npm]
41-
npm install @hey-api/client-nuxt
37+
npm install @hey-api/nuxt
4238
```
4339

4440
```sh [pnpm]
45-
pnpm add @hey-api/client-nuxt
41+
pnpm add @hey-api/nuxt
4642
```
4743

4844
```sh [yarn]
49-
yarn add @hey-api/client-nuxt
45+
yarn add @hey-api/nuxt
5046
```
5147

5248
```sh [bun]
53-
bun add @hey-api/client-nuxt
49+
bun add @hey-api/nuxt
5450
```
5551

5652
:::
@@ -76,6 +72,12 @@ npx @hey-api/openapi-ts \
7672

7773
:::
7874

75+
::: tip
76+
77+
If you add `@hey-api/nuxt` to your Nuxt modules, this step is not needed.
78+
79+
:::
80+
7981
## Configuration
8082

8183
The Nuxt client is built as a thin wrapper on top of Nuxt, extending its functionality to work with Hey API. If you're already familiar with Nuxt, configuring your client will feel like working directly with Nuxt.
@@ -135,7 +137,7 @@ With this approach, `client.gen.ts` will call `createClientConfig()` before init
135137
You can also create your own client instance. You can use it to manually send requests or point it to a different domain.
136138

137139
```js
138-
import { createClient } from '@hey-api/client-nuxt';
140+
import { createClient } from './client/client';
139141

140142
const myClient = createClient({
141143
baseURL: 'https://example.com',
@@ -230,22 +232,5 @@ const url = client.buildUrl<FooData>({
230232
console.log(url); // prints '/foo/1?bar=baz'
231233
```
232234

233-
## Bundling
234-
235-
Sometimes, you may not want to declare client packages as a dependency. This scenario is common if you're using Hey API to generate output that is repackaged and published for other consumers under your own brand. For such cases, our clients support bundling through the `client.bundle` configuration option.
236-
237-
```js
238-
export default {
239-
input: 'https://get.heyapi.dev/hey-api/backend',
240-
output: 'src/client',
241-
plugins: [
242-
{
243-
bundle: true, // [!code ++]
244-
name: '@hey-api/client-nuxt',
245-
},
246-
],
247-
};
248-
```
249-
250235
<!--@include: ../../examples.md-->
251236
<!--@include: ../../sponsors.md-->

0 commit comments

Comments
 (0)