···4646Input is the first thing you must define. It can be a path, URL, or a string content resolving to an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.
47474848::: info
4949-We use [`@hey-api/json-schema-ref-parser`](https://github.com/hey-api/json-schema-ref-parser) to resolve file locations. Please note that accessing a HTTPS URL on localhost has a known [workaround](https://github.com/hey-api/openapi-ts/issues/276).
4949+If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/openapi-ts/issues/276#issuecomment-2043143501) in your environment.
5050:::
51515252## Output
···11+# Nuxt Minimal Starter
22+33+Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
44+55+## Setup
66+77+Make sure to install dependencies:
88+99+```bash
1010+# npm
1111+npm install
1212+1313+# pnpm
1414+pnpm install
1515+1616+# yarn
1717+yarn install
1818+1919+# bun
2020+bun install
2121+```
2222+2323+## Development Server
2424+2525+Start the development server on `http://localhost:3000`:
2626+2727+```bash
2828+# npm
2929+npm run dev
3030+3131+# pnpm
3232+pnpm dev
3333+3434+# yarn
3535+yarn dev
3636+3737+# bun
3838+bun run dev
3939+```
4040+4141+## Production
4242+4343+Build the application for production:
4444+4545+```bash
4646+# npm
4747+npm run build
4848+4949+# pnpm
5050+pnpm build
5151+5252+# yarn
5353+yarn build
5454+5555+# bun
5656+bun run build
5757+```
5858+5959+Locally preview production build:
6060+6161+```bash
6262+# npm
6363+npm run preview
6464+6565+# pnpm
6666+pnpm preview
6767+6868+# yarn
6969+yarn preview
7070+7171+# bun
7272+bun run preview
7373+```
7474+7575+Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
···11+// @ts-nocheck
22+// This file is auto-generated by @hey-api/openapi-ts
33+44+import {
55+ type Composable,
66+ createClient,
77+ createConfig,
88+ type Options,
99+} from '@hey-api/client-nuxt';
1010+1111+import type {
1212+ AddPetData,
1313+ AddPetResponse,
1414+ CreateUserData,
1515+ CreateUserResponse,
1616+ CreateUsersWithListInputData,
1717+ CreateUsersWithListInputResponse,
1818+ DeleteOrderData,
1919+ DeletePetData,
2020+ DeleteUserData,
2121+ FindPetsByStatusData,
2222+ FindPetsByStatusResponse,
2323+ FindPetsByTagsData,
2424+ FindPetsByTagsResponse,
2525+ GetInventoryData,
2626+ GetInventoryResponse,
2727+ GetOrderByIdData,
2828+ GetOrderByIdResponse,
2929+ GetPetByIdData,
3030+ GetPetByIdResponse,
3131+ GetUserByNameData,
3232+ GetUserByNameResponse,
3333+ LoginUserData,
3434+ LoginUserResponse,
3535+ LogoutUserData,
3636+ PlaceOrderData,
3737+ PlaceOrderResponse,
3838+ UpdatePetData,
3939+ UpdatePetResponse,
4040+ UpdatePetWithFormData,
4141+ UpdateUserData,
4242+ UploadFileData,
4343+ UploadFileResponse,
4444+} from './types.gen';
4545+4646+export const client = createClient(createConfig());
4747+4848+/**
4949+ * Add a new pet to the store
5050+ * Add a new pet to the store
5151+ */
5252+export const addPet = <TComposable extends Composable>(
5353+ options: Options<AddPetData, unknown, TComposable>,
5454+) =>
5555+ (options?.client ?? client).post<AddPetResponse, unknown, TComposable>({
5656+ ...options,
5757+ headers: {
5858+ 'Content-Type': 'application/json',
5959+ ...options?.headers,
6060+ },
6161+ url: '/pet',
6262+ });
6363+6464+/**
6565+ * Update an existing pet
6666+ * Update an existing pet by Id
6767+ */
6868+export const updatePet = <TComposable extends Composable>(
6969+ options: Options<UpdatePetData, unknown, TComposable>,
7070+) =>
7171+ (options?.client ?? client).put<UpdatePetResponse, unknown, TComposable>({
7272+ ...options,
7373+ headers: {
7474+ 'Content-Type': 'application/json',
7575+ ...options?.headers,
7676+ },
7777+ url: '/pet',
7878+ });
7979+8080+/**
8181+ * Finds Pets by status
8282+ * Multiple status values can be provided with comma separated strings
8383+ */
8484+export const findPetsByStatus = <TComposable extends Composable>(
8585+ options?: Options<FindPetsByStatusData, unknown, TComposable>,
8686+) =>
8787+ (options?.client ?? client).get<
8888+ FindPetsByStatusResponse,
8989+ unknown,
9090+ TComposable
9191+ >({
9292+ ...options,
9393+ url: '/pet/findByStatus',
9494+ });
9595+9696+/**
9797+ * Finds Pets by tags
9898+ * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
9999+ */
100100+export const findPetsByTags = <TComposable extends Composable>(
101101+ options?: Options<FindPetsByTagsData, unknown, TComposable>,
102102+) =>
103103+ (options?.client ?? client).get<FindPetsByTagsResponse, unknown, TComposable>(
104104+ {
105105+ ...options,
106106+ url: '/pet/findByTags',
107107+ },
108108+ );
109109+110110+/**
111111+ * Deletes a pet
112112+ */
113113+export const deletePet = <TComposable extends Composable>(
114114+ options: Options<DeletePetData, unknown, TComposable>,
115115+) =>
116116+ (options?.client ?? client).delete<unknown, unknown, TComposable>({
117117+ ...options,
118118+ url: '/pet/{petId}',
119119+ });
120120+121121+/**
122122+ * Find pet by ID
123123+ * Returns a single pet
124124+ */
125125+export const getPetById = <TComposable extends Composable>(
126126+ options: Options<GetPetByIdData, unknown, TComposable>,
127127+) =>
128128+ (options?.client ?? client).get<GetPetByIdResponse, unknown, TComposable>({
129129+ ...options,
130130+ security: [
131131+ {
132132+ fn: 'apiKey',
133133+ in: 'header',
134134+ name: 'api_key',
135135+ },
136136+ ],
137137+ // url: '/pet/{petId}',
138138+ url: '/pet/8',
139139+ });
140140+141141+/**
142142+ * Updates a pet in the store with form data
143143+ */
144144+export const updatePetWithForm = <TComposable extends Composable>(
145145+ options: Options<UpdatePetWithFormData, unknown, TComposable>,
146146+) =>
147147+ (options?.client ?? client).post<unknown, unknown, TComposable>({
148148+ ...options,
149149+ url: '/pet/{petId}',
150150+ });
151151+152152+/**
153153+ * uploads an image
154154+ */
155155+export const uploadFile = <TComposable extends Composable>(
156156+ options: Options<UploadFileData, unknown, TComposable>,
157157+) =>
158158+ (options?.client ?? client).post<UploadFileResponse, unknown, TComposable>({
159159+ ...options,
160160+ headers: {
161161+ 'Content-Type': 'application/octet-stream',
162162+ ...options?.headers,
163163+ },
164164+ url: '/pet/{petId}/uploadImage',
165165+ });
166166+167167+/**
168168+ * Returns pet inventories by status
169169+ * Returns a map of status codes to quantities
170170+ */
171171+export const getInventory = <TComposable extends Composable>(
172172+ options?: Options<GetInventoryData, unknown, TComposable>,
173173+) =>
174174+ (options?.client ?? client).get<GetInventoryResponse, unknown, TComposable>({
175175+ ...options,
176176+ security: [
177177+ {
178178+ fn: 'apiKey',
179179+ in: 'header',
180180+ name: 'api_key',
181181+ },
182182+ ],
183183+ url: '/store/inventory',
184184+ });
185185+186186+/**
187187+ * Place an order for a pet
188188+ * Place a new order in the store
189189+ */
190190+export const placeOrder = <TComposable extends Composable>(
191191+ options?: Options<PlaceOrderData, unknown, TComposable>,
192192+) =>
193193+ (options?.client ?? client).post<PlaceOrderResponse, unknown, TComposable>({
194194+ ...options,
195195+ headers: {
196196+ 'Content-Type': 'application/json',
197197+ ...options?.headers,
198198+ },
199199+ url: '/store/order',
200200+ });
201201+202202+/**
203203+ * Delete purchase order by ID
204204+ * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
205205+ */
206206+export const deleteOrder = <TComposable extends Composable>(
207207+ options: Options<DeleteOrderData, unknown, TComposable>,
208208+) =>
209209+ (options?.client ?? client).delete<unknown, unknown, TComposable>({
210210+ ...options,
211211+ url: '/store/order/{orderId}',
212212+ });
213213+214214+/**
215215+ * Find purchase order by ID
216216+ * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
217217+ */
218218+export const getOrderById = <TComposable extends Composable>(
219219+ options: Options<GetOrderByIdData, unknown, TComposable>,
220220+) =>
221221+ (options?.client ?? client).get<GetOrderByIdResponse, unknown, TComposable>({
222222+ ...options,
223223+ url: '/store/order/{orderId}',
224224+ });
225225+226226+/**
227227+ * Create user
228228+ * This can only be done by the logged in user.
229229+ */
230230+export const createUser = <TComposable extends Composable>(
231231+ options?: Options<CreateUserData, unknown, TComposable>,
232232+) =>
233233+ (options?.client ?? client).post<CreateUserResponse, unknown, TComposable>({
234234+ ...options,
235235+ headers: {
236236+ 'Content-Type': 'application/json',
237237+ ...options?.headers,
238238+ },
239239+ url: '/user',
240240+ });
241241+242242+/**
243243+ * Creates list of users with given input array
244244+ * Creates list of users with given input array
245245+ */
246246+export const createUsersWithListInput = <TComposable extends Composable>(
247247+ options?: Options<CreateUsersWithListInputData, unknown, TComposable>,
248248+) =>
249249+ (options?.client ?? client).post<
250250+ CreateUsersWithListInputResponse,
251251+ unknown,
252252+ TComposable
253253+ >({
254254+ ...options,
255255+ headers: {
256256+ 'Content-Type': 'application/json',
257257+ ...options?.headers,
258258+ },
259259+ url: '/user/createWithList',
260260+ });
261261+262262+/**
263263+ * Logs user into the system
264264+ */
265265+export const loginUser = <TComposable extends Composable>(
266266+ options?: Options<LoginUserData, unknown, TComposable>,
267267+) =>
268268+ (options?.client ?? client).get<LoginUserResponse, unknown, TComposable>({
269269+ ...options,
270270+ url: '/user/login',
271271+ });
272272+273273+/**
274274+ * Logs out current logged in user session
275275+ */
276276+export const logoutUser = <TComposable extends Composable>(
277277+ options?: Options<LogoutUserData, unknown, TComposable>,
278278+) =>
279279+ (options?.client ?? client).get<unknown, unknown, TComposable>({
280280+ ...options,
281281+ url: '/user/logout',
282282+ });
283283+284284+/**
285285+ * Delete user
286286+ * This can only be done by the logged in user.
287287+ */
288288+export const deleteUser = <TComposable extends Composable>(
289289+ options: Options<DeleteUserData, unknown, TComposable>,
290290+) =>
291291+ (options?.client ?? client).delete<unknown, unknown, TComposable>({
292292+ ...options,
293293+ url: '/user/{username}',
294294+ });
295295+296296+/**
297297+ * Get user by user name
298298+ */
299299+export const getUserByName = <TComposable extends Composable>(
300300+ options: Options<GetUserByNameData, unknown, TComposable>,
301301+) =>
302302+ (options?.client ?? client).get<GetUserByNameResponse, unknown, TComposable>({
303303+ ...options,
304304+ url: '/user/{username}',
305305+ });
306306+307307+/**
308308+ * Update user
309309+ * This can only be done by the logged in user.
310310+ */
311311+export const updateUser = <TComposable extends Composable>(
312312+ options: Options<UpdateUserData, unknown, TComposable>,
313313+) =>
314314+ (options?.client ?? client).put<unknown, unknown, TComposable>({
315315+ ...options,
316316+ headers: {
317317+ 'Content-Type': 'application/json',
318318+ ...options?.headers,
319319+ },
320320+ url: '/user/{username}',
321321+ });
+563
examples/openapi-ts-nuxt/client/types.gen.ts
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+export type Order = {
44+ complete?: boolean;
55+ id?: number;
66+ petId?: number;
77+ quantity?: number;
88+ shipDate?: string;
99+ /**
1010+ * Order Status
1111+ */
1212+ status?: 'placed' | 'approved' | 'delivered';
1313+};
1414+1515+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+2828+export type Category = {
2929+ id?: number;
3030+ name?: string;
3131+};
3232+3333+export type User = {
3434+ email?: string;
3535+ firstName?: string;
3636+ id?: number;
3737+ lastName?: string;
3838+ password?: string;
3939+ phone?: string;
4040+ /**
4141+ * User Status
4242+ */
4343+ userStatus?: number;
4444+ username?: string;
4545+};
4646+4747+export type Tag = {
4848+ id?: number;
4949+ name?: string;
5050+};
5151+5252+export type Pet = {
5353+ category?: Category;
5454+ id?: number;
5555+ name: string;
5656+ photoUrls: Array<string>;
5757+ /**
5858+ * pet status in the store
5959+ */
6060+ status?: 'available' | 'pending' | 'sold';
6161+ tags?: Array<Tag>;
6262+};
6363+6464+export type ApiResponse = {
6565+ code?: number;
6666+ message?: string;
6767+ type?: string;
6868+};
6969+7070+export type Pet2 = Pet;
7171+7272+/**
7373+ * List of user object
7474+ */
7575+export type UserArray = Array<User>;
7676+7777+export type AddPetData = {
7878+ /**
7979+ * Create a new pet in the store
8080+ */
8181+ body: Pet;
8282+ path?: never;
8383+ query?: never;
8484+ url: '/pet';
8585+};
8686+8787+export type AddPetErrors = {
8888+ /**
8989+ * Invalid input
9090+ */
9191+ 405: unknown;
9292+};
9393+9494+export type AddPetResponses = {
9595+ /**
9696+ * Successful operation
9797+ */
9898+ 200: Pet;
9999+};
100100+101101+export type AddPetResponse = AddPetResponses[keyof AddPetResponses];
102102+103103+export type UpdatePetData = {
104104+ /**
105105+ * Update an existent pet in the store
106106+ */
107107+ body: Pet;
108108+ path?: never;
109109+ query?: never;
110110+ url: '/pet';
111111+};
112112+113113+export type UpdatePetErrors = {
114114+ /**
115115+ * Invalid ID supplied
116116+ */
117117+ 400: unknown;
118118+ /**
119119+ * Pet not found
120120+ */
121121+ 404: unknown;
122122+ /**
123123+ * Validation exception
124124+ */
125125+ 405: unknown;
126126+};
127127+128128+export type UpdatePetResponses = {
129129+ /**
130130+ * Successful operation
131131+ */
132132+ 200: Pet;
133133+};
134134+135135+export type UpdatePetResponse = UpdatePetResponses[keyof UpdatePetResponses];
136136+137137+export type FindPetsByStatusData = {
138138+ body?: never;
139139+ path?: never;
140140+ query?: {
141141+ /**
142142+ * Status values that need to be considered for filter
143143+ */
144144+ status?: 'available' | 'pending' | 'sold';
145145+ };
146146+ url: '/pet/findByStatus';
147147+};
148148+149149+export type FindPetsByStatusErrors = {
150150+ /**
151151+ * Invalid status value
152152+ */
153153+ 400: unknown;
154154+};
155155+156156+export type FindPetsByStatusResponses = {
157157+ /**
158158+ * successful operation
159159+ */
160160+ 200: Array<Pet>;
161161+};
162162+163163+export type FindPetsByStatusResponse =
164164+ FindPetsByStatusResponses[keyof FindPetsByStatusResponses];
165165+166166+export type FindPetsByTagsData = {
167167+ body?: never;
168168+ path?: never;
169169+ query?: {
170170+ /**
171171+ * Tags to filter by
172172+ */
173173+ tags?: Array<string>;
174174+ };
175175+ url: '/pet/findByTags';
176176+};
177177+178178+export type FindPetsByTagsErrors = {
179179+ /**
180180+ * Invalid tag value
181181+ */
182182+ 400: unknown;
183183+};
184184+185185+export type FindPetsByTagsResponses = {
186186+ /**
187187+ * successful operation
188188+ */
189189+ 200: Array<Pet>;
190190+};
191191+192192+export type FindPetsByTagsResponse =
193193+ FindPetsByTagsResponses[keyof FindPetsByTagsResponses];
194194+195195+export type DeletePetData = {
196196+ body?: never;
197197+ headers?: {
198198+ api_key?: string;
199199+ };
200200+ path: {
201201+ /**
202202+ * Pet id to delete
203203+ */
204204+ petId: number;
205205+ };
206206+ query?: never;
207207+ url: '/pet/{petId}';
208208+};
209209+210210+export type DeletePetErrors = {
211211+ /**
212212+ * Invalid pet value
213213+ */
214214+ 400: unknown;
215215+};
216216+217217+export type GetPetByIdData = {
218218+ body?: never;
219219+ path: {
220220+ /**
221221+ * ID of pet to return
222222+ */
223223+ petId: number;
224224+ };
225225+ query?: never;
226226+ url: '/pet/{petId}';
227227+};
228228+229229+export type GetPetByIdErrors = {
230230+ /**
231231+ * Invalid ID supplied
232232+ */
233233+ 400: unknown;
234234+ /**
235235+ * Pet not found
236236+ */
237237+ 404: unknown;
238238+};
239239+240240+export type GetPetByIdResponses = {
241241+ /**
242242+ * successful operation
243243+ */
244244+ 200: Pet;
245245+};
246246+247247+export type GetPetByIdResponse = GetPetByIdResponses[keyof GetPetByIdResponses];
248248+249249+export type UpdatePetWithFormData = {
250250+ body?: never;
251251+ path: {
252252+ /**
253253+ * ID of pet that needs to be updated
254254+ */
255255+ petId: number;
256256+ };
257257+ query?: {
258258+ /**
259259+ * Name of pet that needs to be updated
260260+ */
261261+ name?: string;
262262+ /**
263263+ * Status of pet that needs to be updated
264264+ */
265265+ status?: string;
266266+ };
267267+ url: '/pet/{petId}';
268268+};
269269+270270+export type UpdatePetWithFormErrors = {
271271+ /**
272272+ * Invalid input
273273+ */
274274+ 405: unknown;
275275+};
276276+277277+export type UploadFileData = {
278278+ body?: Blob | File;
279279+ path: {
280280+ /**
281281+ * ID of pet to update
282282+ */
283283+ petId: number;
284284+ };
285285+ query?: {
286286+ /**
287287+ * Additional Metadata
288288+ */
289289+ additionalMetadata?: string;
290290+ };
291291+ url: '/pet/{petId}/uploadImage';
292292+};
293293+294294+export type UploadFileResponses = {
295295+ /**
296296+ * successful operation
297297+ */
298298+ 200: ApiResponse;
299299+};
300300+301301+export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses];
302302+303303+export type GetInventoryData = {
304304+ body?: never;
305305+ path?: never;
306306+ query?: never;
307307+ url: '/store/inventory';
308308+};
309309+310310+export type GetInventoryResponses = {
311311+ /**
312312+ * successful operation
313313+ */
314314+ 200: {
315315+ [key: string]: number;
316316+ };
317317+};
318318+319319+export type GetInventoryResponse =
320320+ GetInventoryResponses[keyof GetInventoryResponses];
321321+322322+export type PlaceOrderData = {
323323+ body?: Order;
324324+ path?: never;
325325+ query?: never;
326326+ url: '/store/order';
327327+};
328328+329329+export type PlaceOrderErrors = {
330330+ /**
331331+ * Invalid input
332332+ */
333333+ 405: unknown;
334334+};
335335+336336+export type PlaceOrderResponses = {
337337+ /**
338338+ * successful operation
339339+ */
340340+ 200: Order;
341341+};
342342+343343+export type PlaceOrderResponse = PlaceOrderResponses[keyof PlaceOrderResponses];
344344+345345+export type DeleteOrderData = {
346346+ body?: never;
347347+ path: {
348348+ /**
349349+ * ID of the order that needs to be deleted
350350+ */
351351+ orderId: number;
352352+ };
353353+ query?: never;
354354+ url: '/store/order/{orderId}';
355355+};
356356+357357+export type DeleteOrderErrors = {
358358+ /**
359359+ * Invalid ID supplied
360360+ */
361361+ 400: unknown;
362362+ /**
363363+ * Order not found
364364+ */
365365+ 404: unknown;
366366+};
367367+368368+export type GetOrderByIdData = {
369369+ body?: never;
370370+ path: {
371371+ /**
372372+ * ID of order that needs to be fetched
373373+ */
374374+ orderId: number;
375375+ };
376376+ query?: never;
377377+ url: '/store/order/{orderId}';
378378+};
379379+380380+export type GetOrderByIdErrors = {
381381+ /**
382382+ * Invalid ID supplied
383383+ */
384384+ 400: unknown;
385385+ /**
386386+ * Order not found
387387+ */
388388+ 404: unknown;
389389+};
390390+391391+export type GetOrderByIdResponses = {
392392+ /**
393393+ * successful operation
394394+ */
395395+ 200: Order;
396396+};
397397+398398+export type GetOrderByIdResponse =
399399+ GetOrderByIdResponses[keyof GetOrderByIdResponses];
400400+401401+export type CreateUserData = {
402402+ /**
403403+ * Created user object
404404+ */
405405+ body?: User;
406406+ path?: never;
407407+ query?: never;
408408+ url: '/user';
409409+};
410410+411411+export type CreateUserResponses = {
412412+ /**
413413+ * successful operation
414414+ */
415415+ default: User;
416416+};
417417+418418+export type CreateUserResponse = CreateUserResponses[keyof CreateUserResponses];
419419+420420+export type CreateUsersWithListInputData = {
421421+ body?: Array<User>;
422422+ path?: never;
423423+ query?: never;
424424+ url: '/user/createWithList';
425425+};
426426+427427+export type CreateUsersWithListInputResponses = {
428428+ /**
429429+ * Successful operation
430430+ */
431431+ 200: User;
432432+ /**
433433+ * successful operation
434434+ */
435435+ default: unknown;
436436+};
437437+438438+export type CreateUsersWithListInputResponse =
439439+ CreateUsersWithListInputResponses[keyof CreateUsersWithListInputResponses];
440440+441441+export type LoginUserData = {
442442+ body?: never;
443443+ path?: never;
444444+ query?: {
445445+ /**
446446+ * The password for login in clear text
447447+ */
448448+ password?: string;
449449+ /**
450450+ * The user name for login
451451+ */
452452+ username?: string;
453453+ };
454454+ url: '/user/login';
455455+};
456456+457457+export type LoginUserErrors = {
458458+ /**
459459+ * Invalid username/password supplied
460460+ */
461461+ 400: unknown;
462462+};
463463+464464+export type LoginUserResponses = {
465465+ /**
466466+ * successful operation
467467+ */
468468+ 200: Blob | File;
469469+};
470470+471471+export type LoginUserResponse = LoginUserResponses[keyof LoginUserResponses];
472472+473473+export type LogoutUserData = {
474474+ body?: never;
475475+ path?: never;
476476+ query?: never;
477477+ url: '/user/logout';
478478+};
479479+480480+export type LogoutUserResponses = {
481481+ /**
482482+ * successful operation
483483+ */
484484+ default: unknown;
485485+};
486486+487487+export type DeleteUserData = {
488488+ body?: never;
489489+ path: {
490490+ /**
491491+ * The name that needs to be deleted
492492+ */
493493+ username: string;
494494+ };
495495+ query?: never;
496496+ url: '/user/{username}';
497497+};
498498+499499+export type DeleteUserErrors = {
500500+ /**
501501+ * Invalid username supplied
502502+ */
503503+ 400: unknown;
504504+ /**
505505+ * User not found
506506+ */
507507+ 404: unknown;
508508+};
509509+510510+export type GetUserByNameData = {
511511+ body?: never;
512512+ path: {
513513+ /**
514514+ * The name that needs to be fetched. Use user1 for testing.
515515+ */
516516+ username: string;
517517+ };
518518+ query?: never;
519519+ url: '/user/{username}';
520520+};
521521+522522+export type GetUserByNameErrors = {
523523+ /**
524524+ * Invalid username supplied
525525+ */
526526+ 400: unknown;
527527+ /**
528528+ * User not found
529529+ */
530530+ 404: unknown;
531531+};
532532+533533+export type GetUserByNameResponses = {
534534+ /**
535535+ * successful operation
536536+ */
537537+ 200: User;
538538+};
539539+540540+export type GetUserByNameResponse =
541541+ GetUserByNameResponses[keyof GetUserByNameResponses];
542542+543543+export type UpdateUserData = {
544544+ /**
545545+ * Update an existent user in the store
546546+ */
547547+ body?: User;
548548+ path: {
549549+ /**
550550+ * name that needs to be updated
551551+ */
552552+ username: string;
553553+ };
554554+ query?: never;
555555+ url: '/user/{username}';
556556+};
557557+558558+export type UpdateUserResponses = {
559559+ /**
560560+ * successful operation
561561+ */
562562+ default: unknown;
563563+};
+95
examples/openapi-ts-nuxt/components/home.vue
···11+<script setup lang="ts">
22+import { getPetById, type Pet } from '~/client';
33+44+// START
55+const baseUrl = 'https://petstore3.swagger.io/api/v3';
66+const finalUrl = `${baseUrl}/pet/8`;
77+88+// $fetch
99+// During SSR data is fetched twice, once on the server and once on the client.
1010+const dollarFetch = await getPetById({
1111+ composable: '$fetch',
1212+});
1313+const dollarFetchNuxt = await $fetch<Pet>(finalUrl);
1414+1515+// useAsyncData
1616+// During SSR data is fetched only on the server side and transferred to the client.
1717+const asyncData = await getPetById({
1818+ composable: 'useAsyncData',
1919+ key: 'item',
2020+ asyncDataOptions: {},
2121+});
2222+const asyncDataNuxt = await useAsyncData<Pet>(() => $fetch(finalUrl));
2323+const asyncDataWithKeyNuxt = await useAsyncData<Pet>('item', () =>
2424+ $fetch(finalUrl),
2525+);
2626+2727+// useFetch
2828+// You can also useFetch as shortcut of useAsyncData + $fetch
2929+const fetch = await getPetById({
3030+ composable: 'useFetch',
3131+ fetchOptions: {},
3232+});
3333+const fetchNuxt = await useFetch<Pet>(finalUrl);
3434+3535+// useLazyAsyncData
3636+/* Navigation will occur before fetching is complete.
3737+ Handle 'pending' and 'error' states directly within your component's template
3838+*/
3939+const lazyAsyncData = await getPetById({
4040+ composable: 'useLazyAsyncData',
4141+ key: 'count',
4242+});
4343+const lazyAsyncDataNuxt = await useLazyAsyncData<Pet>('count', () =>
4444+ $fetch(finalUrl),
4545+);
4646+watch(lazyAsyncDataNuxt.data, (newCount) => {
4747+ // Because count might start out null, you won't have access
4848+ // to its contents immediately, but you can watch it.
4949+});
5050+5151+// useLazyFetch
5252+/* Navigation will occur before fetching is complete.
5353+ * Handle 'pending' and 'error' states directly within your component's template
5454+ */
5555+const lazyFetch = await getPetById({
5656+ composable: 'useLazyFetch',
5757+});
5858+const lazyFetchNuxt = await useLazyFetch<Pet>(finalUrl);
5959+watch(lazyFetchNuxt.data, (newPosts) => {
6060+ // Because posts might start out null, you won't have access
6161+ // to its contents immediately, but you can watch it.
6262+});
6363+6464+// useRequestFetch
6565+// This will forward the user's headers to the `/api/foo` event handler
6666+// Result: { cookies: { foo: 'bar' } }
6767+const requestFetch = useRequestFetch();
6868+const asyncDataFinal = await getPetById({
6969+ composable: 'useAsyncData',
7070+ requestFetch,
7171+});
7272+const asyncData2 = await useAsyncData<Pet>(() => requestFetch(finalUrl));
7373+// This will NOT forward anything
7474+// Result: { cookies: {} }
7575+const asyncData3 = await useAsyncData<Pet>(() => $fetch(finalUrl));
7676+7777+// END
7878+7979+async function handleClick() {
8080+ const result = await getPetById({
8181+ composable: '$fetch',
8282+ // @ts-expect-error
8383+ path: {
8484+ petId: 8,
8585+ },
8686+ });
8787+ console.warn(result);
8888+}
8989+</script>
9090+9191+<template>
9292+ <div>
9393+ <button @click="handleClick">Get Random Pet</button>
9494+ </div>
9595+</template>
···11+MIT License
22+33+Copyright (c) Hey API
44+55+Permission is hereby granted, free of charge, to any person obtaining a copy
66+of this software and associated documentation files (the "Software"), to deal
77+in the Software without restriction, including without limitation the rights
88+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+copies of the Software, and to permit persons to whom the Software is
1010+furnished to do so, subject to the following conditions:
1111+1212+The above copyright notice and this permission notice shall be included in all
1313+copies or substantial portions of the Software.
1414+1515+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+SOFTWARE.
+41
packages/client-nuxt/README.md
···11+<div align="center">
22+ <img alt="Hey API logo" height="150" src="https://heyapi.dev/images/logo-300w.png" width="150">
33+ <h1 align="center"><b>Nuxt Client</b></h1>
44+ <p align="center">🚀 Nuxt client for `@hey-api/openapi-ts` codegen.</p>
55+</div>
66+77+<!-- TODO: update link to Nuxt example -->
88+99+[Live demo](https://stackblitz.com/edit/hey-api-client-fetch-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts,src%2FApp.tsx)
1010+1111+## Features
1212+1313+- seamless integration with `@hey-api/openapi-ts` ecosystem
1414+- type-safe response data and errors
1515+- response data validation and transformation
1616+- access to the original request and response
1717+- granular request and response customization options
1818+- minimal learning curve thanks to extending the underlying technology
1919+- support bundling inside the generated output
2020+2121+## Documentation
2222+2323+Please visit our [website](https://heyapi.dev/) for documentation, guides, migrating, and more.
2424+2525+## Sponsors
2626+2727+Love Hey API? Become our [sponsor](https://github.com/sponsors/hey-api).
2828+2929+<p>
3030+ <a href="https://kutt.it/pkEZyc" target="_blank">
3131+ <img alt="Stainless logo" height="50" src="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg" />
3232+ </a>
3333+</p>
3434+3535+## GitHub Integration (coming soon)
3636+3737+Automatically update your code when the APIs it depends on change. [Find out more](https://heyapi.dev/openapi-ts/integrations.html).
3838+3939+## Migration Guides
4040+4141+[OpenAPI Typescript Codegen](https://heyapi.dev/openapi-ts/migrating.html#openapi-typescript-codegen)