@@ -40,8 +40,8 @@ export type RequestBodyObj<O> = O extends { requestBody: any } ? O["requestBody"
4040export type RequestBodyContent < O > = undefined extends RequestBodyObj < O > ? FilterKeys < NonNullable < RequestBodyObj < O > > , "content" > | undefined : FilterKeys < RequestBodyObj < O > , "content" > ;
4141export type RequestBodyJSON < O > = FilterKeys < RequestBodyContent < O > , JSONLike > extends never ? FilterKeys < NonNullable < RequestBodyContent < O > > , JSONLike > | undefined : FilterKeys < RequestBodyContent < O > , JSONLike > ;
4242export 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 > } ;
4545export type Success < O > = FilterKeys < FilterKeys < O , OkStatus > , "content" > ;
4646export type Error < O > = FilterKeys < FilterKeys < O , ErrorStatus > , "content" > ;
4747export type FetchResponse < T > =
@@ -99,15 +99,15 @@ export default function createClient<Paths extends {}>(options?: ClientOptions)
9999 } ,
100100 /** Call a POST endpoint */
101101 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 ) ;
103103 } ,
104104 /** Call a DELETE endpoint */
105105 async del < P extends PathsWith < Paths , "delete" > > ( url : P , init : FetchOptions < FilterKeys < Paths [ P ] , "delete" > > ) {
106106 return coreFetch < P , "delete" > ( url , { ...init , method : "DELETE" } as any ) ;
107107 } ,
108108 /** Call a OPTIONS endpoint */
109109 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 ) ;
111111 } ,
112112 /** Call a HEAD endpoint */
113113 async head < P extends PathsWith < Paths , "head" > > ( url : P , init : FetchOptions < FilterKeys < Paths [ P ] , "head" > > ) {
0 commit comments