tangled
alpha
login
or
join now
mokkenstorm.dev
/
openapi-ts
0
fork
atom
fork of hey-api/openapi-ts because I need some additional things
0
fork
atom
overview
issues
pulls
pipelines
refactor: remove unused plugins
Max Scopp
7 months ago
3ad13597
2166d56e
+1
-1011
3 changed files
expand all
collapse all
unified
split
examples
openapi-ts-angular
openapi-ts.config.ts
src
client
@hey-api
angular-resource.gen.ts
@tanstack
angular-query-experimental.gen.ts
+1
-15
examples/openapi-ts-angular/openapi-ts.config.ts
···
14
14
// throwOnError: true,
15
15
},
16
16
'@hey-api/schemas',
17
17
-
{
18
18
-
asClass: false,
19
19
-
classNameBuilder(name) {
20
20
-
return `${name}Service`;
21
21
-
},
22
22
-
methodNameBuilder(operation) {
23
23
-
return String(operation.id);
24
24
-
},
25
25
-
name: '@hey-api/sdk',
26
26
-
},
17
17
+
'@hey-api/sdk',
27
18
{
28
19
enums: 'javascript',
29
20
name: '@hey-api/typescript',
30
30
-
},
31
31
-
'@tanstack/angular-query-experimental',
32
32
-
{
33
33
-
asClass: true,
34
34
-
name: '@hey-api/angular-resource',
35
21
},
36
22
],
37
23
});
-309
examples/openapi-ts-angular/src/client/@hey-api/angular-resource.gen.ts
···
1
1
-
// This file is auto-generated by @hey-api/openapi-ts
2
2
-
3
3
-
import { Injectable, resource } from '@angular/core';
4
4
-
5
5
-
import type { Options } from '../sdk.gen';
6
6
-
import {
7
7
-
addPet,
8
8
-
createUser,
9
9
-
createUsersWithListInput,
10
10
-
deleteOrder,
11
11
-
deletePet,
12
12
-
deleteUser,
13
13
-
findPetsByStatus,
14
14
-
findPetsByTags,
15
15
-
getInventory,
16
16
-
getOrderById,
17
17
-
getPetById,
18
18
-
getUserByName,
19
19
-
loginUser,
20
20
-
logoutUser,
21
21
-
placeOrder,
22
22
-
updatePet,
23
23
-
updatePetWithForm,
24
24
-
updateUser,
25
25
-
uploadFile,
26
26
-
} from '../sdk.gen';
27
27
-
import type {
28
28
-
AddPetData,
29
29
-
CreateUserData,
30
30
-
CreateUsersWithListInputData,
31
31
-
DeleteOrderData,
32
32
-
DeletePetData,
33
33
-
DeleteUserData,
34
34
-
FindPetsByStatusData,
35
35
-
FindPetsByTagsData,
36
36
-
GetInventoryData,
37
37
-
GetOrderByIdData,
38
38
-
GetPetByIdData,
39
39
-
GetUserByNameData,
40
40
-
LoginUserData,
41
41
-
LogoutUserData,
42
42
-
PlaceOrderData,
43
43
-
UpdatePetData,
44
44
-
UpdatePetWithFormData,
45
45
-
UpdateUserData,
46
46
-
UploadFileData,
47
47
-
} from '../types.gen';
48
48
-
49
49
-
@Injectable({
50
50
-
providedIn: 'root',
51
51
-
})
52
52
-
export class PetServiceResources {
53
53
-
/**
54
54
-
* Add a new pet to the store.
55
55
-
* Add a new pet to the store.
56
56
-
*/
57
57
-
public addPetResource<ThrowOnError extends boolean = false>(
58
58
-
options: Options<AddPetData, ThrowOnError>,
59
59
-
) {
60
60
-
return resource({
61
61
-
loader: async ({ params }) => addPet(params),
62
62
-
params: () => options,
63
63
-
});
64
64
-
}
65
65
-
66
66
-
/**
67
67
-
* Update an existing pet.
68
68
-
* Update an existing pet by Id.
69
69
-
*/
70
70
-
public updatePetResource<ThrowOnError extends boolean = false>(
71
71
-
options: Options<UpdatePetData, ThrowOnError>,
72
72
-
) {
73
73
-
return resource({
74
74
-
loader: async ({ params }) => updatePet(params),
75
75
-
params: () => options,
76
76
-
});
77
77
-
}
78
78
-
79
79
-
/**
80
80
-
* Finds Pets by status.
81
81
-
* Multiple status values can be provided with comma separated strings.
82
82
-
*/
83
83
-
public findPetsByStatusResource<ThrowOnError extends boolean = false>(
84
84
-
options: Options<FindPetsByStatusData, ThrowOnError>,
85
85
-
) {
86
86
-
return resource({
87
87
-
loader: async ({ params }) => findPetsByStatus(params),
88
88
-
params: () => options,
89
89
-
});
90
90
-
}
91
91
-
92
92
-
/**
93
93
-
* Finds Pets by tags.
94
94
-
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
95
95
-
*/
96
96
-
public findPetsByTagsResource<ThrowOnError extends boolean = false>(
97
97
-
options: Options<FindPetsByTagsData, ThrowOnError>,
98
98
-
) {
99
99
-
return resource({
100
100
-
loader: async ({ params }) => findPetsByTags(params),
101
101
-
params: () => options,
102
102
-
});
103
103
-
}
104
104
-
105
105
-
/**
106
106
-
* Deletes a pet.
107
107
-
* Delete a pet.
108
108
-
*/
109
109
-
public deletePetResource<ThrowOnError extends boolean = false>(
110
110
-
options: Options<DeletePetData, ThrowOnError>,
111
111
-
) {
112
112
-
return resource({
113
113
-
loader: async ({ params }) => deletePet(params),
114
114
-
params: () => options,
115
115
-
});
116
116
-
}
117
117
-
118
118
-
/**
119
119
-
* Find pet by ID.
120
120
-
* Returns a single pet.
121
121
-
*/
122
122
-
public getPetByIdResource<ThrowOnError extends boolean = false>(
123
123
-
options: Options<GetPetByIdData, ThrowOnError>,
124
124
-
) {
125
125
-
return resource({
126
126
-
loader: async ({ params }) => getPetById(params),
127
127
-
params: () => options,
128
128
-
});
129
129
-
}
130
130
-
131
131
-
/**
132
132
-
* Updates a pet in the store with form data.
133
133
-
* Updates a pet resource based on the form data.
134
134
-
*/
135
135
-
public updatePetWithFormResource<ThrowOnError extends boolean = false>(
136
136
-
options: Options<UpdatePetWithFormData, ThrowOnError>,
137
137
-
) {
138
138
-
return resource({
139
139
-
loader: async ({ params }) => updatePetWithForm(params),
140
140
-
params: () => options,
141
141
-
});
142
142
-
}
143
143
-
144
144
-
/**
145
145
-
* Uploads an image.
146
146
-
* Upload image of the pet.
147
147
-
*/
148
148
-
public uploadFileResource<ThrowOnError extends boolean = false>(
149
149
-
options: Options<UploadFileData, ThrowOnError>,
150
150
-
) {
151
151
-
return resource({
152
152
-
loader: async ({ params }) => uploadFile(params),
153
153
-
params: () => options,
154
154
-
});
155
155
-
}
156
156
-
}
157
157
-
158
158
-
@Injectable({
159
159
-
providedIn: 'root',
160
160
-
})
161
161
-
export class StoreServiceResources {
162
162
-
/**
163
163
-
* Returns pet inventories by status.
164
164
-
* Returns a map of status codes to quantities.
165
165
-
*/
166
166
-
public getInventoryResource<ThrowOnError extends boolean = false>(
167
167
-
options?: Options<GetInventoryData, ThrowOnError>,
168
168
-
) {
169
169
-
return resource({
170
170
-
loader: async ({ params }) => getInventory(params),
171
171
-
params: () => options,
172
172
-
});
173
173
-
}
174
174
-
175
175
-
/**
176
176
-
* Place an order for a pet.
177
177
-
* Place a new order in the store.
178
178
-
*/
179
179
-
public placeOrderResource<ThrowOnError extends boolean = false>(
180
180
-
options?: Options<PlaceOrderData, ThrowOnError>,
181
181
-
) {
182
182
-
return resource({
183
183
-
loader: async ({ params }) => placeOrder(params),
184
184
-
params: () => options,
185
185
-
});
186
186
-
}
187
187
-
188
188
-
/**
189
189
-
* Delete purchase order by identifier.
190
190
-
* For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
191
191
-
*/
192
192
-
public deleteOrderResource<ThrowOnError extends boolean = false>(
193
193
-
options: Options<DeleteOrderData, ThrowOnError>,
194
194
-
) {
195
195
-
return resource({
196
196
-
loader: async ({ params }) => deleteOrder(params),
197
197
-
params: () => options,
198
198
-
});
199
199
-
}
200
200
-
201
201
-
/**
202
202
-
* Find purchase order by ID.
203
203
-
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
204
204
-
*/
205
205
-
public getOrderByIdResource<ThrowOnError extends boolean = false>(
206
206
-
options: Options<GetOrderByIdData, ThrowOnError>,
207
207
-
) {
208
208
-
return resource({
209
209
-
loader: async ({ params }) => getOrderById(params),
210
210
-
params: () => options,
211
211
-
});
212
212
-
}
213
213
-
}
214
214
-
215
215
-
@Injectable({
216
216
-
providedIn: 'root',
217
217
-
})
218
218
-
export class UserServiceResources {
219
219
-
/**
220
220
-
* Create user.
221
221
-
* This can only be done by the logged in user.
222
222
-
*/
223
223
-
public createUserResource<ThrowOnError extends boolean = false>(
224
224
-
options?: Options<CreateUserData, ThrowOnError>,
225
225
-
) {
226
226
-
return resource({
227
227
-
loader: async ({ params }) => createUser(params),
228
228
-
params: () => options,
229
229
-
});
230
230
-
}
231
231
-
232
232
-
/**
233
233
-
* Creates list of users with given input array.
234
234
-
* Creates list of users with given input array.
235
235
-
*/
236
236
-
public createUsersWithListInputResource<ThrowOnError extends boolean = false>(
237
237
-
options?: Options<CreateUsersWithListInputData, ThrowOnError>,
238
238
-
) {
239
239
-
return resource({
240
240
-
loader: async ({ params }) => createUsersWithListInput(params),
241
241
-
params: () => options,
242
242
-
});
243
243
-
}
244
244
-
245
245
-
/**
246
246
-
* Logs user into the system.
247
247
-
* Log into the system.
248
248
-
*/
249
249
-
public loginUserResource<ThrowOnError extends boolean = false>(
250
250
-
options?: Options<LoginUserData, ThrowOnError>,
251
251
-
) {
252
252
-
return resource({
253
253
-
loader: async ({ params }) => loginUser(params),
254
254
-
params: () => options,
255
255
-
});
256
256
-
}
257
257
-
258
258
-
/**
259
259
-
* Logs out current logged in user session.
260
260
-
* Log user out of the system.
261
261
-
*/
262
262
-
public logoutUserResource<ThrowOnError extends boolean = false>(
263
263
-
options?: Options<LogoutUserData, ThrowOnError>,
264
264
-
) {
265
265
-
return resource({
266
266
-
loader: async ({ params }) => logoutUser(params),
267
267
-
params: () => options,
268
268
-
});
269
269
-
}
270
270
-
271
271
-
/**
272
272
-
* Delete user resource.
273
273
-
* This can only be done by the logged in user.
274
274
-
*/
275
275
-
public deleteUserResource<ThrowOnError extends boolean = false>(
276
276
-
options: Options<DeleteUserData, ThrowOnError>,
277
277
-
) {
278
278
-
return resource({
279
279
-
loader: async ({ params }) => deleteUser(params),
280
280
-
params: () => options,
281
281
-
});
282
282
-
}
283
283
-
284
284
-
/**
285
285
-
* Get user by user name.
286
286
-
* Get user detail based on username.
287
287
-
*/
288
288
-
public getUserByNameResource<ThrowOnError extends boolean = false>(
289
289
-
options: Options<GetUserByNameData, ThrowOnError>,
290
290
-
) {
291
291
-
return resource({
292
292
-
loader: async ({ params }) => getUserByName(params),
293
293
-
params: () => options,
294
294
-
});
295
295
-
}
296
296
-
297
297
-
/**
298
298
-
* Update user resource.
299
299
-
* This can only be done by the logged in user.
300
300
-
*/
301
301
-
public updateUserResource<ThrowOnError extends boolean = false>(
302
302
-
options: Options<UpdateUserData, ThrowOnError>,
303
303
-
) {
304
304
-
return resource({
305
305
-
loader: async ({ params }) => updateUser(params),
306
306
-
params: () => options,
307
307
-
});
308
308
-
}
309
309
-
}
-687
examples/openapi-ts-angular/src/client/@tanstack/angular-query-experimental.gen.ts
···
1
1
-
// This file is auto-generated by @hey-api/openapi-ts
2
2
-
3
3
-
import {
4
4
-
type DefaultError,
5
5
-
type MutationOptions,
6
6
-
queryOptions,
7
7
-
} from '@tanstack/angular-query-experimental';
8
8
-
9
9
-
import { client as _heyApiClient } from '../client.gen';
10
10
-
import {
11
11
-
addPet,
12
12
-
createUser,
13
13
-
createUsersWithListInput,
14
14
-
deleteOrder,
15
15
-
deletePet,
16
16
-
deleteUser,
17
17
-
findPetsByStatus,
18
18
-
findPetsByTags,
19
19
-
getInventory,
20
20
-
getOrderById,
21
21
-
getPetById,
22
22
-
getUserByName,
23
23
-
loginUser,
24
24
-
logoutUser,
25
25
-
type Options,
26
26
-
placeOrder,
27
27
-
updatePet,
28
28
-
updatePetWithForm,
29
29
-
updateUser,
30
30
-
uploadFile,
31
31
-
} from '../sdk.gen';
32
32
-
import type {
33
33
-
AddPetData,
34
34
-
AddPetResponse,
35
35
-
CreateUserData,
36
36
-
CreateUserResponse,
37
37
-
CreateUsersWithListInputData,
38
38
-
CreateUsersWithListInputResponse,
39
39
-
DeleteOrderData,
40
40
-
DeletePetData,
41
41
-
DeleteUserData,
42
42
-
FindPetsByStatusData,
43
43
-
FindPetsByTagsData,
44
44
-
GetInventoryData,
45
45
-
GetOrderByIdData,
46
46
-
GetPetByIdData,
47
47
-
GetUserByNameData,
48
48
-
LoginUserData,
49
49
-
LogoutUserData,
50
50
-
PlaceOrderData,
51
51
-
PlaceOrderResponse,
52
52
-
UpdatePetData,
53
53
-
UpdatePetResponse,
54
54
-
UpdatePetWithFormData,
55
55
-
UpdatePetWithFormResponse,
56
56
-
UpdateUserData,
57
57
-
UploadFileData,
58
58
-
UploadFileResponse,
59
59
-
} from '../types.gen';
60
60
-
61
61
-
export type QueryKey<TOptions extends Options> = [
62
62
-
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
63
63
-
_id: string;
64
64
-
_infinite?: boolean;
65
65
-
tags?: ReadonlyArray<string>;
66
66
-
},
67
67
-
];
68
68
-
69
69
-
const createQueryKey = <TOptions extends Options>(
70
70
-
id: string,
71
71
-
options?: TOptions,
72
72
-
infinite?: boolean,
73
73
-
tags?: ReadonlyArray<string>,
74
74
-
): [QueryKey<TOptions>[0]] => {
75
75
-
const params: QueryKey<TOptions>[0] = {
76
76
-
_id: id,
77
77
-
baseUrl:
78
78
-
options?.baseUrl ||
79
79
-
(options?.client ?? _heyApiClient).getConfig().baseUrl,
80
80
-
} as QueryKey<TOptions>[0];
81
81
-
if (infinite) {
82
82
-
params._infinite = infinite;
83
83
-
}
84
84
-
if (tags) {
85
85
-
params.tags = tags;
86
86
-
}
87
87
-
if (options?.body) {
88
88
-
params.body = options.body;
89
89
-
}
90
90
-
if (options?.headers) {
91
91
-
params.headers = options.headers;
92
92
-
}
93
93
-
if (options?.path) {
94
94
-
params.path = options.path;
95
95
-
}
96
96
-
if (options?.query) {
97
97
-
params.query = options.query;
98
98
-
}
99
99
-
return [params];
100
100
-
};
101
101
-
102
102
-
export const addPetQueryKey = (options: Options<AddPetData>) =>
103
103
-
createQueryKey('addPet', options);
104
104
-
105
105
-
/**
106
106
-
* Add a new pet to the store.
107
107
-
* Add a new pet to the store.
108
108
-
*/
109
109
-
export const addPetOptions = (options: Options<AddPetData>) =>
110
110
-
queryOptions({
111
111
-
queryFn: async ({ queryKey, signal }) => {
112
112
-
const { data } = await addPet({
113
113
-
...options,
114
114
-
...queryKey[0],
115
115
-
signal,
116
116
-
throwOnError: true,
117
117
-
});
118
118
-
return data;
119
119
-
},
120
120
-
queryKey: addPetQueryKey(options),
121
121
-
});
122
122
-
123
123
-
/**
124
124
-
* Add a new pet to the store.
125
125
-
* Add a new pet to the store.
126
126
-
*/
127
127
-
export const addPetMutation = (
128
128
-
options?: Partial<Options<AddPetData>>,
129
129
-
): MutationOptions<AddPetResponse, DefaultError, Options<AddPetData>> => {
130
130
-
const mutationOptions: MutationOptions<
131
131
-
AddPetResponse,
132
132
-
DefaultError,
133
133
-
Options<AddPetData>
134
134
-
> = {
135
135
-
mutationFn: async (localOptions) => {
136
136
-
const { data } = await addPet({
137
137
-
...options,
138
138
-
...localOptions,
139
139
-
throwOnError: true,
140
140
-
});
141
141
-
return data;
142
142
-
},
143
143
-
};
144
144
-
return mutationOptions;
145
145
-
};
146
146
-
147
147
-
/**
148
148
-
* Update an existing pet.
149
149
-
* Update an existing pet by Id.
150
150
-
*/
151
151
-
export const updatePetMutation = (
152
152
-
options?: Partial<Options<UpdatePetData>>,
153
153
-
): MutationOptions<UpdatePetResponse, DefaultError, Options<UpdatePetData>> => {
154
154
-
const mutationOptions: MutationOptions<
155
155
-
UpdatePetResponse,
156
156
-
DefaultError,
157
157
-
Options<UpdatePetData>
158
158
-
> = {
159
159
-
mutationFn: async (localOptions) => {
160
160
-
const { data } = await updatePet({
161
161
-
...options,
162
162
-
...localOptions,
163
163
-
throwOnError: true,
164
164
-
});
165
165
-
return data;
166
166
-
},
167
167
-
};
168
168
-
return mutationOptions;
169
169
-
};
170
170
-
171
171
-
export const findPetsByStatusQueryKey = (
172
172
-
options: Options<FindPetsByStatusData>,
173
173
-
) => createQueryKey('findPetsByStatus', options);
174
174
-
175
175
-
/**
176
176
-
* Finds Pets by status.
177
177
-
* Multiple status values can be provided with comma separated strings.
178
178
-
*/
179
179
-
export const findPetsByStatusOptions = (
180
180
-
options: Options<FindPetsByStatusData>,
181
181
-
) =>
182
182
-
queryOptions({
183
183
-
queryFn: async ({ queryKey, signal }) => {
184
184
-
const { data } = await findPetsByStatus({
185
185
-
...options,
186
186
-
...queryKey[0],
187
187
-
signal,
188
188
-
throwOnError: true,
189
189
-
});
190
190
-
return data;
191
191
-
},
192
192
-
queryKey: findPetsByStatusQueryKey(options),
193
193
-
});
194
194
-
195
195
-
export const findPetsByTagsQueryKey = (options: Options<FindPetsByTagsData>) =>
196
196
-
createQueryKey('findPetsByTags', options);
197
197
-
198
198
-
/**
199
199
-
* Finds Pets by tags.
200
200
-
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
201
201
-
*/
202
202
-
export const findPetsByTagsOptions = (options: Options<FindPetsByTagsData>) =>
203
203
-
queryOptions({
204
204
-
queryFn: async ({ queryKey, signal }) => {
205
205
-
const { data } = await findPetsByTags({
206
206
-
...options,
207
207
-
...queryKey[0],
208
208
-
signal,
209
209
-
throwOnError: true,
210
210
-
});
211
211
-
return data;
212
212
-
},
213
213
-
queryKey: findPetsByTagsQueryKey(options),
214
214
-
});
215
215
-
216
216
-
/**
217
217
-
* Deletes a pet.
218
218
-
* Delete a pet.
219
219
-
*/
220
220
-
export const deletePetMutation = (
221
221
-
options?: Partial<Options<DeletePetData>>,
222
222
-
): MutationOptions<unknown, DefaultError, Options<DeletePetData>> => {
223
223
-
const mutationOptions: MutationOptions<
224
224
-
unknown,
225
225
-
DefaultError,
226
226
-
Options<DeletePetData>
227
227
-
> = {
228
228
-
mutationFn: async (localOptions) => {
229
229
-
const { data } = await deletePet({
230
230
-
...options,
231
231
-
...localOptions,
232
232
-
throwOnError: true,
233
233
-
});
234
234
-
return data;
235
235
-
},
236
236
-
};
237
237
-
return mutationOptions;
238
238
-
};
239
239
-
240
240
-
export const getPetByIdQueryKey = (options: Options<GetPetByIdData>) =>
241
241
-
createQueryKey('getPetById', options);
242
242
-
243
243
-
/**
244
244
-
* Find pet by ID.
245
245
-
* Returns a single pet.
246
246
-
*/
247
247
-
export const getPetByIdOptions = (options: Options<GetPetByIdData>) =>
248
248
-
queryOptions({
249
249
-
queryFn: async ({ queryKey, signal }) => {
250
250
-
const { data } = await getPetById({
251
251
-
...options,
252
252
-
...queryKey[0],
253
253
-
signal,
254
254
-
throwOnError: true,
255
255
-
});
256
256
-
return data;
257
257
-
},
258
258
-
queryKey: getPetByIdQueryKey(options),
259
259
-
});
260
260
-
261
261
-
export const updatePetWithFormQueryKey = (
262
262
-
options: Options<UpdatePetWithFormData>,
263
263
-
) => createQueryKey('updatePetWithForm', options);
264
264
-
265
265
-
/**
266
266
-
* Updates a pet in the store with form data.
267
267
-
* Updates a pet resource based on the form data.
268
268
-
*/
269
269
-
export const updatePetWithFormOptions = (
270
270
-
options: Options<UpdatePetWithFormData>,
271
271
-
) =>
272
272
-
queryOptions({
273
273
-
queryFn: async ({ queryKey, signal }) => {
274
274
-
const { data } = await updatePetWithForm({
275
275
-
...options,
276
276
-
...queryKey[0],
277
277
-
signal,
278
278
-
throwOnError: true,
279
279
-
});
280
280
-
return data;
281
281
-
},
282
282
-
queryKey: updatePetWithFormQueryKey(options),
283
283
-
});
284
284
-
285
285
-
/**
286
286
-
* Updates a pet in the store with form data.
287
287
-
* Updates a pet resource based on the form data.
288
288
-
*/
289
289
-
export const updatePetWithFormMutation = (
290
290
-
options?: Partial<Options<UpdatePetWithFormData>>,
291
291
-
): MutationOptions<
292
292
-
UpdatePetWithFormResponse,
293
293
-
DefaultError,
294
294
-
Options<UpdatePetWithFormData>
295
295
-
> => {
296
296
-
const mutationOptions: MutationOptions<
297
297
-
UpdatePetWithFormResponse,
298
298
-
DefaultError,
299
299
-
Options<UpdatePetWithFormData>
300
300
-
> = {
301
301
-
mutationFn: async (localOptions) => {
302
302
-
const { data } = await updatePetWithForm({
303
303
-
...options,
304
304
-
...localOptions,
305
305
-
throwOnError: true,
306
306
-
});
307
307
-
return data;
308
308
-
},
309
309
-
};
310
310
-
return mutationOptions;
311
311
-
};
312
312
-
313
313
-
export const uploadFileQueryKey = (options: Options<UploadFileData>) =>
314
314
-
createQueryKey('uploadFile', options);
315
315
-
316
316
-
/**
317
317
-
* Uploads an image.
318
318
-
* Upload image of the pet.
319
319
-
*/
320
320
-
export const uploadFileOptions = (options: Options<UploadFileData>) =>
321
321
-
queryOptions({
322
322
-
queryFn: async ({ queryKey, signal }) => {
323
323
-
const { data } = await uploadFile({
324
324
-
...options,
325
325
-
...queryKey[0],
326
326
-
signal,
327
327
-
throwOnError: true,
328
328
-
});
329
329
-
return data;
330
330
-
},
331
331
-
queryKey: uploadFileQueryKey(options),
332
332
-
});
333
333
-
334
334
-
/**
335
335
-
* Uploads an image.
336
336
-
* Upload image of the pet.
337
337
-
*/
338
338
-
export const uploadFileMutation = (
339
339
-
options?: Partial<Options<UploadFileData>>,
340
340
-
): MutationOptions<
341
341
-
UploadFileResponse,
342
342
-
DefaultError,
343
343
-
Options<UploadFileData>
344
344
-
> => {
345
345
-
const mutationOptions: MutationOptions<
346
346
-
UploadFileResponse,
347
347
-
DefaultError,
348
348
-
Options<UploadFileData>
349
349
-
> = {
350
350
-
mutationFn: async (localOptions) => {
351
351
-
const { data } = await uploadFile({
352
352
-
...options,
353
353
-
...localOptions,
354
354
-
throwOnError: true,
355
355
-
});
356
356
-
return data;
357
357
-
},
358
358
-
};
359
359
-
return mutationOptions;
360
360
-
};
361
361
-
362
362
-
export const getInventoryQueryKey = (options?: Options<GetInventoryData>) =>
363
363
-
createQueryKey('getInventory', options);
364
364
-
365
365
-
/**
366
366
-
* Returns pet inventories by status.
367
367
-
* Returns a map of status codes to quantities.
368
368
-
*/
369
369
-
export const getInventoryOptions = (options?: Options<GetInventoryData>) =>
370
370
-
queryOptions({
371
371
-
queryFn: async ({ queryKey, signal }) => {
372
372
-
const { data } = await getInventory({
373
373
-
...options,
374
374
-
...queryKey[0],
375
375
-
signal,
376
376
-
throwOnError: true,
377
377
-
});
378
378
-
return data;
379
379
-
},
380
380
-
queryKey: getInventoryQueryKey(options),
381
381
-
});
382
382
-
383
383
-
export const placeOrderQueryKey = (options?: Options<PlaceOrderData>) =>
384
384
-
createQueryKey('placeOrder', options);
385
385
-
386
386
-
/**
387
387
-
* Place an order for a pet.
388
388
-
* Place a new order in the store.
389
389
-
*/
390
390
-
export const placeOrderOptions = (options?: Options<PlaceOrderData>) =>
391
391
-
queryOptions({
392
392
-
queryFn: async ({ queryKey, signal }) => {
393
393
-
const { data } = await placeOrder({
394
394
-
...options,
395
395
-
...queryKey[0],
396
396
-
signal,
397
397
-
throwOnError: true,
398
398
-
});
399
399
-
return data;
400
400
-
},
401
401
-
queryKey: placeOrderQueryKey(options),
402
402
-
});
403
403
-
404
404
-
/**
405
405
-
* Place an order for a pet.
406
406
-
* Place a new order in the store.
407
407
-
*/
408
408
-
export const placeOrderMutation = (
409
409
-
options?: Partial<Options<PlaceOrderData>>,
410
410
-
): MutationOptions<
411
411
-
PlaceOrderResponse,
412
412
-
DefaultError,
413
413
-
Options<PlaceOrderData>
414
414
-
> => {
415
415
-
const mutationOptions: MutationOptions<
416
416
-
PlaceOrderResponse,
417
417
-
DefaultError,
418
418
-
Options<PlaceOrderData>
419
419
-
> = {
420
420
-
mutationFn: async (localOptions) => {
421
421
-
const { data } = await placeOrder({
422
422
-
...options,
423
423
-
...localOptions,
424
424
-
throwOnError: true,
425
425
-
});
426
426
-
return data;
427
427
-
},
428
428
-
};
429
429
-
return mutationOptions;
430
430
-
};
431
431
-
432
432
-
/**
433
433
-
* Delete purchase order by identifier.
434
434
-
* For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
435
435
-
*/
436
436
-
export const deleteOrderMutation = (
437
437
-
options?: Partial<Options<DeleteOrderData>>,
438
438
-
): MutationOptions<unknown, DefaultError, Options<DeleteOrderData>> => {
439
439
-
const mutationOptions: MutationOptions<
440
440
-
unknown,
441
441
-
DefaultError,
442
442
-
Options<DeleteOrderData>
443
443
-
> = {
444
444
-
mutationFn: async (localOptions) => {
445
445
-
const { data } = await deleteOrder({
446
446
-
...options,
447
447
-
...localOptions,
448
448
-
throwOnError: true,
449
449
-
});
450
450
-
return data;
451
451
-
},
452
452
-
};
453
453
-
return mutationOptions;
454
454
-
};
455
455
-
456
456
-
export const getOrderByIdQueryKey = (options: Options<GetOrderByIdData>) =>
457
457
-
createQueryKey('getOrderById', options);
458
458
-
459
459
-
/**
460
460
-
* Find purchase order by ID.
461
461
-
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
462
462
-
*/
463
463
-
export const getOrderByIdOptions = (options: Options<GetOrderByIdData>) =>
464
464
-
queryOptions({
465
465
-
queryFn: async ({ queryKey, signal }) => {
466
466
-
const { data } = await getOrderById({
467
467
-
...options,
468
468
-
...queryKey[0],
469
469
-
signal,
470
470
-
throwOnError: true,
471
471
-
});
472
472
-
return data;
473
473
-
},
474
474
-
queryKey: getOrderByIdQueryKey(options),
475
475
-
});
476
476
-
477
477
-
export const createUserQueryKey = (options?: Options<CreateUserData>) =>
478
478
-
createQueryKey('createUser', options);
479
479
-
480
480
-
/**
481
481
-
* Create user.
482
482
-
* This can only be done by the logged in user.
483
483
-
*/
484
484
-
export const createUserOptions = (options?: Options<CreateUserData>) =>
485
485
-
queryOptions({
486
486
-
queryFn: async ({ queryKey, signal }) => {
487
487
-
const { data } = await createUser({
488
488
-
...options,
489
489
-
...queryKey[0],
490
490
-
signal,
491
491
-
throwOnError: true,
492
492
-
});
493
493
-
return data;
494
494
-
},
495
495
-
queryKey: createUserQueryKey(options),
496
496
-
});
497
497
-
498
498
-
/**
499
499
-
* Create user.
500
500
-
* This can only be done by the logged in user.
501
501
-
*/
502
502
-
export const createUserMutation = (
503
503
-
options?: Partial<Options<CreateUserData>>,
504
504
-
): MutationOptions<
505
505
-
CreateUserResponse,
506
506
-
DefaultError,
507
507
-
Options<CreateUserData>
508
508
-
> => {
509
509
-
const mutationOptions: MutationOptions<
510
510
-
CreateUserResponse,
511
511
-
DefaultError,
512
512
-
Options<CreateUserData>
513
513
-
> = {
514
514
-
mutationFn: async (localOptions) => {
515
515
-
const { data } = await createUser({
516
516
-
...options,
517
517
-
...localOptions,
518
518
-
throwOnError: true,
519
519
-
});
520
520
-
return data;
521
521
-
},
522
522
-
};
523
523
-
return mutationOptions;
524
524
-
};
525
525
-
526
526
-
export const createUsersWithListInputQueryKey = (
527
527
-
options?: Options<CreateUsersWithListInputData>,
528
528
-
) => createQueryKey('createUsersWithListInput', options);
529
529
-
530
530
-
/**
531
531
-
* Creates list of users with given input array.
532
532
-
* Creates list of users with given input array.
533
533
-
*/
534
534
-
export const createUsersWithListInputOptions = (
535
535
-
options?: Options<CreateUsersWithListInputData>,
536
536
-
) =>
537
537
-
queryOptions({
538
538
-
queryFn: async ({ queryKey, signal }) => {
539
539
-
const { data } = await createUsersWithListInput({
540
540
-
...options,
541
541
-
...queryKey[0],
542
542
-
signal,
543
543
-
throwOnError: true,
544
544
-
});
545
545
-
return data;
546
546
-
},
547
547
-
queryKey: createUsersWithListInputQueryKey(options),
548
548
-
});
549
549
-
550
550
-
/**
551
551
-
* Creates list of users with given input array.
552
552
-
* Creates list of users with given input array.
553
553
-
*/
554
554
-
export const createUsersWithListInputMutation = (
555
555
-
options?: Partial<Options<CreateUsersWithListInputData>>,
556
556
-
): MutationOptions<
557
557
-
CreateUsersWithListInputResponse,
558
558
-
DefaultError,
559
559
-
Options<CreateUsersWithListInputData>
560
560
-
> => {
561
561
-
const mutationOptions: MutationOptions<
562
562
-
CreateUsersWithListInputResponse,
563
563
-
DefaultError,
564
564
-
Options<CreateUsersWithListInputData>
565
565
-
> = {
566
566
-
mutationFn: async (localOptions) => {
567
567
-
const { data } = await createUsersWithListInput({
568
568
-
...options,
569
569
-
...localOptions,
570
570
-
throwOnError: true,
571
571
-
});
572
572
-
return data;
573
573
-
},
574
574
-
};
575
575
-
return mutationOptions;
576
576
-
};
577
577
-
578
578
-
export const loginUserQueryKey = (options?: Options<LoginUserData>) =>
579
579
-
createQueryKey('loginUser', options);
580
580
-
581
581
-
/**
582
582
-
* Logs user into the system.
583
583
-
* Log into the system.
584
584
-
*/
585
585
-
export const loginUserOptions = (options?: Options<LoginUserData>) =>
586
586
-
queryOptions({
587
587
-
queryFn: async ({ queryKey, signal }) => {
588
588
-
const { data } = await loginUser({
589
589
-
...options,
590
590
-
...queryKey[0],
591
591
-
signal,
592
592
-
throwOnError: true,
593
593
-
});
594
594
-
return data;
595
595
-
},
596
596
-
queryKey: loginUserQueryKey(options),
597
597
-
});
598
598
-
599
599
-
export const logoutUserQueryKey = (options?: Options<LogoutUserData>) =>
600
600
-
createQueryKey('logoutUser', options);
601
601
-
602
602
-
/**
603
603
-
* Logs out current logged in user session.
604
604
-
* Log user out of the system.
605
605
-
*/
606
606
-
export const logoutUserOptions = (options?: Options<LogoutUserData>) =>
607
607
-
queryOptions({
608
608
-
queryFn: async ({ queryKey, signal }) => {
609
609
-
const { data } = await logoutUser({
610
610
-
...options,
611
611
-
...queryKey[0],
612
612
-
signal,
613
613
-
throwOnError: true,
614
614
-
});
615
615
-
return data;
616
616
-
},
617
617
-
queryKey: logoutUserQueryKey(options),
618
618
-
});
619
619
-
620
620
-
/**
621
621
-
* Delete user resource.
622
622
-
* This can only be done by the logged in user.
623
623
-
*/
624
624
-
export const deleteUserMutation = (
625
625
-
options?: Partial<Options<DeleteUserData>>,
626
626
-
): MutationOptions<unknown, DefaultError, Options<DeleteUserData>> => {
627
627
-
const mutationOptions: MutationOptions<
628
628
-
unknown,
629
629
-
DefaultError,
630
630
-
Options<DeleteUserData>
631
631
-
> = {
632
632
-
mutationFn: async (localOptions) => {
633
633
-
const { data } = await deleteUser({
634
634
-
...options,
635
635
-
...localOptions,
636
636
-
throwOnError: true,
637
637
-
});
638
638
-
return data;
639
639
-
},
640
640
-
};
641
641
-
return mutationOptions;
642
642
-
};
643
643
-
644
644
-
export const getUserByNameQueryKey = (options: Options<GetUserByNameData>) =>
645
645
-
createQueryKey('getUserByName', options);
646
646
-
647
647
-
/**
648
648
-
* Get user by user name.
649
649
-
* Get user detail based on username.
650
650
-
*/
651
651
-
export const getUserByNameOptions = (options: Options<GetUserByNameData>) =>
652
652
-
queryOptions({
653
653
-
queryFn: async ({ queryKey, signal }) => {
654
654
-
const { data } = await getUserByName({
655
655
-
...options,
656
656
-
...queryKey[0],
657
657
-
signal,
658
658
-
throwOnError: true,
659
659
-
});
660
660
-
return data;
661
661
-
},
662
662
-
queryKey: getUserByNameQueryKey(options),
663
663
-
});
664
664
-
665
665
-
/**
666
666
-
* Update user resource.
667
667
-
* This can only be done by the logged in user.
668
668
-
*/
669
669
-
export const updateUserMutation = (
670
670
-
options?: Partial<Options<UpdateUserData>>,
671
671
-
): MutationOptions<unknown, DefaultError, Options<UpdateUserData>> => {
672
672
-
const mutationOptions: MutationOptions<
673
673
-
unknown,
674
674
-
DefaultError,
675
675
-
Options<UpdateUserData>
676
676
-
> = {
677
677
-
mutationFn: async (localOptions) => {
678
678
-
const { data } = await updateUser({
679
679
-
...options,
680
680
-
...localOptions,
681
681
-
throwOnError: true,
682
682
-
});
683
683
-
return data;
684
684
-
},
685
685
-
};
686
686
-
return mutationOptions;
687
687
-
};