Skip to content

Commit cea163d

Browse files
committed
fix: include common http types
1 parent a78ecc7 commit cea163d

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

src/openapi-client.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ export type {
2929
OpenApiClientGeneratorConfigValidationSchemaStorage,
3030
OpenApiClientExternalValueSourceImportEntity
3131
} from './schema-to-typescript/openapi-to-typescript-client';
32+
33+
export type {
34+
CommonHttpClientFetchRequest,
35+
CommonHttpClientFetchResponse,
36+
CommonHttpClientError,
37+
CommonHttpClientRequest,
38+
CommonHttpClientResponse,
39+
CommonHttpClientFetchResponseBody,
40+
CommonHttpClientFetchRequestHeaders,
41+
CommonHttpClientResponseHeaders,
42+
CommonHttpClientOptions,
43+
CommonHttpClientRequestHeaders
44+
} from './schema-to-typescript/common/core/common-http-client';

src/schema-to-typescript/common/core/common-http-client.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,100 @@ export interface CommonHttpClientFetchRequestHeaders {
2828
[headerName: string]: string;
2929
}
3030

31+
/**
32+
* Request prepared for the fetch function.
33+
*/
3134
export interface CommonHttpClientFetchRequest {
35+
/**
36+
* HTTP Method.
37+
*/
3238
method: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'PATCH';
39+
/**
40+
* Request headers.
41+
*/
3342
headers: CommonHttpClientFetchRequestHeaders;
43+
/**
44+
* Request body.
45+
*/
3446
body?: BodyInit;
47+
/**
48+
* Cache mode.
49+
*/
3550
cache: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
51+
/**
52+
* Credentials mode.
53+
*/
3654
credentials: 'include' | 'omit' | 'same-origin';
55+
/**
56+
* Redirect mode.
57+
*/
3758
redirect: 'error' | 'follow' | 'manual';
59+
/**
60+
* Custom request properties. Can be used to pass metadata to the fetch function.
61+
*/
3862
customRequestProps?: Record<string, unknown>;
3963
}
4064

65+
/**
66+
* Request in terms of OpenAPI.
67+
*/
4168
export type CommonHttpClientRequest = Omit<
4269
CommonHttpClientFetchRequest,
4370
'body' | 'headers' | 'cache' | 'credentials' | 'redirect'
4471
> & {
72+
/**
73+
* Path to the resource.
74+
*/
4575
path: string;
76+
/**
77+
* Path parameters, i.e. {id}.
78+
*/
4679
pathParams?: Record<string, unknown>;
80+
/**
81+
* Query parameters.
82+
*/
4783
query?: Record<string, unknown>;
84+
/**
85+
* Request body.
86+
*/
4887
body?: unknown;
88+
/**
89+
* Request headers.
90+
*/
4991
headers?: CommonHttpClientRequestHeaders;
5092
} & Partial<Pick<CommonHttpClientFetchRequest, 'cache' | 'credentials' | 'redirect'>>;
5193

94+
/**
95+
* Response of the fetch function.
96+
*/
5297
export interface CommonHttpClientFetchResponse {
98+
/**
99+
* HTTP status code.
100+
*/
53101
status: number;
102+
/**
103+
* HTTP status code explanation.
104+
*/
54105
statusText: string;
106+
/**
107+
* Response body.
108+
*/
55109
body: CommonHttpClientFetchResponseBody;
110+
/**
111+
* Whether the request was successful. True for 2xx status codes.
112+
*/
56113
ok: boolean;
114+
/**
115+
* The final URL of the request (after redirects).
116+
*/
57117
url: string;
118+
/**
119+
* Response headers.
120+
*/
58121
headers: CommonHttpClientResponseHeaders;
122+
/**
123+
* Custom request properties. Can be used to pass metadata outside the fetch function.
124+
*/
59125
customRequestProps?: Record<string, unknown>;
60126
}
61127

0 commit comments

Comments
 (0)