Skip to content

Commit b226db3

Browse files
authored
Release 8.0.1 (#224)
* feat: add "onFormatRouteName" hook * chore: try to add github workflows * chore: rename gh workflow file to main * chore: fix changelog after rebase * fix incorrect working --route-types with --modular option (#207) * chore: try to fix modular route types problem * fix: --route-types with --modular option; fix: better format namespace name (--route-types) * feat: add extra output util functions * chore: improve getTemplate function * feat: add formatTSContent util function * fix: bugs after rebase * bump: up version to 8.0.1; fix: critical bug linked with customFetch
1 parent 4b809f3 commit b226db3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+126
-120
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# next release
22

3+
# 8.0.1
4+
5+
Fixes:
6+
- Not working `customFetch`
7+
Error: `Failed to execute 'fetch' on 'Window': Illegal invocation`
8+
39
# 8.0.0
410

511
BREAKING_CHANGES:

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-typescript-api",
3-
"version": "8.0.0",
3+
"version": "8.0.1",
44
"description": "Generate typescript/javascript api from swagger schema",
55
"scripts": {
66
"cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",

templates/base/http-clients/fetch-http-client.eta

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
3131
baseUrl?: string;
3232
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
3333
securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
34-
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>
34+
customFetch?: typeof fetch;
3535
}
3636

3737
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
@@ -52,7 +52,7 @@ export class HttpClient<SecurityDataType = unknown> {
5252
private securityData: SecurityDataType | null = null;
5353
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
5454
private abortControllers = new Map<CancelToken, AbortController>();
55-
private customFetch = fetch;
55+
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
5656

5757
private baseApiParams: RequestParams = {
5858
credentials: 'same-origin',

tests/generated/v2.0/adafruit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
192192
baseUrl?: string;
193193
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
194194
securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
195-
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
195+
customFetch?: typeof fetch;
196196
}
197197

198198
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
@@ -213,7 +213,7 @@ export class HttpClient<SecurityDataType = unknown> {
213213
private securityData: SecurityDataType | null = null;
214214
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
215215
private abortControllers = new Map<CancelToken, AbortController>();
216-
private customFetch = fetch;
216+
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
217217

218218
private baseApiParams: RequestParams = {
219219
credentials: "same-origin",

tests/generated/v2.0/another-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
168168
baseUrl?: string;
169169
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
170170
securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
171-
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
171+
customFetch?: typeof fetch;
172172
}
173173

174174
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
@@ -189,7 +189,7 @@ export class HttpClient<SecurityDataType = unknown> {
189189
private securityData: SecurityDataType | null = null;
190190
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
191191
private abortControllers = new Map<CancelToken, AbortController>();
192-
private customFetch = fetch;
192+
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
193193

194194
private baseApiParams: RequestParams = {
195195
credentials: "same-origin",

tests/generated/v2.0/another-schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
6060
baseUrl?: string;
6161
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
6262
securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
63-
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
63+
customFetch?: typeof fetch;
6464
}
6565

6666
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
@@ -81,7 +81,7 @@ export class HttpClient<SecurityDataType = unknown> {
8181
private securityData: SecurityDataType | null = null;
8282
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
8383
private abortControllers = new Map<CancelToken, AbortController>();
84-
private customFetch = fetch;
84+
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
8585

8686
private baseApiParams: RequestParams = {
8787
credentials: "same-origin",

tests/generated/v2.0/api-with-examples.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
3737
baseUrl?: string;
3838
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
3939
securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
40-
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
40+
customFetch?: typeof fetch;
4141
}
4242

4343
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
@@ -58,7 +58,7 @@ export class HttpClient<SecurityDataType = unknown> {
5858
private securityData: SecurityDataType | null = null;
5959
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
6060
private abortControllers = new Map<CancelToken, AbortController>();
61-
private customFetch = fetch;
61+
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
6262

6363
private baseApiParams: RequestParams = {
6464
credentials: "same-origin",

tests/generated/v2.0/authentiq.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
8989
baseUrl?: string;
9090
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
9191
securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
92-
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
92+
customFetch?: typeof fetch;
9393
}
9494

9595
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
@@ -110,7 +110,7 @@ export class HttpClient<SecurityDataType = unknown> {
110110
private securityData: SecurityDataType | null = null;
111111
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
112112
private abortControllers = new Map<CancelToken, AbortController>();
113-
private customFetch = fetch;
113+
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
114114

115115
private baseApiParams: RequestParams = {
116116
credentials: "same-origin",

tests/generated/v2.0/enums.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export interface ApiConfig<SecurityDataType = unknown> {
102102
baseUrl?: string;
103103
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
104104
securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
105-
customFetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
105+
customFetch?: typeof fetch;
106106
}
107107

108108
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
@@ -123,7 +123,7 @@ export class HttpClient<SecurityDataType = unknown> {
123123
private securityData: SecurityDataType | null = null;
124124
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
125125
private abortControllers = new Map<CancelToken, AbortController>();
126-
private customFetch = fetch;
126+
private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams);
127127

128128
private baseApiParams: RequestParams = {
129129
credentials: "same-origin",

0 commit comments

Comments
 (0)