@shipworthy/openapi-fetch 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -31
- package/dist/index.cjs +250 -49
- package/dist/index.d.cts +64 -29
- package/dist/index.d.ts +64 -29
- package/dist/index.js +250 -49
- package/dist/transform-casing.cjs +161 -0
- package/dist/transform-casing.d.cts +138 -0
- package/dist/transform-casing.d.ts +138 -0
- package/dist/transform-casing.js +160 -0
- package/package.json +14 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/helpers.d.ts
|
|
2
1
|
type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
3
2
|
/** 2XX statuses */
|
|
4
3
|
type OkStatus = 200 | 201 | 202 | 203 | 204 | 206 | 207 | "2XX";
|
|
@@ -190,8 +189,29 @@ type Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Re
|
|
|
190
189
|
* - object → recursively resolve
|
|
191
190
|
*/
|
|
192
191
|
type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends (infer E)[] ? Writable<E>[] : T extends object ? { [K in keyof T as NonNullable<T[K]> extends $Read<any> ? never : K]: Writable<T[K]>; } & { [K in keyof T as NonNullable<T[K]> extends $Read<any> ? K : never]?: never; } : T;
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
interface CaseSchema {
|
|
193
|
+
readonly ref?: string;
|
|
194
|
+
readonly properties?: Readonly<Record<string, {
|
|
195
|
+
readonly name: string;
|
|
196
|
+
readonly schema?: CaseSchema;
|
|
197
|
+
}>>;
|
|
198
|
+
readonly declared?: readonly string[];
|
|
199
|
+
readonly items?: CaseSchema;
|
|
200
|
+
readonly prefixItems?: readonly (CaseSchema | null)[];
|
|
201
|
+
readonly additionalProperties?: CaseSchema;
|
|
202
|
+
readonly patternProperties?: Readonly<Record<string, CaseSchema | null>>;
|
|
203
|
+
readonly variants?: readonly CaseSchema[];
|
|
204
|
+
}
|
|
205
|
+
type CaseMediaMap = Readonly<Record<string, CaseSchema | null>>;
|
|
206
|
+
interface CaseOperation {
|
|
207
|
+
readonly parameters?: Readonly<Partial<Record<"path" | "query" | "header" | "cookie", CaseSchema>>>;
|
|
208
|
+
readonly requestBodies?: CaseMediaMap;
|
|
209
|
+
readonly responses?: Readonly<Record<string, CaseMediaMap | null>>;
|
|
210
|
+
}
|
|
211
|
+
interface CaseMapping {
|
|
212
|
+
readonly schemas?: Readonly<Record<string, CaseSchema>>;
|
|
213
|
+
readonly operations?: Readonly<Record<string, CaseOperation>>;
|
|
214
|
+
}
|
|
195
215
|
/** Options for each client instance */
|
|
196
216
|
interface ClientOptions extends Omit<RequestInit, "headers"> {
|
|
197
217
|
/** set the common root URL for all API requests */
|
|
@@ -206,6 +226,8 @@ interface ClientOptions extends Omit<RequestInit, "headers"> {
|
|
|
206
226
|
bodySerializer?: BodySerializer<unknown>;
|
|
207
227
|
/** global pathSerializer */
|
|
208
228
|
pathSerializer?: PathSerializer;
|
|
229
|
+
/** schema-based field mapping applied to every request and parsed result */
|
|
230
|
+
caseMapping?: CaseMapping;
|
|
209
231
|
headers?: HeadersOptions;
|
|
210
232
|
/** RequestInit extension object to pass as 2nd argument to fetch when supported (defaults to undefined) */
|
|
211
233
|
requestInitExt?: Record<string, unknown>;
|
|
@@ -301,10 +323,28 @@ type MergedOptions<T = unknown> = {
|
|
|
301
323
|
};
|
|
302
324
|
interface MiddlewareRequestParams {
|
|
303
325
|
query?: Record<string, unknown>;
|
|
304
|
-
header?:
|
|
326
|
+
header?: HeadersOptions;
|
|
305
327
|
path?: Record<string, unknown>;
|
|
306
328
|
cookie?: Record<string, unknown>;
|
|
307
329
|
}
|
|
330
|
+
interface MiddlewareRequestInput {
|
|
331
|
+
readonly params: MiddlewareRequestParams;
|
|
332
|
+
readonly body: unknown;
|
|
333
|
+
}
|
|
334
|
+
interface MiddlewareRequestInitParams {
|
|
335
|
+
readonly schemaPath: string;
|
|
336
|
+
readonly method: string;
|
|
337
|
+
readonly input: MiddlewareRequestInput;
|
|
338
|
+
/** Client, request, and parameter headers merged before serialization. */
|
|
339
|
+
readonly headers: Headers;
|
|
340
|
+
readonly id: string;
|
|
341
|
+
readonly options: MergedOptions;
|
|
342
|
+
}
|
|
343
|
+
interface MiddlewareResult {
|
|
344
|
+
readonly data?: unknown;
|
|
345
|
+
readonly error?: unknown;
|
|
346
|
+
readonly response: Response;
|
|
347
|
+
}
|
|
308
348
|
interface MiddlewareCallbackParams {
|
|
309
349
|
/** Current Request object */
|
|
310
350
|
request: Request;
|
|
@@ -317,6 +357,12 @@ interface MiddlewareCallbackParams {
|
|
|
317
357
|
/** createClient options (read-only) */
|
|
318
358
|
readonly options: MergedOptions;
|
|
319
359
|
}
|
|
360
|
+
interface MiddlewareResultParams extends MiddlewareCallbackParams {
|
|
361
|
+
/** The method requested through the client, before HTTP middleware can replace the Request. */
|
|
362
|
+
readonly method: string;
|
|
363
|
+
readonly result: MiddlewareResult;
|
|
364
|
+
}
|
|
365
|
+
type MiddlewareOnRequestInit = (options: MiddlewareRequestInitParams) => void | MiddlewareRequestInput | Promise<MiddlewareRequestInput | void>;
|
|
320
366
|
type MiddlewareOnRequest = (options: MiddlewareCallbackParams) => void | Request | Response | undefined | Promise<Request | Response | undefined | void>;
|
|
321
367
|
type MiddlewareOnResponse = (options: MiddlewareCallbackParams & {
|
|
322
368
|
response: Response;
|
|
@@ -324,19 +370,25 @@ type MiddlewareOnResponse = (options: MiddlewareCallbackParams & {
|
|
|
324
370
|
type MiddlewareOnError = (options: MiddlewareCallbackParams & {
|
|
325
371
|
error: unknown;
|
|
326
372
|
}) => void | Response | Error | Promise<void | Response | Error>;
|
|
327
|
-
type
|
|
328
|
-
|
|
373
|
+
type MiddlewareOnResult = (options: MiddlewareResultParams) => void | Partial<Pick<MiddlewareResult, "data" | "error">> | Promise<Partial<Pick<MiddlewareResult, "data" | "error">> | void>;
|
|
374
|
+
interface MiddlewareHooks {
|
|
375
|
+
onRequestInit?: MiddlewareOnRequestInit;
|
|
376
|
+
onRequest?: MiddlewareOnRequest;
|
|
329
377
|
onResponse?: MiddlewareOnResponse;
|
|
330
378
|
onError?: MiddlewareOnError;
|
|
379
|
+
onResult?: MiddlewareOnResult;
|
|
380
|
+
}
|
|
381
|
+
type Middleware = MiddlewareHooks & ({
|
|
382
|
+
onRequestInit: MiddlewareOnRequestInit;
|
|
383
|
+
} | {
|
|
384
|
+
onRequest: MiddlewareOnRequest;
|
|
331
385
|
} | {
|
|
332
|
-
onRequest?: MiddlewareOnRequest;
|
|
333
386
|
onResponse: MiddlewareOnResponse;
|
|
334
|
-
onError?: MiddlewareOnError;
|
|
335
387
|
} | {
|
|
336
|
-
onRequest?: MiddlewareOnRequest;
|
|
337
|
-
onResponse?: MiddlewareOnResponse;
|
|
338
388
|
onError: MiddlewareOnError;
|
|
339
|
-
}
|
|
389
|
+
} | {
|
|
390
|
+
onResult: MiddlewareOnResult;
|
|
391
|
+
});
|
|
340
392
|
/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */
|
|
341
393
|
type MaybeOptionalInit<Params, Location extends keyof Params> = RequiredKeysOf<FetchOptions<FilterKeys<Params, Location>>> extends never ? FetchOptions<FilterKeys<Params, Location>> | undefined : FetchOptions<FilterKeys<Params, Location>>;
|
|
342
394
|
type InitParam<Init> = RequiredKeysOf<Init> extends never ? [(Init & {
|
|
@@ -375,14 +427,10 @@ type MethodResponse<CreatedClient extends Client<any, any>, Method extends HttpM
|
|
|
375
427
|
[key: string]: any;
|
|
376
428
|
}, infer Media extends MediaType> ? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>["data"]> : never;
|
|
377
429
|
type PathBasedClient<Paths extends Record<string | number, any>, Media extends MediaType = MediaType> = { [Path in keyof Paths]: ClientForPath<Paths[Path], Media>; };
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/client.d.ts
|
|
380
430
|
/**
|
|
381
431
|
* Create an openapi-fetch client.
|
|
382
432
|
*/
|
|
383
433
|
export default function createClient<Paths extends {}, Media extends MediaType = MediaType>(clientOptions?: ClientOptions): Client<Paths, Media>;
|
|
384
|
-
//#endregion
|
|
385
|
-
//#region src/path-client.d.ts
|
|
386
434
|
/**
|
|
387
435
|
* Wrap openapi-fetch client to support a path based API.
|
|
388
436
|
*/
|
|
@@ -392,12 +440,8 @@ export declare function wrapAsPathBasedClient<Paths extends {}, Media extends Me
|
|
|
392
440
|
* Strictly equivalent to `wrapAsPathBasedClient(createClient(...))`.
|
|
393
441
|
*/
|
|
394
442
|
export declare function createPathBasedClient<Paths extends {}, Media extends MediaType = MediaType>(clientOptions?: ClientOptions): PathBasedClient<Paths, Media>;
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/headers.d.ts
|
|
397
443
|
/** Merge headers a and b, with b taking priority */
|
|
398
444
|
export declare function mergeHeaders(...allHeaders: (HeadersOptions | undefined)[]): Headers;
|
|
399
|
-
//#endregion
|
|
400
|
-
//#region src/serializers/param.d.ts
|
|
401
445
|
type SerializePrimitiveOptions = {
|
|
402
446
|
allowReserved?: boolean;
|
|
403
447
|
};
|
|
@@ -417,23 +461,15 @@ type SerializeArrayOptions = {
|
|
|
417
461
|
};
|
|
418
462
|
/** Serialize array param (shallow only) */
|
|
419
463
|
export declare function serializeArrayParam(name: string, value: unknown[], options: SerializeArrayOptions): string;
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region src/serializers/query.d.ts
|
|
422
464
|
/** Serialize query params to string */
|
|
423
465
|
export declare function createQuerySerializer<T = unknown>(options?: QuerySerializerOptions): (queryParams: T) => string;
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/serializers/path.d.ts
|
|
426
466
|
/**
|
|
427
467
|
* Handle different OpenAPI 3.x serialization styles
|
|
428
468
|
* @see https://swagger.io/docs/specification/serialization/#path
|
|
429
469
|
*/
|
|
430
470
|
export declare function defaultPathSerializer(pathname: string, pathParams: Record<string, unknown>): string;
|
|
431
|
-
//#endregion
|
|
432
|
-
//#region src/serializers/body.d.ts
|
|
433
471
|
/** Serialize body object to string */
|
|
434
472
|
export declare function defaultBodySerializer<T>(body: T, headers?: Headers | Record<string, unknown>): string | FormData;
|
|
435
|
-
//#endregion
|
|
436
|
-
//#region src/serializers/url.d.ts
|
|
437
473
|
/** Construct URL string from baseUrl and handle path and query params */
|
|
438
474
|
export declare function createFinalURL<O>(pathname: string, options: {
|
|
439
475
|
baseUrl: string;
|
|
@@ -446,5 +482,4 @@ export declare function createFinalURL<O>(pathname: string, options: {
|
|
|
446
482
|
}): string;
|
|
447
483
|
/** Remove trailing slash from url */
|
|
448
484
|
export declare function removeTrailingSlash(url: string): string;
|
|
449
|
-
|
|
450
|
-
export { type $Read, type $Write, type BodySerializer, type Client, type ClientForPath, type ClientMethod, type ClientOptions, type ClientPathsWithMethod, type ClientRequestMethod, type DefaultParamsOption, type ErrorResponse, type ErrorResponseJSON, type ErrorStatus, type FetchOptions, type FetchResponse, type FilterKeys, type FirstErrorStatus, type GetResponseContent, type HeadersOptions, type HttpMethod, type IsOperationRequestBodyOptional, type JSONLike, type MaybeOptionalInit, type MediaType, type MergedOptions, type MethodResponse, type Middleware, type MiddlewareCallbackParams, type MiddlewareRequestParams, type OKStatusUnion, type OkStatus, type OperationObject, type OperationRequestBody, type OperationRequestBodyContent, type OperationRequestBodyMediaContent, type ParamsOption, type ParseAs, type ParseAsResponse, type PathBasedClient, type PathItemObject, type PathSerializer, type PathsWithMethod, type QuerySerializer, type QuerySerializerOptions, type Readable, type RequestBodyJSON, type RequestBodyOption, type RequestOptions, type RequiredKeysOf, type ResponseContent, type ResponseObjectMap, type SuccessResponse, type SuccessResponseJSON, type Writable, createClient };
|
|
485
|
+
export { type $Read, type $Write, type BodySerializer, type Client, type ClientForPath, type ClientMethod, type ClientOptions, type ClientPathsWithMethod, type ClientRequestMethod, type DefaultParamsOption, type ErrorResponse, type ErrorResponseJSON, type ErrorStatus, type FetchOptions, type FetchResponse, type FilterKeys, type FirstErrorStatus, type GetResponseContent, type HeadersOptions, type HttpMethod, type IsOperationRequestBodyOptional, type JSONLike, type MaybeOptionalInit, type MediaType, type MergedOptions, type MethodResponse, type Middleware, type MiddlewareCallbackParams, type MiddlewareRequestInitParams, type MiddlewareRequestInput, type MiddlewareRequestParams, type MiddlewareResult, type MiddlewareResultParams, type OKStatusUnion, type OkStatus, type OperationObject, type OperationRequestBody, type OperationRequestBodyContent, type OperationRequestBodyMediaContent, type ParamsOption, type ParseAs, type ParseAsResponse, type PathBasedClient, type PathItemObject, type PathSerializer, type PathsWithMethod, type QuerySerializer, type QuerySerializerOptions, type Readable, type RequestBodyJSON, type RequestBodyOption, type RequestOptions, type RequiredKeysOf, type ResponseContent, type ResponseObjectMap, type SuccessResponse, type SuccessResponseJSON, type Writable, createClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/helpers.d.ts
|
|
2
1
|
type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
3
2
|
/** 2XX statuses */
|
|
4
3
|
type OkStatus = 200 | 201 | 202 | 203 | 204 | 206 | 207 | "2XX";
|
|
@@ -190,8 +189,29 @@ type Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Re
|
|
|
190
189
|
* - object → recursively resolve
|
|
191
190
|
*/
|
|
192
191
|
type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends (infer E)[] ? Writable<E>[] : T extends object ? { [K in keyof T as NonNullable<T[K]> extends $Read<any> ? never : K]: Writable<T[K]>; } & { [K in keyof T as NonNullable<T[K]> extends $Read<any> ? K : never]?: never; } : T;
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
interface CaseSchema {
|
|
193
|
+
readonly ref?: string;
|
|
194
|
+
readonly properties?: Readonly<Record<string, {
|
|
195
|
+
readonly name: string;
|
|
196
|
+
readonly schema?: CaseSchema;
|
|
197
|
+
}>>;
|
|
198
|
+
readonly declared?: readonly string[];
|
|
199
|
+
readonly items?: CaseSchema;
|
|
200
|
+
readonly prefixItems?: readonly (CaseSchema | null)[];
|
|
201
|
+
readonly additionalProperties?: CaseSchema;
|
|
202
|
+
readonly patternProperties?: Readonly<Record<string, CaseSchema | null>>;
|
|
203
|
+
readonly variants?: readonly CaseSchema[];
|
|
204
|
+
}
|
|
205
|
+
type CaseMediaMap = Readonly<Record<string, CaseSchema | null>>;
|
|
206
|
+
interface CaseOperation {
|
|
207
|
+
readonly parameters?: Readonly<Partial<Record<"path" | "query" | "header" | "cookie", CaseSchema>>>;
|
|
208
|
+
readonly requestBodies?: CaseMediaMap;
|
|
209
|
+
readonly responses?: Readonly<Record<string, CaseMediaMap | null>>;
|
|
210
|
+
}
|
|
211
|
+
interface CaseMapping {
|
|
212
|
+
readonly schemas?: Readonly<Record<string, CaseSchema>>;
|
|
213
|
+
readonly operations?: Readonly<Record<string, CaseOperation>>;
|
|
214
|
+
}
|
|
195
215
|
/** Options for each client instance */
|
|
196
216
|
interface ClientOptions extends Omit<RequestInit, "headers"> {
|
|
197
217
|
/** set the common root URL for all API requests */
|
|
@@ -206,6 +226,8 @@ interface ClientOptions extends Omit<RequestInit, "headers"> {
|
|
|
206
226
|
bodySerializer?: BodySerializer<unknown>;
|
|
207
227
|
/** global pathSerializer */
|
|
208
228
|
pathSerializer?: PathSerializer;
|
|
229
|
+
/** schema-based field mapping applied to every request and parsed result */
|
|
230
|
+
caseMapping?: CaseMapping;
|
|
209
231
|
headers?: HeadersOptions;
|
|
210
232
|
/** RequestInit extension object to pass as 2nd argument to fetch when supported (defaults to undefined) */
|
|
211
233
|
requestInitExt?: Record<string, unknown>;
|
|
@@ -301,10 +323,28 @@ type MergedOptions<T = unknown> = {
|
|
|
301
323
|
};
|
|
302
324
|
interface MiddlewareRequestParams {
|
|
303
325
|
query?: Record<string, unknown>;
|
|
304
|
-
header?:
|
|
326
|
+
header?: HeadersOptions;
|
|
305
327
|
path?: Record<string, unknown>;
|
|
306
328
|
cookie?: Record<string, unknown>;
|
|
307
329
|
}
|
|
330
|
+
interface MiddlewareRequestInput {
|
|
331
|
+
readonly params: MiddlewareRequestParams;
|
|
332
|
+
readonly body: unknown;
|
|
333
|
+
}
|
|
334
|
+
interface MiddlewareRequestInitParams {
|
|
335
|
+
readonly schemaPath: string;
|
|
336
|
+
readonly method: string;
|
|
337
|
+
readonly input: MiddlewareRequestInput;
|
|
338
|
+
/** Client, request, and parameter headers merged before serialization. */
|
|
339
|
+
readonly headers: Headers;
|
|
340
|
+
readonly id: string;
|
|
341
|
+
readonly options: MergedOptions;
|
|
342
|
+
}
|
|
343
|
+
interface MiddlewareResult {
|
|
344
|
+
readonly data?: unknown;
|
|
345
|
+
readonly error?: unknown;
|
|
346
|
+
readonly response: Response;
|
|
347
|
+
}
|
|
308
348
|
interface MiddlewareCallbackParams {
|
|
309
349
|
/** Current Request object */
|
|
310
350
|
request: Request;
|
|
@@ -317,6 +357,12 @@ interface MiddlewareCallbackParams {
|
|
|
317
357
|
/** createClient options (read-only) */
|
|
318
358
|
readonly options: MergedOptions;
|
|
319
359
|
}
|
|
360
|
+
interface MiddlewareResultParams extends MiddlewareCallbackParams {
|
|
361
|
+
/** The method requested through the client, before HTTP middleware can replace the Request. */
|
|
362
|
+
readonly method: string;
|
|
363
|
+
readonly result: MiddlewareResult;
|
|
364
|
+
}
|
|
365
|
+
type MiddlewareOnRequestInit = (options: MiddlewareRequestInitParams) => void | MiddlewareRequestInput | Promise<MiddlewareRequestInput | void>;
|
|
320
366
|
type MiddlewareOnRequest = (options: MiddlewareCallbackParams) => void | Request | Response | undefined | Promise<Request | Response | undefined | void>;
|
|
321
367
|
type MiddlewareOnResponse = (options: MiddlewareCallbackParams & {
|
|
322
368
|
response: Response;
|
|
@@ -324,19 +370,25 @@ type MiddlewareOnResponse = (options: MiddlewareCallbackParams & {
|
|
|
324
370
|
type MiddlewareOnError = (options: MiddlewareCallbackParams & {
|
|
325
371
|
error: unknown;
|
|
326
372
|
}) => void | Response | Error | Promise<void | Response | Error>;
|
|
327
|
-
type
|
|
328
|
-
|
|
373
|
+
type MiddlewareOnResult = (options: MiddlewareResultParams) => void | Partial<Pick<MiddlewareResult, "data" | "error">> | Promise<Partial<Pick<MiddlewareResult, "data" | "error">> | void>;
|
|
374
|
+
interface MiddlewareHooks {
|
|
375
|
+
onRequestInit?: MiddlewareOnRequestInit;
|
|
376
|
+
onRequest?: MiddlewareOnRequest;
|
|
329
377
|
onResponse?: MiddlewareOnResponse;
|
|
330
378
|
onError?: MiddlewareOnError;
|
|
379
|
+
onResult?: MiddlewareOnResult;
|
|
380
|
+
}
|
|
381
|
+
type Middleware = MiddlewareHooks & ({
|
|
382
|
+
onRequestInit: MiddlewareOnRequestInit;
|
|
383
|
+
} | {
|
|
384
|
+
onRequest: MiddlewareOnRequest;
|
|
331
385
|
} | {
|
|
332
|
-
onRequest?: MiddlewareOnRequest;
|
|
333
386
|
onResponse: MiddlewareOnResponse;
|
|
334
|
-
onError?: MiddlewareOnError;
|
|
335
387
|
} | {
|
|
336
|
-
onRequest?: MiddlewareOnRequest;
|
|
337
|
-
onResponse?: MiddlewareOnResponse;
|
|
338
388
|
onError: MiddlewareOnError;
|
|
339
|
-
}
|
|
389
|
+
} | {
|
|
390
|
+
onResult: MiddlewareOnResult;
|
|
391
|
+
});
|
|
340
392
|
/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */
|
|
341
393
|
type MaybeOptionalInit<Params, Location extends keyof Params> = RequiredKeysOf<FetchOptions<FilterKeys<Params, Location>>> extends never ? FetchOptions<FilterKeys<Params, Location>> | undefined : FetchOptions<FilterKeys<Params, Location>>;
|
|
342
394
|
type InitParam<Init> = RequiredKeysOf<Init> extends never ? [(Init & {
|
|
@@ -375,14 +427,10 @@ type MethodResponse<CreatedClient extends Client<any, any>, Method extends HttpM
|
|
|
375
427
|
[key: string]: any;
|
|
376
428
|
}, infer Media extends MediaType> ? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>["data"]> : never;
|
|
377
429
|
type PathBasedClient<Paths extends Record<string | number, any>, Media extends MediaType = MediaType> = { [Path in keyof Paths]: ClientForPath<Paths[Path], Media>; };
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/client.d.ts
|
|
380
430
|
/**
|
|
381
431
|
* Create an openapi-fetch client.
|
|
382
432
|
*/
|
|
383
433
|
export default function createClient<Paths extends {}, Media extends MediaType = MediaType>(clientOptions?: ClientOptions): Client<Paths, Media>;
|
|
384
|
-
//#endregion
|
|
385
|
-
//#region src/path-client.d.ts
|
|
386
434
|
/**
|
|
387
435
|
* Wrap openapi-fetch client to support a path based API.
|
|
388
436
|
*/
|
|
@@ -392,12 +440,8 @@ export declare function wrapAsPathBasedClient<Paths extends {}, Media extends Me
|
|
|
392
440
|
* Strictly equivalent to `wrapAsPathBasedClient(createClient(...))`.
|
|
393
441
|
*/
|
|
394
442
|
export declare function createPathBasedClient<Paths extends {}, Media extends MediaType = MediaType>(clientOptions?: ClientOptions): PathBasedClient<Paths, Media>;
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/headers.d.ts
|
|
397
443
|
/** Merge headers a and b, with b taking priority */
|
|
398
444
|
export declare function mergeHeaders(...allHeaders: (HeadersOptions | undefined)[]): Headers;
|
|
399
|
-
//#endregion
|
|
400
|
-
//#region src/serializers/param.d.ts
|
|
401
445
|
type SerializePrimitiveOptions = {
|
|
402
446
|
allowReserved?: boolean;
|
|
403
447
|
};
|
|
@@ -417,23 +461,15 @@ type SerializeArrayOptions = {
|
|
|
417
461
|
};
|
|
418
462
|
/** Serialize array param (shallow only) */
|
|
419
463
|
export declare function serializeArrayParam(name: string, value: unknown[], options: SerializeArrayOptions): string;
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region src/serializers/query.d.ts
|
|
422
464
|
/** Serialize query params to string */
|
|
423
465
|
export declare function createQuerySerializer<T = unknown>(options?: QuerySerializerOptions): (queryParams: T) => string;
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/serializers/path.d.ts
|
|
426
466
|
/**
|
|
427
467
|
* Handle different OpenAPI 3.x serialization styles
|
|
428
468
|
* @see https://swagger.io/docs/specification/serialization/#path
|
|
429
469
|
*/
|
|
430
470
|
export declare function defaultPathSerializer(pathname: string, pathParams: Record<string, unknown>): string;
|
|
431
|
-
//#endregion
|
|
432
|
-
//#region src/serializers/body.d.ts
|
|
433
471
|
/** Serialize body object to string */
|
|
434
472
|
export declare function defaultBodySerializer<T>(body: T, headers?: Headers | Record<string, unknown>): string | FormData;
|
|
435
|
-
//#endregion
|
|
436
|
-
//#region src/serializers/url.d.ts
|
|
437
473
|
/** Construct URL string from baseUrl and handle path and query params */
|
|
438
474
|
export declare function createFinalURL<O>(pathname: string, options: {
|
|
439
475
|
baseUrl: string;
|
|
@@ -446,5 +482,4 @@ export declare function createFinalURL<O>(pathname: string, options: {
|
|
|
446
482
|
}): string;
|
|
447
483
|
/** Remove trailing slash from url */
|
|
448
484
|
export declare function removeTrailingSlash(url: string): string;
|
|
449
|
-
|
|
450
|
-
export { type $Read, type $Write, type BodySerializer, type Client, type ClientForPath, type ClientMethod, type ClientOptions, type ClientPathsWithMethod, type ClientRequestMethod, type DefaultParamsOption, type ErrorResponse, type ErrorResponseJSON, type ErrorStatus, type FetchOptions, type FetchResponse, type FilterKeys, type FirstErrorStatus, type GetResponseContent, type HeadersOptions, type HttpMethod, type IsOperationRequestBodyOptional, type JSONLike, type MaybeOptionalInit, type MediaType, type MergedOptions, type MethodResponse, type Middleware, type MiddlewareCallbackParams, type MiddlewareRequestParams, type OKStatusUnion, type OkStatus, type OperationObject, type OperationRequestBody, type OperationRequestBodyContent, type OperationRequestBodyMediaContent, type ParamsOption, type ParseAs, type ParseAsResponse, type PathBasedClient, type PathItemObject, type PathSerializer, type PathsWithMethod, type QuerySerializer, type QuerySerializerOptions, type Readable, type RequestBodyJSON, type RequestBodyOption, type RequestOptions, type RequiredKeysOf, type ResponseContent, type ResponseObjectMap, type SuccessResponse, type SuccessResponseJSON, type Writable, createClient };
|
|
485
|
+
export { type $Read, type $Write, type BodySerializer, type Client, type ClientForPath, type ClientMethod, type ClientOptions, type ClientPathsWithMethod, type ClientRequestMethod, type DefaultParamsOption, type ErrorResponse, type ErrorResponseJSON, type ErrorStatus, type FetchOptions, type FetchResponse, type FilterKeys, type FirstErrorStatus, type GetResponseContent, type HeadersOptions, type HttpMethod, type IsOperationRequestBodyOptional, type JSONLike, type MaybeOptionalInit, type MediaType, type MergedOptions, type MethodResponse, type Middleware, type MiddlewareCallbackParams, type MiddlewareRequestInitParams, type MiddlewareRequestInput, type MiddlewareRequestParams, type MiddlewareResult, type MiddlewareResultParams, type OKStatusUnion, type OkStatus, type OperationObject, type OperationRequestBody, type OperationRequestBodyContent, type OperationRequestBodyMediaContent, type ParamsOption, type ParseAs, type ParseAsResponse, type PathBasedClient, type PathItemObject, type PathSerializer, type PathsWithMethod, type QuerySerializer, type QuerySerializerOptions, type Readable, type RequestBodyJSON, type RequestBodyOption, type RequestOptions, type RequiredKeysOf, type ResponseContent, type ResponseObjectMap, type SuccessResponse, type SuccessResponseJSON, type Writable, createClient };
|