openapi-fetch
Advanced tools
Comparing version 0.1.2 to 0.1.3
# openapi-fetch | ||
## 0.1.3 | ||
### Patch Changes | ||
- 8c01480: Fix querySerializer signature | ||
## 0.1.2 | ||
@@ -4,0 +10,0 @@ |
@@ -51,10 +51,10 @@ /** options for each client instance */ | ||
}; | ||
export type QuerySerializer<O> = { | ||
querySerializer?: (query: O extends { | ||
parameters: { | ||
query: any; | ||
}; | ||
} ? O['parameters']['query'] : Record<string, unknown>) => string; | ||
export type QuerySerializer<O> = (query: O extends { | ||
parameters: { | ||
query: any; | ||
}; | ||
} ? O['parameters']['query'] : Record<string, unknown>) => string; | ||
export type FetchOptions<T> = Params<T> & RequestBody<T> & Omit<RequestInit, 'body'> & { | ||
querySerializer?: QuerySerializer<T>; | ||
}; | ||
export type FetchOptions<T> = Params<T> & RequestBody<T> & Omit<RequestInit, 'body'> & QuerySerializer<T>; | ||
export type Success<O> = FilterKeys<FilterKeys<O, OkStatus>, 'content'>; | ||
@@ -61,0 +61,0 @@ export type Error<O> = FilterKeys<FilterKeys<O, ErrorStatus>, 'content'>; |
@@ -11,3 +11,3 @@ // settings | ||
async function coreFetch(url, fetchOptions) { | ||
let { headers, body: requestBody, params = {}, querySerializer = (q) => new URLSearchParams(q).toString(), ...init } = fetchOptions || {}; | ||
const { headers, body: requestBody, params = {}, querySerializer = (q) => new URLSearchParams(q).toString(), ...init } = fetchOptions || {}; | ||
// URL | ||
@@ -14,0 +14,0 @@ let finalURL = `${options?.baseUrl ?? ''}${url}`; |
@@ -51,10 +51,10 @@ /** options for each client instance */ | ||
}; | ||
export type QuerySerializer<O> = { | ||
querySerializer?: (query: O extends { | ||
parameters: { | ||
query: any; | ||
}; | ||
} ? O['parameters']['query'] : Record<string, unknown>) => string; | ||
export type QuerySerializer<O> = (query: O extends { | ||
parameters: { | ||
query: any; | ||
}; | ||
} ? O['parameters']['query'] : Record<string, unknown>) => string; | ||
export type FetchOptions<T> = Params<T> & RequestBody<T> & Omit<RequestInit, 'body'> & { | ||
querySerializer?: QuerySerializer<T>; | ||
}; | ||
export type FetchOptions<T> = Params<T> & RequestBody<T> & Omit<RequestInit, 'body'> & QuerySerializer<T>; | ||
export type Success<O> = FilterKeys<FilterKeys<O, OkStatus>, 'content'>; | ||
@@ -61,0 +61,0 @@ export type Error<O> = FilterKeys<FilterKeys<O, ErrorStatus>, 'content'>; |
{ | ||
"name": "openapi-fetch", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Drew Powers", |
@@ -43,4 +43,4 @@ // settings | ||
export type RequestBody<O> = undefined extends RequestBodyJSON<O> ? { body?: RequestBodyJSON<O> } : { body: RequestBodyJSON<O> }; | ||
export type QuerySerializer<O> = { querySerializer?: (query: O extends { parameters: { query: any } } ? O['parameters']['query'] : Record<string, unknown>) => string }; | ||
export type FetchOptions<T> = Params<T> & RequestBody<T> & Omit<RequestInit, 'body'> & QuerySerializer<T>; | ||
export type QuerySerializer<O> = (query: O extends { parameters: { query: any } } ? O['parameters']['query'] : Record<string, unknown>) => string; | ||
export type FetchOptions<T> = Params<T> & RequestBody<T> & Omit<RequestInit, 'body'> & { querySerializer?: QuerySerializer<T> }; | ||
export type Success<O> = FilterKeys<FilterKeys<O, OkStatus>, 'content'>; | ||
@@ -59,3 +59,3 @@ export type Error<O> = FilterKeys<FilterKeys<O, ErrorStatus>, 'content'>; | ||
async function coreFetch<P extends keyof Paths, M extends HttpMethod>(url: P, fetchOptions: FetchOptions<M extends keyof Paths[P] ? Paths[P][M] : never>): Promise<FetchResponse<M extends keyof Paths[P] ? Paths[P][M] : unknown>> { | ||
let { headers, body: requestBody, params = {}, querySerializer = (q: QuerySerializer<M extends keyof Paths[P] ? Paths[P][M] : never>) => new URLSearchParams(q as any).toString(), ...init } = fetchOptions || {}; | ||
const { headers, body: requestBody, params = {}, querySerializer = (q: QuerySerializer<M extends keyof Paths[P] ? Paths[P][M] : never>) => new URLSearchParams(q as any).toString(), ...init } = fetchOptions || {}; | ||
@@ -62,0 +62,0 @@ // URL |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60729