@@ -2,10 +2,9 @@ import axios from "axios";
2
2
import { http , HttpResponse } from "msw" ;
3
3
import { setupServer } from "msw/node" ;
4
4
import { Fetcher } from "openapi-typescript-fetch" ;
5
- import { nanoid } from "nanoid" ;
6
5
import superagent from "superagent" ;
7
6
import { afterAll , bench , describe } from "vitest" ;
8
- import createClient from "../dist/index.js" ;
7
+ import createClient , { createPathBasedClient } from "../dist/index.js" ;
9
8
import * as openapiTSCodegen from "./fixtures/openapi-typescript-codegen.min.js" ;
10
9
11
10
const BASE_URL = "https://api.test.local" ;
@@ -41,6 +40,10 @@ describe("setup", () => {
41
40
createClient ( { baseUrl : BASE_URL } ) ;
42
41
} ) ;
43
42
43
+ bench ( "openapi-fetch (path based)" , async ( ) => {
44
+ createPathBasedClient ( { baseUrl : BASE_URL } ) ;
45
+ } ) ;
46
+
44
47
bench ( "openapi-typescript-fetch" , async ( ) => {
45
48
const fetcher = Fetcher . for ( ) ;
46
49
fetcher . configure ( {
@@ -60,6 +63,7 @@ describe("setup", () => {
60
63
61
64
describe ( "get (only URL)" , ( ) => {
62
65
const openapiFetch = createClient ( { baseUrl : BASE_URL } ) ;
66
+ const openapiFetchPath = createPathBasedClient ( { baseUrl : BASE_URL } ) ;
63
67
const openapiTSFetch = Fetcher . for ( ) ;
64
68
openapiTSFetch . configure ( {
65
69
baseUrl : BASE_URL ,
@@ -74,6 +78,10 @@ describe("get (only URL)", () => {
74
78
await openapiFetch . GET ( "/url" ) ;
75
79
} ) ;
76
80
81
+ bench ( "openapi-fetch (path based)" , async ( ) => {
82
+ await openapiFetchPath [ "/url" ] . GET ( ) ;
83
+ } ) ;
84
+
77
85
bench ( "openapi-typescript-fetch" , async ( ) => {
78
86
await openapiTSFetchGET ( ) ;
79
87
} ) ;
@@ -96,6 +104,10 @@ describe("get (headers)", () => {
96
104
baseUrl : BASE_URL ,
97
105
headers : { "x-base-header" : 123 } ,
98
106
} ) ;
107
+ const openapiFetchPath = createPathBasedClient ( {
108
+ baseUrl : BASE_URL ,
109
+ headers : { "x-base-header" : 123 } ,
110
+ } ) ;
99
111
const openapiTSFetch = Fetcher . for ( ) ;
100
112
openapiTSFetch . configure ( {
101
113
baseUrl : BASE_URL ,
@@ -113,6 +125,12 @@ describe("get (headers)", () => {
113
125
} ) ;
114
126
} ) ;
115
127
128
+ bench ( "openapi-fetch (path based)" , async ( ) => {
129
+ await openapiFetchPath [ "/url" ] . GET ( {
130
+ headers : { "x-header-1" : 123 , "x-header-2" : 456 } ,
131
+ } ) ;
132
+ } ) ;
133
+
116
134
bench ( "openapi-typescript-fetch" , async ( ) => {
117
135
await openapiTSFetchGET ( null , {
118
136
headers : { "x-header-1" : 123 , "x-header-2" : 456 } ,
0 commit comments