@@ -40,8 +40,8 @@ export type RequestBodyObj<O> = O extends { requestBody: any } ? O["requestBody"
40
40
export type RequestBodyContent < O > = undefined extends RequestBodyObj < O > ? FilterKeys < NonNullable < RequestBodyObj < O > > , "content" > | undefined : FilterKeys < RequestBodyObj < O > , "content" > ;
41
41
export type RequestBodyJSON < O > = FilterKeys < RequestBodyContent < O > , JSONLike > extends never ? FilterKeys < NonNullable < RequestBodyContent < O > > , JSONLike > | undefined : FilterKeys < RequestBodyContent < O > , JSONLike > ;
42
42
export type RequestBody < O > = undefined extends RequestBodyJSON < O > ? { body ?: RequestBodyJSON < O > } : { body : RequestBodyJSON < O > } ;
43
- export type QuerySerializer < O > = { querySerializer ?: ( query : O extends { parameters : { query : any } } ? O [ "parameters" ] [ "query" ] : Record < string , unknown > ) => string } ;
44
- export type FetchOptions < T > = Params < T > & RequestBody < T > & Omit < RequestInit , "body" > & QuerySerializer < T > ;
43
+ export type QuerySerializer < O > = ( query : O extends { parameters : { query : any } } ? O [ "parameters" ] [ "query" ] : Record < string , unknown > ) => string ;
44
+ export type FetchOptions < T > = Params < T > & RequestBody < T > & Omit < RequestInit , "body" > & { querySerializer ?: QuerySerializer < T > } ;
45
45
export type Success < O > = FilterKeys < FilterKeys < O , OkStatus > , "content" > ;
46
46
export type Error < O > = FilterKeys < FilterKeys < O , ErrorStatus > , "content" > ;
47
47
export type FetchResponse < T > =
@@ -99,15 +99,15 @@ export default function createClient<Paths extends {}>(options?: ClientOptions)
99
99
} ,
100
100
/** Call a POST endpoint */
101
101
async post < P extends PathsWith < Paths , "post" > > ( url : P , init : FetchOptions < FilterKeys < Paths [ P ] , "post" > > ) {
102
- return coreFetch < P , "put " > ( url , { ...init , method : "POST" } as any ) ;
102
+ return coreFetch < P , "post " > ( url , { ...init , method : "POST" } as any ) ;
103
103
} ,
104
104
/** Call a DELETE endpoint */
105
105
async del < P extends PathsWith < Paths , "delete" > > ( url : P , init : FetchOptions < FilterKeys < Paths [ P ] , "delete" > > ) {
106
106
return coreFetch < P , "delete" > ( url , { ...init , method : "DELETE" } as any ) ;
107
107
} ,
108
108
/** Call a OPTIONS endpoint */
109
109
async options < P extends PathsWith < Paths , "options" > > ( url : P , init : FetchOptions < FilterKeys < Paths [ P ] , "options" > > ) {
110
- return coreFetch < P , "delete " > ( url , { ...init , method : "OPTIONS" } as any ) ;
110
+ return coreFetch < P , "options " > ( url , { ...init , method : "OPTIONS" } as any ) ;
111
111
} ,
112
112
/** Call a HEAD endpoint */
113
113
async head < P extends PathsWith < Paths , "head" > > ( url : P , init : FetchOptions < FilterKeys < Paths [ P ] , "head" > > ) {
0 commit comments