pet.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* eslint-disable */
  2. // @ts-ignore
  3. import request from '@/utils/request';
  4. import { CustomRequestOptions } from '@/interceptors/request';
  5. import * as API from './types';
  6. /** Update an existing pet PUT /pet */
  7. export async function updatePet({
  8. body,
  9. options,
  10. }: {
  11. body: API.Pet;
  12. options?: CustomRequestOptions;
  13. }) {
  14. return request<unknown>('/pet', {
  15. method: 'PUT',
  16. headers: {
  17. 'Content-Type': 'application/json',
  18. },
  19. data: body,
  20. ...(options || {}),
  21. });
  22. }
  23. /** Add a new pet to the store POST /pet */
  24. export async function addPet({
  25. body,
  26. options,
  27. }: {
  28. body: API.Pet;
  29. options?: CustomRequestOptions;
  30. }) {
  31. return request<unknown>('/pet', {
  32. method: 'POST',
  33. headers: {
  34. 'Content-Type': 'application/json',
  35. },
  36. data: body,
  37. ...(options || {}),
  38. });
  39. }
  40. /** Find pet by ID Returns a single pet GET /pet/${param0} */
  41. export async function getPetById({
  42. params,
  43. options,
  44. }: {
  45. // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  46. params: API.getPetByIdParams;
  47. options?: CustomRequestOptions;
  48. }) {
  49. const { petId: param0, ...queryParams } = params;
  50. return request<API.Pet>(`/pet/${param0}`, {
  51. method: 'GET',
  52. params: { ...queryParams },
  53. ...(options || {}),
  54. });
  55. }
  56. /** Updates a pet in the store with form data POST /pet/${param0} */
  57. export async function updatePetWithForm({
  58. params,
  59. body,
  60. options,
  61. }: {
  62. // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  63. params: API.updatePetWithFormParams;
  64. body: {
  65. /** Updated name of the pet */
  66. name?: string;
  67. /** Updated status of the pet */
  68. status?: string;
  69. };
  70. options?: CustomRequestOptions;
  71. }) {
  72. const { petId: param0, ...queryParams } = params;
  73. return request<unknown>(`/pet/${param0}`, {
  74. method: 'POST',
  75. headers: {
  76. 'Content-Type': 'application/x-www-form-urlencoded',
  77. },
  78. params: { ...queryParams },
  79. data: body,
  80. ...(options || {}),
  81. });
  82. }
  83. /** Deletes a pet DELETE /pet/${param0} */
  84. export async function deletePet({
  85. params,
  86. options,
  87. }: {
  88. // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  89. params: API.deletePetParams;
  90. options?: CustomRequestOptions;
  91. }) {
  92. const { petId: param0, ...queryParams } = params;
  93. return request<unknown>(`/pet/${param0}`, {
  94. method: 'DELETE',
  95. params: { ...queryParams },
  96. ...(options || {}),
  97. });
  98. }
  99. /** uploads an image POST /pet/${param0}/uploadImage */
  100. export async function uploadFile({
  101. params,
  102. body,
  103. file,
  104. options,
  105. }: {
  106. // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  107. params: API.uploadFileParams;
  108. body: {
  109. /** Additional data to pass to server */
  110. additionalMetadata?: string;
  111. };
  112. file?: File;
  113. options?: CustomRequestOptions;
  114. }) {
  115. const { petId: param0, ...queryParams } = params;
  116. const formData = new FormData();
  117. if (file) {
  118. formData.append('file', file);
  119. }
  120. Object.keys(body).forEach((ele) => {
  121. const item = (body as { [key: string]: any })[ele];
  122. if (item !== undefined && item !== null) {
  123. if (typeof item === 'object' && !(item instanceof File)) {
  124. if (item instanceof Array) {
  125. item.forEach((f) => formData.append(ele, f || ''));
  126. } else {
  127. formData.append(ele, JSON.stringify(item));
  128. }
  129. } else {
  130. formData.append(ele, item);
  131. }
  132. }
  133. });
  134. return request<API.ApiResponse>(`/pet/${param0}/uploadImage`, {
  135. method: 'POST',
  136. headers: {
  137. 'Content-Type': 'multipart/form-data',
  138. },
  139. params: { ...queryParams },
  140. data: formData,
  141. ...(options || {}),
  142. });
  143. }
  144. /** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */
  145. export async function findPetsByStatus({
  146. params,
  147. options,
  148. }: {
  149. // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  150. params: API.findPetsByStatusParams;
  151. options?: CustomRequestOptions;
  152. }) {
  153. return request<API.Pet[]>('/pet/findByStatus', {
  154. method: 'GET',
  155. params: {
  156. ...params,
  157. },
  158. ...(options || {}),
  159. });
  160. }
  161. /** Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */
  162. export async function findPetsByTags({
  163. params,
  164. options,
  165. }: {
  166. // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  167. params: API.findPetsByTagsParams;
  168. options?: CustomRequestOptions;
  169. }) {
  170. return request<API.Pet[]>('/pet/findByTags', {
  171. method: 'GET',
  172. params: {
  173. ...params,
  174. },
  175. ...(options || {}),
  176. });
  177. }