fork of hey-api/openapi-ts because I need some additional things
1// This file is auto-generated by @hey-api/openapi-ts
2
3import type { Client, Options as Options2, TDataShape } from './client';
4import { client } from './client.gen';
5import type {
6 AddPetData,
7 AddPetErrors,
8 AddPetResponses,
9 CreateUserData,
10 CreateUserErrors,
11 CreateUserResponses,
12 CreateUsersWithListInputData,
13 CreateUsersWithListInputErrors,
14 CreateUsersWithListInputResponses,
15 DeleteOrderData,
16 DeleteOrderErrors,
17 DeleteOrderResponses,
18 DeletePetData,
19 DeletePetErrors,
20 DeletePetResponses,
21 DeleteUserData,
22 DeleteUserErrors,
23 DeleteUserResponses,
24 FindPetsByStatusData,
25 FindPetsByStatusErrors,
26 FindPetsByStatusResponses,
27 FindPetsByTagsData,
28 FindPetsByTagsErrors,
29 FindPetsByTagsResponses,
30 GetInventoryData,
31 GetInventoryErrors,
32 GetInventoryResponses,
33 GetOrderByIdData,
34 GetOrderByIdErrors,
35 GetOrderByIdResponses,
36 GetPetByIdData,
37 GetPetByIdErrors,
38 GetPetByIdResponses,
39 GetUserByNameData,
40 GetUserByNameErrors,
41 GetUserByNameResponses,
42 LoginUserData,
43 LoginUserErrors,
44 LoginUserResponses,
45 LogoutUserData,
46 LogoutUserErrors,
47 LogoutUserResponses,
48 PlaceOrderData,
49 PlaceOrderErrors,
50 PlaceOrderResponses,
51 UpdatePetData,
52 UpdatePetErrors,
53 UpdatePetResponses,
54 UpdatePetWithFormData,
55 UpdatePetWithFormErrors,
56 UpdatePetWithFormResponses,
57 UpdateUserData,
58 UpdateUserErrors,
59 UpdateUserResponses,
60 UploadFileData,
61 UploadFileErrors,
62 UploadFileResponses,
63} from './types.gen';
64
65export type Options<
66 TData extends TDataShape = TDataShape,
67 ThrowOnError extends boolean = boolean,
68> = Options2<TData, ThrowOnError> & {
69 /**
70 * You can provide a client instance returned by `createClient()` instead of
71 * individual options. This might be also useful if you want to implement a
72 * custom client.
73 */
74 client?: Client;
75 /**
76 * You can pass arbitrary values through the `meta` object. This can be
77 * used to access values that aren't defined as part of the SDK function.
78 */
79 meta?: Record<string, unknown>;
80};
81
82/**
83 * Add a new pet to the store.
84 *
85 * Add a new pet to the store.
86 */
87export const addPet = <ThrowOnError extends boolean = false>(
88 options: Options<AddPetData, ThrowOnError>,
89) =>
90 (options.client ?? client).post<AddPetResponses, AddPetErrors, ThrowOnError>({
91 security: [{ scheme: 'bearer', type: 'http' }],
92 url: '/pet',
93 ...options,
94 headers: {
95 'Content-Type': 'application/json',
96 ...options.headers,
97 },
98 });
99
100/**
101 * Update an existing pet.
102 *
103 * Update an existing pet by Id.
104 */
105export const updatePet = <ThrowOnError extends boolean = false>(
106 options: Options<UpdatePetData, ThrowOnError>,
107) =>
108 (options.client ?? client).put<
109 UpdatePetResponses,
110 UpdatePetErrors,
111 ThrowOnError
112 >({
113 security: [{ scheme: 'bearer', type: 'http' }],
114 url: '/pet',
115 ...options,
116 headers: {
117 'Content-Type': 'application/json',
118 ...options.headers,
119 },
120 });
121
122/**
123 * Finds Pets by status.
124 *
125 * Multiple status values can be provided with comma separated strings.
126 */
127export const findPetsByStatus = <ThrowOnError extends boolean = false>(
128 options: Options<FindPetsByStatusData, ThrowOnError>,
129) =>
130 (options.client ?? client).get<
131 FindPetsByStatusResponses,
132 FindPetsByStatusErrors,
133 ThrowOnError
134 >({
135 security: [{ scheme: 'bearer', type: 'http' }],
136 url: '/pet/findByStatus',
137 ...options,
138 });
139
140/**
141 * Finds Pets by tags.
142 *
143 * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
144 */
145export const findPetsByTags = <ThrowOnError extends boolean = false>(
146 options: Options<FindPetsByTagsData, ThrowOnError>,
147) =>
148 (options.client ?? client).get<
149 FindPetsByTagsResponses,
150 FindPetsByTagsErrors,
151 ThrowOnError
152 >({
153 security: [{ scheme: 'bearer', type: 'http' }],
154 url: '/pet/findByTags',
155 ...options,
156 });
157
158/**
159 * Deletes a pet.
160 *
161 * Delete a pet.
162 */
163export const deletePet = <ThrowOnError extends boolean = false>(
164 options: Options<DeletePetData, ThrowOnError>,
165) =>
166 (options.client ?? client).delete<
167 DeletePetResponses,
168 DeletePetErrors,
169 ThrowOnError
170 >({
171 security: [{ scheme: 'bearer', type: 'http' }],
172 url: '/pet/{petId}',
173 ...options,
174 });
175
176/**
177 * Find pet by ID.
178 *
179 * Returns a single pet.
180 */
181export const getPetById = <ThrowOnError extends boolean = false>(
182 options: Options<GetPetByIdData, ThrowOnError>,
183) =>
184 (options.client ?? client).get<
185 GetPetByIdResponses,
186 GetPetByIdErrors,
187 ThrowOnError
188 >({
189 security: [
190 { name: 'api_key', type: 'apiKey' },
191 { scheme: 'bearer', type: 'http' },
192 ],
193 url: '/pet/{petId}',
194 ...options,
195 });
196
197/**
198 * Updates a pet in the store with form data.
199 *
200 * Updates a pet resource based on the form data.
201 */
202export const updatePetWithForm = <ThrowOnError extends boolean = false>(
203 options: Options<UpdatePetWithFormData, ThrowOnError>,
204) =>
205 (options.client ?? client).post<
206 UpdatePetWithFormResponses,
207 UpdatePetWithFormErrors,
208 ThrowOnError
209 >({
210 security: [{ scheme: 'bearer', type: 'http' }],
211 url: '/pet/{petId}',
212 ...options,
213 });
214
215/**
216 * Uploads an image.
217 *
218 * Upload image of the pet.
219 */
220export const uploadFile = <ThrowOnError extends boolean = false>(
221 options: Options<UploadFileData, ThrowOnError>,
222) =>
223 (options.client ?? client).post<
224 UploadFileResponses,
225 UploadFileErrors,
226 ThrowOnError
227 >({
228 bodySerializer: null,
229 security: [{ scheme: 'bearer', type: 'http' }],
230 url: '/pet/{petId}/uploadImage',
231 ...options,
232 headers: {
233 'Content-Type': 'application/octet-stream',
234 ...options.headers,
235 },
236 });
237
238/**
239 * Returns pet inventories by status.
240 *
241 * Returns a map of status codes to quantities.
242 */
243export const getInventory = <ThrowOnError extends boolean = false>(
244 options?: Options<GetInventoryData, ThrowOnError>,
245) =>
246 (options?.client ?? client).get<
247 GetInventoryResponses,
248 GetInventoryErrors,
249 ThrowOnError
250 >({
251 security: [{ name: 'api_key', type: 'apiKey' }],
252 url: '/store/inventory',
253 ...options,
254 });
255
256/**
257 * Place an order for a pet.
258 *
259 * Place a new order in the store.
260 */
261export const placeOrder = <ThrowOnError extends boolean = false>(
262 options?: Options<PlaceOrderData, ThrowOnError>,
263) =>
264 (options?.client ?? client).post<
265 PlaceOrderResponses,
266 PlaceOrderErrors,
267 ThrowOnError
268 >({
269 url: '/store/order',
270 ...options,
271 headers: {
272 'Content-Type': 'application/json',
273 ...options?.headers,
274 },
275 });
276
277/**
278 * Delete purchase order by identifier.
279 *
280 * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
281 */
282export const deleteOrder = <ThrowOnError extends boolean = false>(
283 options: Options<DeleteOrderData, ThrowOnError>,
284) =>
285 (options.client ?? client).delete<
286 DeleteOrderResponses,
287 DeleteOrderErrors,
288 ThrowOnError
289 >({ url: '/store/order/{orderId}', ...options });
290
291/**
292 * Find purchase order by ID.
293 *
294 * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
295 */
296export const getOrderById = <ThrowOnError extends boolean = false>(
297 options: Options<GetOrderByIdData, ThrowOnError>,
298) =>
299 (options.client ?? client).get<
300 GetOrderByIdResponses,
301 GetOrderByIdErrors,
302 ThrowOnError
303 >({ url: '/store/order/{orderId}', ...options });
304
305/**
306 * Create user.
307 *
308 * This can only be done by the logged in user.
309 */
310export const createUser = <ThrowOnError extends boolean = false>(
311 options?: Options<CreateUserData, ThrowOnError>,
312) =>
313 (options?.client ?? client).post<
314 CreateUserResponses,
315 CreateUserErrors,
316 ThrowOnError
317 >({
318 url: '/user',
319 ...options,
320 headers: {
321 'Content-Type': 'application/json',
322 ...options?.headers,
323 },
324 });
325
326/**
327 * Creates list of users with given input array.
328 *
329 * Creates list of users with given input array.
330 */
331export const createUsersWithListInput = <ThrowOnError extends boolean = false>(
332 options?: Options<CreateUsersWithListInputData, ThrowOnError>,
333) =>
334 (options?.client ?? client).post<
335 CreateUsersWithListInputResponses,
336 CreateUsersWithListInputErrors,
337 ThrowOnError
338 >({
339 url: '/user/createWithList',
340 ...options,
341 headers: {
342 'Content-Type': 'application/json',
343 ...options?.headers,
344 },
345 });
346
347/**
348 * Logs user into the system.
349 *
350 * Log into the system.
351 */
352export const loginUser = <ThrowOnError extends boolean = false>(
353 options?: Options<LoginUserData, ThrowOnError>,
354) =>
355 (options?.client ?? client).get<
356 LoginUserResponses,
357 LoginUserErrors,
358 ThrowOnError
359 >({ url: '/user/login', ...options });
360
361/**
362 * Logs out current logged in user session.
363 *
364 * Log user out of the system.
365 */
366export const logoutUser = <ThrowOnError extends boolean = false>(
367 options?: Options<LogoutUserData, ThrowOnError>,
368) =>
369 (options?.client ?? client).get<
370 LogoutUserResponses,
371 LogoutUserErrors,
372 ThrowOnError
373 >({ url: '/user/logout', ...options });
374
375/**
376 * Delete user resource.
377 *
378 * This can only be done by the logged in user.
379 */
380export const deleteUser = <ThrowOnError extends boolean = false>(
381 options: Options<DeleteUserData, ThrowOnError>,
382) =>
383 (options.client ?? client).delete<
384 DeleteUserResponses,
385 DeleteUserErrors,
386 ThrowOnError
387 >({ url: '/user/{username}', ...options });
388
389/**
390 * Get user by user name.
391 *
392 * Get user detail based on username.
393 */
394export const getUserByName = <ThrowOnError extends boolean = false>(
395 options: Options<GetUserByNameData, ThrowOnError>,
396) =>
397 (options.client ?? client).get<
398 GetUserByNameResponses,
399 GetUserByNameErrors,
400 ThrowOnError
401 >({ url: '/user/{username}', ...options });
402
403/**
404 * Update user resource.
405 *
406 * This can only be done by the logged in user.
407 */
408export const updateUser = <ThrowOnError extends boolean = false>(
409 options: Options<UpdateUserData, ThrowOnError>,
410) =>
411 (options.client ?? client).put<
412 UpdateUserResponses,
413 UpdateUserErrors,
414 ThrowOnError
415 >({
416 url: '/user/{username}',
417 ...options,
418 headers: {
419 'Content-Type': 'application/json',
420 ...options.headers,
421 },
422 });