Skip to content

Commit d2e58c9

Browse files
committed
test: axiosImport 修改为 axiosImportPath
1 parent 710e968 commit d2e58c9

File tree

3 files changed

+54
-56
lines changed

3 files changed

+54
-56
lines changed

test/files/petStore3.types.txt

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type { OneOf } from "openapi-axios/helpers"
2-
import type { AxiosPromise, AxiosRequestConfig } from "axios";
3-
import { DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, resolveURL } from "openapi-axios/helpers";
4-
import axios from 'axios';
5-
const request = axios.request;
1+
import type { OneOf } from "pkg-name-for-test/client"
2+
import { DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, resolveURL } from "pkg-name-for-test/client";
3+
import type {AxiosRequestConfig, AxiosPromise} from "axios";
4+
import axios from "axios";
65
const BASE_URL = "/api/v3";
76
export type Address = {/**
87
* @example Palo Alto
@@ -140,7 +139,7 @@ export type AddPetResData = Pet;
140139
* @description Add a new pet to the store
141140
*/
142141
export async function addPet(data:AddPetReqData, config?:AxiosRequestConfig): AxiosPromise<AddPetResData> {
143-
return request({
142+
return axios({
144143
url: resolveURL(BASE_URL, `/pet`),
145144
method: POST,
146145
data,
@@ -155,7 +154,7 @@ export type UpdatePetResData = Pet;
155154
* @description Update an existing pet by Id
156155
*/
157156
export async function updatePet(data:UpdatePetReqData, config?:AxiosRequestConfig): AxiosPromise<UpdatePetResData> {
158-
return request({
157+
return axios({
159158
url: resolveURL(BASE_URL, `/pet`),
160159
method: PUT,
161160
data,
@@ -173,7 +172,7 @@ petId:number;};
173172
* @description
174173
*/
175174
export async function deletePet(path:DeletePetReqPath, config?:AxiosRequestConfig): AxiosPromise<never> {
176-
return request({
175+
return axios({
177176
url: resolveURL(BASE_URL, `/pet/${path.petId}`),
178177
method: DELETE,
179178
...config
@@ -191,7 +190,7 @@ export type GetPetByIdResData = Pet;
191190
* @description Returns a single pet
192191
*/
193192
export async function getPetById(path:GetPetByIdReqPath, config?:AxiosRequestConfig): AxiosPromise<GetPetByIdResData> {
194-
return request({
193+
return axios({
195194
url: resolveURL(BASE_URL, `/pet/${path.petId}`),
196195
method: GET,
197196
...config
@@ -216,7 +215,7 @@ status?:string;};
216215
* @description
217216
*/
218217
export async function updatePetWithForm(path:UpdatePetWithFormReqPath, params?:UpdatePetWithFormReqParams, config?:AxiosRequestConfig): AxiosPromise<never> {
219-
return request({
218+
return axios({
220219
url: resolveURL(BASE_URL, `/pet/${path.petId}`),
221220
method: POST,
222221
params,
@@ -240,7 +239,7 @@ export type UploadFileResData = ApiResponse;
240239
* @description
241240
*/
242241
export async function uploadFile(path:UploadFileReqPath, data:UploadFileReqData, params?:UploadFileReqParams, config?:AxiosRequestConfig): AxiosPromise<UploadFileResData> {
243-
return request({
242+
return axios({
244243
url: resolveURL(BASE_URL, `/pet/${path.petId}/uploadImage`),
245244
method: POST,
246245
params,
@@ -260,7 +259,7 @@ export type FindPetsByStatusResData = Array<Pet>;
260259
* @description Multiple status values can be provided with comma separated strings
261260
*/
262261
export async function findPetsByStatus(params?:FindPetsByStatusReqParams, config?:AxiosRequestConfig): AxiosPromise<FindPetsByStatusResData> {
263-
return request({
262+
return axios({
264263
url: resolveURL(BASE_URL, `/pet/findByStatus`),
265264
method: GET,
266265
params,
@@ -278,7 +277,7 @@ export type FindPetsByTagsResData = Array<Pet>;
278277
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
279278
*/
280279
export async function findPetsByTags(params?:FindPetsByTagsReqParams, config?:AxiosRequestConfig): AxiosPromise<FindPetsByTagsResData> {
281-
return request({
280+
return axios({
282281
url: resolveURL(BASE_URL, `/pet/findByTags`),
283282
method: GET,
284283
params,
@@ -295,7 +294,7 @@ export type GetInventoryResData = {/**
295294
* @description Returns a map of status codes to quantities
296295
*/
297296
export async function getInventory(config?:AxiosRequestConfig): AxiosPromise<GetInventoryResData> {
298-
return request({
297+
return axios({
299298
url: resolveURL(BASE_URL, `/store/inventory`),
300299
method: GET,
301300
...config
@@ -309,7 +308,7 @@ export type PlaceOrderResData = Order;
309308
* @description Place a new order in the store
310309
*/
311310
export async function placeOrder(data:PlaceOrderReqData, config?:AxiosRequestConfig): AxiosPromise<PlaceOrderResData> {
312-
return request({
311+
return axios({
313312
url: resolveURL(BASE_URL, `/store/order`),
314313
method: POST,
315314
data,
@@ -327,7 +326,7 @@ orderId:number;};
327326
* @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
328327
*/
329328
export async function deleteOrder(path:DeleteOrderReqPath, config?:AxiosRequestConfig): AxiosPromise<never> {
330-
return request({
329+
return axios({
331330
url: resolveURL(BASE_URL, `/store/order/${path.orderId}`),
332331
method: DELETE,
333332
...config
@@ -345,7 +344,7 @@ export type GetOrderByIdResData = Order;
345344
* @description For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
346345
*/
347346
export async function getOrderById(path:GetOrderByIdReqPath, config?:AxiosRequestConfig): AxiosPromise<GetOrderByIdResData> {
348-
return request({
347+
return axios({
349348
url: resolveURL(BASE_URL, `/store/order/${path.orderId}`),
350349
method: GET,
351350
...config
@@ -358,7 +357,7 @@ export type CreateUserReqData = User;
358357
* @description This can only be done by the logged in user.
359358
*/
360359
export async function createUser(data:CreateUserReqData, config?:AxiosRequestConfig): AxiosPromise<never> {
361-
return request({
360+
return axios({
362361
url: resolveURL(BASE_URL, `/user`),
363362
method: POST,
364363
data,
@@ -375,7 +374,7 @@ username:string;};
375374
* @description This can only be done by the logged in user.
376375
*/
377376
export async function deleteUser(path:DeleteUserReqPath, config?:AxiosRequestConfig): AxiosPromise<never> {
378-
return request({
377+
return axios({
379378
url: resolveURL(BASE_URL, `/user/${path.username}`),
380379
method: DELETE,
381380
...config
@@ -392,7 +391,7 @@ export type GetUserByNameResData = User;
392391
* @description
393392
*/
394393
export async function getUserByName(path:GetUserByNameReqPath, config?:AxiosRequestConfig): AxiosPromise<GetUserByNameResData> {
395-
return request({
394+
return axios({
396395
url: resolveURL(BASE_URL, `/user/${path.username}`),
397396
method: GET,
398397
...config
@@ -409,7 +408,7 @@ export type UpdateUserReqData = User;
409408
* @description This can only be done by the logged in user.
410409
*/
411410
export async function updateUser(path:UpdateUserReqPath, data:UpdateUserReqData, config?:AxiosRequestConfig): AxiosPromise<never> {
412-
return request({
411+
return axios({
413412
url: resolveURL(BASE_URL, `/user/${path.username}`),
414413
method: PUT,
415414
data,
@@ -424,7 +423,7 @@ export type CreateUsersWithListInputResData = User;
424423
* @description Creates list of users with given input array
425424
*/
426425
export async function createUsersWithListInput(data?:CreateUsersWithListInputReqData, config?:AxiosRequestConfig): AxiosPromise<CreateUsersWithListInputResData> {
427-
return request({
426+
return axios({
428427
url: resolveURL(BASE_URL, `/user/createWithList`),
429428
method: POST,
430429
data,
@@ -446,7 +445,7 @@ export type LoginUserResData = string;
446445
* @description
447446
*/
448447
export async function loginUser(params?:LoginUserReqParams, config?:AxiosRequestConfig): AxiosPromise<LoginUserResData> {
449-
return request({
448+
return axios({
450449
url: resolveURL(BASE_URL, `/user/login`),
451450
method: GET,
452451
params,
@@ -459,7 +458,7 @@ params,
459458
* @description
460459
*/
461460
export async function logoutUser(config?:AxiosRequestConfig): AxiosPromise<never> {
462-
return request({
461+
return axios({
463462
url: resolveURL(BASE_URL, `/user/logout`),
464463
method: GET,
465464
...config

test/printers/DocumentPrinter.test.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ test('DocumentPrinter', () => {
99
const text = printer.print();
1010
writeFile('petStore3.types.txt', text);
1111
expect(text).toMatchInlineSnapshot(`
12-
"import type { OneOf } from "openapi-axios/helpers"
13-
import type { AxiosPromise, AxiosRequestConfig } from "axios";
14-
import { DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, resolveURL } from "openapi-axios/helpers";
15-
import axios from 'axios';
16-
const request = axios.request;
12+
"import type { OneOf } from "pkg-name-for-test/client"
13+
import { DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, resolveURL } from "pkg-name-for-test/client";
14+
import type {AxiosRequestConfig, AxiosPromise} from "axios";
15+
import axios from "axios";
1716
const BASE_URL = "/api/v3";
1817
export type Address = {/**
1918
* @example Palo Alto
@@ -151,7 +150,7 @@ test('DocumentPrinter', () => {
151150
* @description Add a new pet to the store
152151
*/
153152
export async function addPet(data:AddPetReqData, config?:AxiosRequestConfig): AxiosPromise<AddPetResData> {
154-
return request({
153+
return axios({
155154
url: resolveURL(BASE_URL, \`/pet\`),
156155
method: POST,
157156
data,
@@ -166,7 +165,7 @@ test('DocumentPrinter', () => {
166165
* @description Update an existing pet by Id
167166
*/
168167
export async function updatePet(data:UpdatePetReqData, config?:AxiosRequestConfig): AxiosPromise<UpdatePetResData> {
169-
return request({
168+
return axios({
170169
url: resolveURL(BASE_URL, \`/pet\`),
171170
method: PUT,
172171
data,
@@ -184,7 +183,7 @@ test('DocumentPrinter', () => {
184183
* @description
185184
*/
186185
export async function deletePet(path:DeletePetReqPath, config?:AxiosRequestConfig): AxiosPromise<never> {
187-
return request({
186+
return axios({
188187
url: resolveURL(BASE_URL, \`/pet/\${path.petId}\`),
189188
method: DELETE,
190189
...config
@@ -202,7 +201,7 @@ test('DocumentPrinter', () => {
202201
* @description Returns a single pet
203202
*/
204203
export async function getPetById(path:GetPetByIdReqPath, config?:AxiosRequestConfig): AxiosPromise<GetPetByIdResData> {
205-
return request({
204+
return axios({
206205
url: resolveURL(BASE_URL, \`/pet/\${path.petId}\`),
207206
method: GET,
208207
...config
@@ -227,7 +226,7 @@ test('DocumentPrinter', () => {
227226
* @description
228227
*/
229228
export async function updatePetWithForm(path:UpdatePetWithFormReqPath, params?:UpdatePetWithFormReqParams, config?:AxiosRequestConfig): AxiosPromise<never> {
230-
return request({
229+
return axios({
231230
url: resolveURL(BASE_URL, \`/pet/\${path.petId}\`),
232231
method: POST,
233232
params,
@@ -251,7 +250,7 @@ test('DocumentPrinter', () => {
251250
* @description
252251
*/
253252
export async function uploadFile(path:UploadFileReqPath, data:UploadFileReqData, params?:UploadFileReqParams, config?:AxiosRequestConfig): AxiosPromise<UploadFileResData> {
254-
return request({
253+
return axios({
255254
url: resolveURL(BASE_URL, \`/pet/\${path.petId}/uploadImage\`),
256255
method: POST,
257256
params,
@@ -271,7 +270,7 @@ test('DocumentPrinter', () => {
271270
* @description Multiple status values can be provided with comma separated strings
272271
*/
273272
export async function findPetsByStatus(params?:FindPetsByStatusReqParams, config?:AxiosRequestConfig): AxiosPromise<FindPetsByStatusResData> {
274-
return request({
273+
return axios({
275274
url: resolveURL(BASE_URL, \`/pet/findByStatus\`),
276275
method: GET,
277276
params,
@@ -289,7 +288,7 @@ test('DocumentPrinter', () => {
289288
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
290289
*/
291290
export async function findPetsByTags(params?:FindPetsByTagsReqParams, config?:AxiosRequestConfig): AxiosPromise<FindPetsByTagsResData> {
292-
return request({
291+
return axios({
293292
url: resolveURL(BASE_URL, \`/pet/findByTags\`),
294293
method: GET,
295294
params,
@@ -306,7 +305,7 @@ test('DocumentPrinter', () => {
306305
* @description Returns a map of status codes to quantities
307306
*/
308307
export async function getInventory(config?:AxiosRequestConfig): AxiosPromise<GetInventoryResData> {
309-
return request({
308+
return axios({
310309
url: resolveURL(BASE_URL, \`/store/inventory\`),
311310
method: GET,
312311
...config
@@ -320,7 +319,7 @@ test('DocumentPrinter', () => {
320319
* @description Place a new order in the store
321320
*/
322321
export async function placeOrder(data:PlaceOrderReqData, config?:AxiosRequestConfig): AxiosPromise<PlaceOrderResData> {
323-
return request({
322+
return axios({
324323
url: resolveURL(BASE_URL, \`/store/order\`),
325324
method: POST,
326325
data,
@@ -338,7 +337,7 @@ test('DocumentPrinter', () => {
338337
* @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
339338
*/
340339
export async function deleteOrder(path:DeleteOrderReqPath, config?:AxiosRequestConfig): AxiosPromise<never> {
341-
return request({
340+
return axios({
342341
url: resolveURL(BASE_URL, \`/store/order/\${path.orderId}\`),
343342
method: DELETE,
344343
...config
@@ -356,7 +355,7 @@ test('DocumentPrinter', () => {
356355
* @description For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
357356
*/
358357
export async function getOrderById(path:GetOrderByIdReqPath, config?:AxiosRequestConfig): AxiosPromise<GetOrderByIdResData> {
359-
return request({
358+
return axios({
360359
url: resolveURL(BASE_URL, \`/store/order/\${path.orderId}\`),
361360
method: GET,
362361
...config
@@ -369,7 +368,7 @@ test('DocumentPrinter', () => {
369368
* @description This can only be done by the logged in user.
370369
*/
371370
export async function createUser(data:CreateUserReqData, config?:AxiosRequestConfig): AxiosPromise<never> {
372-
return request({
371+
return axios({
373372
url: resolveURL(BASE_URL, \`/user\`),
374373
method: POST,
375374
data,
@@ -386,7 +385,7 @@ test('DocumentPrinter', () => {
386385
* @description This can only be done by the logged in user.
387386
*/
388387
export async function deleteUser(path:DeleteUserReqPath, config?:AxiosRequestConfig): AxiosPromise<never> {
389-
return request({
388+
return axios({
390389
url: resolveURL(BASE_URL, \`/user/\${path.username}\`),
391390
method: DELETE,
392391
...config
@@ -403,7 +402,7 @@ test('DocumentPrinter', () => {
403402
* @description
404403
*/
405404
export async function getUserByName(path:GetUserByNameReqPath, config?:AxiosRequestConfig): AxiosPromise<GetUserByNameResData> {
406-
return request({
405+
return axios({
407406
url: resolveURL(BASE_URL, \`/user/\${path.username}\`),
408407
method: GET,
409408
...config
@@ -420,7 +419,7 @@ test('DocumentPrinter', () => {
420419
* @description This can only be done by the logged in user.
421420
*/
422421
export async function updateUser(path:UpdateUserReqPath, data:UpdateUserReqData, config?:AxiosRequestConfig): AxiosPromise<never> {
423-
return request({
422+
return axios({
424423
url: resolveURL(BASE_URL, \`/user/\${path.username}\`),
425424
method: PUT,
426425
data,
@@ -435,7 +434,7 @@ test('DocumentPrinter', () => {
435434
* @description Creates list of users with given input array
436435
*/
437436
export async function createUsersWithListInput(data?:CreateUsersWithListInputReqData, config?:AxiosRequestConfig): AxiosPromise<CreateUsersWithListInputResData> {
438-
return request({
437+
return axios({
439438
url: resolveURL(BASE_URL, \`/user/createWithList\`),
440439
method: POST,
441440
data,
@@ -457,7 +456,7 @@ test('DocumentPrinter', () => {
457456
* @description
458457
*/
459458
export async function loginUser(params?:LoginUserReqParams, config?:AxiosRequestConfig): AxiosPromise<LoginUserResData> {
460-
return request({
459+
return axios({
461460
url: resolveURL(BASE_URL, \`/user/login\`),
462461
method: GET,
463462
params,
@@ -470,7 +469,7 @@ test('DocumentPrinter', () => {
470469
* @description
471470
*/
472471
export async function logoutUser(config?:AxiosRequestConfig): AxiosPromise<never> {
473-
return request({
472+
return axios({
474473
url: resolveURL(BASE_URL, \`/user/logout\`),
475474
method: GET,
476475
...config

0 commit comments

Comments
 (0)