···11+---
22+'@hey-api/client-fetch': minor
33+---
44+55+fix: set next field to never and recommend switching to the Next.js client
+15-15
docs/openapi-ts/clients/next-js.md
···68686969When we installed the client above, it created a [`client.gen.ts`](/openapi-ts/output#client) file. You will most likely want to configure the exported `client` instance. There are two ways to do that.
70707171-### `setConfig()`
7272-7373-This is the simpler approach. You can call the `setConfig()` method at the beginning of your application or anytime you need to update the client configuration. You can pass any Fetch API configuration option to `setConfig()`, and even your own Fetch implementation.
7474-7575-```js
7676-import { client } from 'client/client.gen';
7777-7878-client.setConfig({
7979- baseUrl: 'https://example.com',
8080-});
8181-```
8282-8383-The disadvantage of this approach is that your code may call the `client` instance before it's configured for the first time. Depending on your use case, you might need to use the second approach.
8484-8571### Runtime API
86728773Since `client.gen.ts` is a generated file, we can't directly modify it. Instead, we can tell our configuration to use a custom file implementing the Runtime API. We do that by specifying the `runtimeConfigPath` option.
···114100115101:::
116102117117-With this approach, `client.gen.ts` will call `createClientConfig()` before initializing the `client` instance. If needed, you can still use `setConfig()` to update the client configuration later.
103103+With this approach, `client.gen.ts` will call `createClientConfig()` before initializing the `client` instance. This is the recommended approach because it guarantees the client will be initialized in both server and client environment. If needed, you can still use `setConfig()` to update the client configuration later.
104104+105105+### `setConfig()`
106106+107107+This is the simpler approach. You can call the `setConfig()` method at the beginning of your application or anytime you need to update the client configuration. You can pass any Fetch API configuration option to `setConfig()`, and even your own Fetch implementation.
108108+109109+```js
110110+import { client } from 'client/client.gen';
111111+112112+client.setConfig({
113113+ baseUrl: 'https://example.com',
114114+});
115115+```
116116+117117+The disadvantage of this approach is that your code may call the `client` instance before it's configured for the first time. Depending on your use case, this might be an acceptable trade-off. However, our Next.js users usually want to use the first approach.
118118119119### `createClient()`
120120
···3737 UpdatePetData,
3838 UpdatePetResponse,
3939 UpdatePetWithFormData,
4040+ UpdatePetWithFormResponse,
4041 UpdateUserData,
4142 UploadFileData,
4243 UploadFileResponse,
···6061};
61626263/**
6363- * Add a new pet to the store
6464- * Add a new pet to the store
6464+ * Add a new pet to the store.
6565+ * Add a new pet to the store.
6566 */
6667export const addPet = <ThrowOnError extends boolean = false>(
6768 options: Options<AddPetData, ThrowOnError>,
···8485 );
85868687/**
8787- * Update an existing pet
8888- * Update an existing pet by Id
8888+ * Update an existing pet.
8989+ * Update an existing pet by Id.
8990 */
9091export const updatePet = <ThrowOnError extends boolean = false>(
9192 options: Options<UpdatePetData, ThrowOnError>,
···110111 });
111112112113/**
113113- * Finds Pets by status
114114- * Multiple status values can be provided with comma separated strings
114114+ * Finds Pets by status.
115115+ * Multiple status values can be provided with comma separated strings.
115116 */
116117export const findPetsByStatus = <ThrowOnError extends boolean = false>(
117118 options?: Options<FindPetsByStatusData, ThrowOnError>,
···132133 });
133134134135/**
135135- * Finds Pets by tags
136136+ * Finds Pets by tags.
136137 * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
137138 */
138139export const findPetsByTags = <ThrowOnError extends boolean = false>(
···154155 });
155156156157/**
157157- * Deletes a pet
158158+ * Deletes a pet.
159159+ * Delete a pet.
158160 */
159161export const deletePet = <ThrowOnError extends boolean = false>(
160162 options: Options<DeletePetData, ThrowOnError>,
···171173 });
172174173175/**
174174- * Find pet by ID
175175- * Returns a single pet
176176+ * Find pet by ID.
177177+ * Returns a single pet.
176178 */
177179export const getPetById = <ThrowOnError extends boolean = false>(
178180 options: Options<GetPetByIdData, ThrowOnError>,
···197199 });
198200199201/**
200200- * Updates a pet in the store with form data
202202+ * Updates a pet in the store with form data.
203203+ * Updates a pet resource based on the form data.
201204 */
202205export const updatePetWithForm = <ThrowOnError extends boolean = false>(
203206 options: Options<UpdatePetWithFormData, ThrowOnError>,
204207) =>
205205- (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
208208+ (options.client ?? _heyApiClient).post<
209209+ UpdatePetWithFormResponse,
210210+ unknown,
211211+ ThrowOnError
212212+ >({
206213 security: [
207214 {
208215 scheme: 'bearer',
···214221 });
215222216223/**
217217- * uploads an image
224224+ * Uploads an image.
225225+ * Upload image of the pet.
218226 */
219227export const uploadFile = <ThrowOnError extends boolean = false>(
220228 options: Options<UploadFileData, ThrowOnError>,
···239247 });
240248241249/**
242242- * Returns pet inventories by status
243243- * Returns a map of status codes to quantities
250250+ * Returns pet inventories by status.
251251+ * Returns a map of status codes to quantities.
244252 */
245253export const getInventory = <ThrowOnError extends boolean = false>(
246254 options?: Options<GetInventoryData, ThrowOnError>,
···261269 });
262270263271/**
264264- * Place an order for a pet
265265- * Place a new order in the store
272272+ * Place an order for a pet.
273273+ * Place a new order in the store.
266274 */
267275export const placeOrder = <ThrowOnError extends boolean = false>(
268276 options?: Options<PlaceOrderData, ThrowOnError>,
···281289 });
282290283291/**
284284- * Delete purchase order by ID
285285- * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
292292+ * Delete purchase order by identifier.
293293+ * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
286294 */
287295export const deleteOrder = <ThrowOnError extends boolean = false>(
288296 options: Options<DeleteOrderData, ThrowOnError>,
···293301 });
294302295303/**
296296- * Find purchase order by ID
304304+ * Find purchase order by ID.
297305 * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
298306 */
299307export const getOrderById = <ThrowOnError extends boolean = false>(
···309317 });
310318311319/**
312312- * Create user
320320+ * Create user.
313321 * This can only be done by the logged in user.
314322 */
315323export const createUser = <ThrowOnError extends boolean = false>(
···329337 });
330338331339/**
332332- * Creates list of users with given input array
333333- * Creates list of users with given input array
340340+ * Creates list of users with given input array.
341341+ * Creates list of users with given input array.
334342 */
335343export const createUsersWithListInput = <ThrowOnError extends boolean = false>(
336344 options?: Options<CreateUsersWithListInputData, ThrowOnError>,
···349357 });
350358351359/**
352352- * Logs user into the system
360360+ * Logs user into the system.
361361+ * Log into the system.
353362 */
354363export const loginUser = <ThrowOnError extends boolean = false>(
355364 options?: Options<LoginUserData, ThrowOnError>,
···364373 });
365374366375/**
367367- * Logs out current logged in user session
376376+ * Logs out current logged in user session.
377377+ * Log user out of the system.
368378 */
369379export const logoutUser = <ThrowOnError extends boolean = false>(
370380 options?: Options<LogoutUserData, ThrowOnError>,
···375385 });
376386377387/**
378378- * Delete user
388388+ * Delete user resource.
379389 * This can only be done by the logged in user.
380390 */
381391export const deleteUser = <ThrowOnError extends boolean = false>(
···387397 });
388398389399/**
390390- * Get user by user name
400400+ * Get user by user name.
401401+ * Get user detail based on username.
391402 */
392403export const getUserByName = <ThrowOnError extends boolean = false>(
393404 options: Options<GetUserByNameData, ThrowOnError>,
···402413 });
403414404415/**
405405- * Update user
416416+ * Update user resource.
406417 * This can only be done by the logged in user.
407418 */
408419export const updateUser = <ThrowOnError extends boolean = false>(
+159-27
examples/openapi-ts-next/src/client/types.gen.ts
···1212 status?: 'placed' | 'approved' | 'delivered';
1313};
14141515-export type Customer = {
1616- address?: Array<Address>;
1717- id?: number;
1818- username?: string;
1919-};
2020-2121-export type Address = {
2222- city?: string;
2323- state?: string;
2424- street?: string;
2525- zip?: string;
2626-};
2727-2815export type Category = {
2916 id?: number;
3017 name?: string;
···8875 /**
8976 * Invalid input
9077 */
9191- 405: unknown;
7878+ 400: unknown;
7979+ /**
8080+ * Validation exception
8181+ */
8282+ 422: unknown;
8383+ /**
8484+ * Unexpected error
8585+ */
8686+ default: unknown;
9287};
93889489export type AddPetResponses = {
···122117 /**
123118 * Validation exception
124119 */
125125- 405: unknown;
120120+ 422: unknown;
121121+ /**
122122+ * Unexpected error
123123+ */
124124+ default: unknown;
126125};
127126128127export type UpdatePetResponses = {
···151150 * Invalid status value
152151 */
153152 400: unknown;
153153+ /**
154154+ * Unexpected error
155155+ */
156156+ default: unknown;
154157};
155158156159export type FindPetsByStatusResponses = {
···180183 * Invalid tag value
181184 */
182185 400: unknown;
186186+ /**
187187+ * Unexpected error
188188+ */
189189+ default: unknown;
183190};
184191185192export type FindPetsByTagsResponses = {
···212219 * Invalid pet value
213220 */
214221 400: unknown;
222222+ /**
223223+ * Unexpected error
224224+ */
225225+ default: unknown;
226226+};
227227+228228+export type DeletePetResponses = {
229229+ /**
230230+ * Pet deleted
231231+ */
232232+ 200: unknown;
215233};
216234217235export type GetPetByIdData = {
···235253 * Pet not found
236254 */
237255 404: unknown;
256256+ /**
257257+ * Unexpected error
258258+ */
259259+ default: unknown;
238260};
239261240262export type GetPetByIdResponses = {
···271293 /**
272294 * Invalid input
273295 */
274274- 405: unknown;
296296+ 400: unknown;
297297+ /**
298298+ * Unexpected error
299299+ */
300300+ default: unknown;
301301+};
302302+303303+export type UpdatePetWithFormResponses = {
304304+ /**
305305+ * successful operation
306306+ */
307307+ 200: Pet;
275308};
309309+310310+export type UpdatePetWithFormResponse =
311311+ UpdatePetWithFormResponses[keyof UpdatePetWithFormResponses];
276312277313export type UploadFileData = {
278314 body?: Blob | File;
···291327 url: '/pet/{petId}/uploadImage';
292328};
293329330330+export type UploadFileErrors = {
331331+ /**
332332+ * No file uploaded
333333+ */
334334+ 400: unknown;
335335+ /**
336336+ * Pet not found
337337+ */
338338+ 404: unknown;
339339+ /**
340340+ * Unexpected error
341341+ */
342342+ default: unknown;
343343+};
344344+294345export type UploadFileResponses = {
295346 /**
296347 * successful operation
···305356 path?: never;
306357 query?: never;
307358 url: '/store/inventory';
359359+};
360360+361361+export type GetInventoryErrors = {
362362+ /**
363363+ * Unexpected error
364364+ */
365365+ default: unknown;
308366};
309367310368export type GetInventoryResponses = {
···330388 /**
331389 * Invalid input
332390 */
333333- 405: unknown;
391391+ 400: unknown;
392392+ /**
393393+ * Validation exception
394394+ */
395395+ 422: unknown;
396396+ /**
397397+ * Unexpected error
398398+ */
399399+ default: unknown;
334400};
335401336402export type PlaceOrderResponses = {
···363429 * Order not found
364430 */
365431 404: unknown;
432432+ /**
433433+ * Unexpected error
434434+ */
435435+ default: unknown;
436436+};
437437+438438+export type DeleteOrderResponses = {
439439+ /**
440440+ * order deleted
441441+ */
442442+ 200: unknown;
366443};
367444368445export type GetOrderByIdData = {
···386463 * Order not found
387464 */
388465 404: unknown;
466466+ /**
467467+ * Unexpected error
468468+ */
469469+ default: unknown;
389470};
390471391472export type GetOrderByIdResponses = {
···408489 url: '/user';
409490};
410491492492+export type CreateUserErrors = {
493493+ /**
494494+ * Unexpected error
495495+ */
496496+ default: unknown;
497497+};
498498+411499export type CreateUserResponses = {
412500 /**
413501 * successful operation
414502 */
415415- default: User;
503503+ 200: User;
416504};
417505418506export type CreateUserResponse = CreateUserResponses[keyof CreateUserResponses];
···424512 url: '/user/createWithList';
425513};
426514515515+export type CreateUsersWithListInputErrors = {
516516+ /**
517517+ * Unexpected error
518518+ */
519519+ default: unknown;
520520+};
521521+427522export type CreateUsersWithListInputResponses = {
428523 /**
429524 * Successful operation
430525 */
431526 200: User;
432432- /**
433433- * successful operation
434434- */
435435- default: unknown;
436527};
437528438529export type CreateUsersWithListInputResponse =
···459550 * Invalid username/password supplied
460551 */
461552 400: unknown;
553553+ /**
554554+ * Unexpected error
555555+ */
556556+ default: unknown;
462557};
463558464559export type LoginUserResponses = {
···477572 url: '/user/logout';
478573};
479574575575+export type LogoutUserErrors = {
576576+ /**
577577+ * Unexpected error
578578+ */
579579+ default: unknown;
580580+};
581581+480582export type LogoutUserResponses = {
481583 /**
482584 * successful operation
483585 */
484484- default: unknown;
586586+ 200: unknown;
485587};
486588487589export type DeleteUserData = {
···505607 * User not found
506608 */
507609 404: unknown;
610610+ /**
611611+ * Unexpected error
612612+ */
613613+ default: unknown;
614614+};
615615+616616+export type DeleteUserResponses = {
617617+ /**
618618+ * User deleted
619619+ */
620620+ 200: unknown;
508621};
509622510623export type GetUserByNameData = {
511624 body?: never;
512625 path: {
513626 /**
514514- * The name that needs to be fetched. Use user1 for testing.
627627+ * The name that needs to be fetched. Use user1 for testing
515628 */
516629 username: string;
517630 };
···528641 * User not found
529642 */
530643 404: unknown;
644644+ /**
645645+ * Unexpected error
646646+ */
647647+ default: unknown;
531648};
532649533650export type GetUserByNameResponses = {
···547664 body?: User;
548665 path: {
549666 /**
550550- * name that needs to be updated
667667+ * name that need to be deleted
551668 */
552669 username: string;
553670 };
···555672 url: '/user/{username}';
556673};
557674675675+export type UpdateUserErrors = {
676676+ /**
677677+ * bad request
678678+ */
679679+ 400: unknown;
680680+ /**
681681+ * user not found
682682+ */
683683+ 404: unknown;
684684+ /**
685685+ * Unexpected error
686686+ */
687687+ default: unknown;
688688+};
689689+558690export type UpdateUserResponses = {
559691 /**
560692 * successful operation
561693 */
562562- default: unknown;
694694+ 200: unknown;
563695};
564696565697export type ClientOptions = {
566566- baseUrl: `${string}://${string}/v3` | (string & {});
698698+ baseUrl: 'https://petstore3.swagger.io/api/v3' | (string & {});
567699};
+7
packages/client-fetch/src/types.ts
···2121 */
2222 fetch?: (request: Request) => ReturnType<typeof fetch>;
2323 /**
2424+ * Please don't use the Fetch client for Next.js applications. The `next`
2525+ * options won't have any effect.
2626+ *
2727+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
2828+ */
2929+ next?: never;
3030+ /**
2431 * Return the response data parsed in a specified format. By default, `auto`
2532 * will infer the appropriate method from the `Content-Type` response header.
2633 * You can override this behavior with any of the {@link Body} methods.
···139139 */
140140 fetch?: (request: Request) => ReturnType<typeof fetch>;
141141 /**
142142+ * Please don't use the Fetch client for Next.js applications. The `next`
143143+ * options won't have any effect.
144144+ *
145145+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
146146+ */
147147+ next?: never;
148148+ /**
142149 * Return the response data parsed in a specified format. By default, `auto`
143150 * will infer the appropriate method from the `Content-Type` response header.
144151 * You can override this behavior with any of the {@link Body} methods.
···139139 */
140140 fetch?: (request: Request) => ReturnType<typeof fetch>;
141141 /**
142142+ * Please don't use the Fetch client for Next.js applications. The `next`
143143+ * options won't have any effect.
144144+ *
145145+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
146146+ */
147147+ next?: never;
148148+ /**
142149 * Return the response data parsed in a specified format. By default, `auto`
143150 * will infer the appropriate method from the `Content-Type` response header.
144151 * You can override this behavior with any of the {@link Body} methods.