Skip to content

Commit 2cbffeb

Browse files
committed
feat: support required client in SDK using sdk.client = false
1 parent 93039cc commit 2cbffeb

File tree

220 files changed

+26241
-7419
lines changed

Some content is hidden

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

220 files changed

+26241
-7419
lines changed

.changeset/dry-eggs-begin.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
'@hey-api/client-axios': patch
33
'@hey-api/client-fetch': patch
4-
'@hey-api/client-next': patch
54
'@hey-api/client-nuxt': patch
65
'@hey-api/openapi-ts': patch
76
---

.changeset/orange-bags-hope.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@hey-api/client-axios': patch
3+
'@hey-api/client-fetch': patch
4+
'@hey-api/client-next': patch
5+
'@hey-api/client-nuxt': patch
6+
---
7+
8+
fix: remove client from Options interface

.changeset/thin-impalas-tell.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+
feat: support required client in SDK using sdk.client = false

.changeset/tiny-kings-reflect.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@hey-api/client-axios': patch
3+
'@hey-api/client-fetch': patch
4+
'@hey-api/client-next': patch
5+
'@hey-api/client-nuxt': patch
6+
---
7+
8+
fix: export TDataShape interface

examples/openapi-ts-axios/src/client/sdk.gen.ts

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
import type { Options } from '@hey-api/client-axios';
3+
import type {
4+
Client,
5+
Options as ClientOptions,
6+
TDataShape,
7+
} from '@hey-api/client-axios';
48

59
import { client as _heyApiClient } from './client.gen';
610
import type {
@@ -38,32 +42,42 @@ import type {
3842
UploadFileResponse,
3943
} from './types.gen';
4044

45+
type Options<
46+
TData extends TDataShape = TDataShape,
47+
ThrowOnError extends boolean = boolean,
48+
> = ClientOptions<TData, ThrowOnError> & {
49+
/**
50+
* You can provide a client instance returned by `createClient()` instead of
51+
* individual options. This might be also useful if you want to implement a
52+
* custom client.
53+
*/
54+
client?: Client;
55+
};
56+
4157
/**
4258
* Add a new pet to the store
4359
* Add a new pet to the store
4460
*/
4561
export const addPet = <ThrowOnError extends boolean = false>(
4662
options: Options<AddPetData, ThrowOnError>,
4763
) =>
48-
(options?.client ?? _heyApiClient).post<
49-
AddPetResponse,
50-
unknown,
51-
ThrowOnError
52-
>({
53-
responseType: 'blob',
54-
security: [
55-
{
56-
scheme: 'bearer',
57-
type: 'http',
64+
(options.client ?? _heyApiClient).post<AddPetResponse, unknown, ThrowOnError>(
65+
{
66+
responseType: 'blob',
67+
security: [
68+
{
69+
scheme: 'bearer',
70+
type: 'http',
71+
},
72+
],
73+
url: '/pet',
74+
...options,
75+
headers: {
76+
'Content-Type': 'application/json',
77+
...options?.headers,
5878
},
59-
],
60-
url: '/pet',
61-
...options,
62-
headers: {
63-
'Content-Type': 'application/json',
64-
...options?.headers,
6579
},
66-
});
80+
);
6781

6882
/**
6983
* Update an existing pet
@@ -72,7 +86,7 @@ export const addPet = <ThrowOnError extends boolean = false>(
7286
export const updatePet = <ThrowOnError extends boolean = false>(
7387
options: Options<UpdatePetData, ThrowOnError>,
7488
) =>
75-
(options?.client ?? _heyApiClient).put<
89+
(options.client ?? _heyApiClient).put<
7690
UpdatePetResponse,
7791
unknown,
7892
ThrowOnError
@@ -144,7 +158,7 @@ export const findPetsByTags = <ThrowOnError extends boolean = false>(
144158
export const deletePet = <ThrowOnError extends boolean = false>(
145159
options: Options<DeletePetData, ThrowOnError>,
146160
) =>
147-
(options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
161+
(options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
148162
security: [
149163
{
150164
scheme: 'bearer',
@@ -162,7 +176,7 @@ export const deletePet = <ThrowOnError extends boolean = false>(
162176
export const getPetById = <ThrowOnError extends boolean = false>(
163177
options: Options<GetPetByIdData, ThrowOnError>,
164178
) =>
165-
(options?.client ?? _heyApiClient).get<
179+
(options.client ?? _heyApiClient).get<
166180
GetPetByIdResponse,
167181
unknown,
168182
ThrowOnError
@@ -188,7 +202,7 @@ export const getPetById = <ThrowOnError extends boolean = false>(
188202
export const updatePetWithForm = <ThrowOnError extends boolean = false>(
189203
options: Options<UpdatePetWithFormData, ThrowOnError>,
190204
) =>
191-
(options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
205+
(options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
192206
security: [
193207
{
194208
scheme: 'bearer',
@@ -205,7 +219,7 @@ export const updatePetWithForm = <ThrowOnError extends boolean = false>(
205219
export const uploadFile = <ThrowOnError extends boolean = false>(
206220
options: Options<UploadFileData, ThrowOnError>,
207221
) =>
208-
(options?.client ?? _heyApiClient).post<
222+
(options.client ?? _heyApiClient).post<
209223
UploadFileResponse,
210224
unknown,
211225
ThrowOnError
@@ -273,7 +287,7 @@ export const placeOrder = <ThrowOnError extends boolean = false>(
273287
export const deleteOrder = <ThrowOnError extends boolean = false>(
274288
options: Options<DeleteOrderData, ThrowOnError>,
275289
) =>
276-
(options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
290+
(options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
277291
url: '/store/order/{orderId}',
278292
...options,
279293
});
@@ -285,7 +299,7 @@ export const deleteOrder = <ThrowOnError extends boolean = false>(
285299
export const getOrderById = <ThrowOnError extends boolean = false>(
286300
options: Options<GetOrderByIdData, ThrowOnError>,
287301
) =>
288-
(options?.client ?? _heyApiClient).get<
302+
(options.client ?? _heyApiClient).get<
289303
GetOrderByIdResponse,
290304
unknown,
291305
ThrowOnError
@@ -370,7 +384,7 @@ export const logoutUser = <ThrowOnError extends boolean = false>(
370384
export const deleteUser = <ThrowOnError extends boolean = false>(
371385
options: Options<DeleteUserData, ThrowOnError>,
372386
) =>
373-
(options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
387+
(options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
374388
url: '/user/{username}',
375389
...options,
376390
});
@@ -381,7 +395,7 @@ export const deleteUser = <ThrowOnError extends boolean = false>(
381395
export const getUserByName = <ThrowOnError extends boolean = false>(
382396
options: Options<GetUserByNameData, ThrowOnError>,
383397
) =>
384-
(options?.client ?? _heyApiClient).get<
398+
(options.client ?? _heyApiClient).get<
385399
GetUserByNameResponse,
386400
unknown,
387401
ThrowOnError
@@ -398,7 +412,7 @@ export const getUserByName = <ThrowOnError extends boolean = false>(
398412
export const updateUser = <ThrowOnError extends boolean = false>(
399413
options: Options<UpdateUserData, ThrowOnError>,
400414
) =>
401-
(options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({
415+
(options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({
402416
url: '/user/{username}',
403417
...options,
404418
headers: {

examples/openapi-ts-fastify/src/client/sdk.gen.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
import type { Options } from '@hey-api/client-fetch';
3+
import type {
4+
Client,
5+
Options as ClientOptions,
6+
TDataShape,
7+
} from '@hey-api/client-fetch';
48

59
import { client as _heyApiClient } from './client.gen';
610
import type {
@@ -14,6 +18,18 @@ import type {
1418
ShowPetByIdResponse,
1519
} from './types.gen';
1620

21+
type Options<
22+
TData extends TDataShape = TDataShape,
23+
ThrowOnError extends boolean = boolean,
24+
> = ClientOptions<TData, ThrowOnError> & {
25+
/**
26+
* You can provide a client instance returned by `createClient()` instead of
27+
* individual options. This might be also useful if you want to implement a
28+
* custom client.
29+
*/
30+
client?: Client;
31+
};
32+
1733
/**
1834
* List all pets
1935
*/
@@ -50,7 +66,7 @@ export const createPets = <ThrowOnError extends boolean = false>(
5066
export const showPetById = <ThrowOnError extends boolean = false>(
5167
options: Options<ShowPetByIdData, ThrowOnError>,
5268
) =>
53-
(options?.client ?? _heyApiClient).get<
69+
(options.client ?? _heyApiClient).get<
5470
ShowPetByIdResponse,
5571
ShowPetByIdError,
5672
ThrowOnError

examples/openapi-ts-fetch/src/client/sdk.gen.ts

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
import type { Options } from '@hey-api/client-fetch';
3+
import type {
4+
Client,
5+
Options as ClientOptions,
6+
TDataShape,
7+
} from '@hey-api/client-fetch';
48

59
import { client as _heyApiClient } from './client.gen';
610
import type {
@@ -38,31 +42,41 @@ import type {
3842
UploadFileResponse,
3943
} from './types.gen';
4044

45+
type Options<
46+
TData extends TDataShape = TDataShape,
47+
ThrowOnError extends boolean = boolean,
48+
> = ClientOptions<TData, ThrowOnError> & {
49+
/**
50+
* You can provide a client instance returned by `createClient()` instead of
51+
* individual options. This might be also useful if you want to implement a
52+
* custom client.
53+
*/
54+
client?: Client;
55+
};
56+
4157
/**
4258
* Add a new pet to the store
4359
* Add a new pet to the store
4460
*/
4561
export const addPet = <ThrowOnError extends boolean = false>(
4662
options: Options<AddPetData, ThrowOnError>,
4763
) =>
48-
(options?.client ?? _heyApiClient).post<
49-
AddPetResponse,
50-
unknown,
51-
ThrowOnError
52-
>({
53-
security: [
54-
{
55-
scheme: 'bearer',
56-
type: 'http',
64+
(options.client ?? _heyApiClient).post<AddPetResponse, unknown, ThrowOnError>(
65+
{
66+
security: [
67+
{
68+
scheme: 'bearer',
69+
type: 'http',
70+
},
71+
],
72+
url: '/pet',
73+
...options,
74+
headers: {
75+
'Content-Type': 'application/json',
76+
...options?.headers,
5777
},
58-
],
59-
url: '/pet',
60-
...options,
61-
headers: {
62-
'Content-Type': 'application/json',
63-
...options?.headers,
6478
},
65-
});
79+
);
6680

6781
/**
6882
* Update an existing pet
@@ -71,7 +85,7 @@ export const addPet = <ThrowOnError extends boolean = false>(
7185
export const updatePet = <ThrowOnError extends boolean = false>(
7286
options: Options<UpdatePetData, ThrowOnError>,
7387
) =>
74-
(options?.client ?? _heyApiClient).put<
88+
(options.client ?? _heyApiClient).put<
7589
UpdatePetResponse,
7690
unknown,
7791
ThrowOnError
@@ -140,7 +154,7 @@ export const findPetsByTags = <ThrowOnError extends boolean = false>(
140154
export const deletePet = <ThrowOnError extends boolean = false>(
141155
options: Options<DeletePetData, ThrowOnError>,
142156
) =>
143-
(options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
157+
(options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
144158
security: [
145159
{
146160
scheme: 'bearer',
@@ -158,7 +172,7 @@ export const deletePet = <ThrowOnError extends boolean = false>(
158172
export const getPetById = <ThrowOnError extends boolean = false>(
159173
options: Options<GetPetByIdData, ThrowOnError>,
160174
) =>
161-
(options?.client ?? _heyApiClient).get<
175+
(options.client ?? _heyApiClient).get<
162176
GetPetByIdResponse,
163177
unknown,
164178
ThrowOnError
@@ -183,7 +197,7 @@ export const getPetById = <ThrowOnError extends boolean = false>(
183197
export const updatePetWithForm = <ThrowOnError extends boolean = false>(
184198
options: Options<UpdatePetWithFormData, ThrowOnError>,
185199
) =>
186-
(options?.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
200+
(options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
187201
security: [
188202
{
189203
scheme: 'bearer',
@@ -200,7 +214,7 @@ export const updatePetWithForm = <ThrowOnError extends boolean = false>(
200214
export const uploadFile = <ThrowOnError extends boolean = false>(
201215
options: Options<UploadFileData, ThrowOnError>,
202216
) =>
203-
(options?.client ?? _heyApiClient).post<
217+
(options.client ?? _heyApiClient).post<
204218
UploadFileResponse,
205219
unknown,
206220
ThrowOnError
@@ -268,7 +282,7 @@ export const placeOrder = <ThrowOnError extends boolean = false>(
268282
export const deleteOrder = <ThrowOnError extends boolean = false>(
269283
options: Options<DeleteOrderData, ThrowOnError>,
270284
) =>
271-
(options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
285+
(options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
272286
url: '/store/order/{orderId}',
273287
...options,
274288
});
@@ -280,7 +294,7 @@ export const deleteOrder = <ThrowOnError extends boolean = false>(
280294
export const getOrderById = <ThrowOnError extends boolean = false>(
281295
options: Options<GetOrderByIdData, ThrowOnError>,
282296
) =>
283-
(options?.client ?? _heyApiClient).get<
297+
(options.client ?? _heyApiClient).get<
284298
GetOrderByIdResponse,
285299
unknown,
286300
ThrowOnError
@@ -362,7 +376,7 @@ export const logoutUser = <ThrowOnError extends boolean = false>(
362376
export const deleteUser = <ThrowOnError extends boolean = false>(
363377
options: Options<DeleteUserData, ThrowOnError>,
364378
) =>
365-
(options?.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
379+
(options.client ?? _heyApiClient).delete<unknown, unknown, ThrowOnError>({
366380
url: '/user/{username}',
367381
...options,
368382
});
@@ -373,7 +387,7 @@ export const deleteUser = <ThrowOnError extends boolean = false>(
373387
export const getUserByName = <ThrowOnError extends boolean = false>(
374388
options: Options<GetUserByNameData, ThrowOnError>,
375389
) =>
376-
(options?.client ?? _heyApiClient).get<
390+
(options.client ?? _heyApiClient).get<
377391
GetUserByNameResponse,
378392
unknown,
379393
ThrowOnError
@@ -389,7 +403,7 @@ export const getUserByName = <ThrowOnError extends boolean = false>(
389403
export const updateUser = <ThrowOnError extends boolean = false>(
390404
options: Options<UpdateUserData, ThrowOnError>,
391405
) =>
392-
(options?.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({
406+
(options.client ?? _heyApiClient).put<unknown, unknown, ThrowOnError>({
393407
url: '/user/{username}',
394408
...options,
395409
headers: {

0 commit comments

Comments
 (0)