Skip to content

Commit d8bbc98

Browse files
author
Batyr Jumageldiyew
committed
support next.js config props
1 parent 93758f1 commit d8bbc98

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/templates/client.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export class {{{clientName}}} {
7070
PASSWORD: config?.PASSWORD,
7171
HEADERS: config?.HEADERS,
7272
ENCODE_PATH: config?.ENCODE_PATH,
73+
NEXT: config?.NEXT,
74+
CACHE: config?.CACHE,
7375
});
7476

7577
{{#each services}}

src/templates/core/OpenAPI.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export type OpenAPIConfig = {
1515
PASSWORD?: string | Resolver<string> | undefined;
1616
HEADERS?: Headers | Resolver<Headers> | undefined;
1717
ENCODE_PATH?: ((path: string) => string) | undefined;
18+
NEXT?: NextFetchRequestConfig;
19+
CACHE?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
1820
};
1921

2022
export const OpenAPI: OpenAPIConfig = {
@@ -27,4 +29,6 @@ export const OpenAPI: OpenAPIConfig = {
2729
PASSWORD: undefined,
2830
HEADERS: undefined,
2931
ENCODE_PATH: undefined,
32+
NEXT: undefined,
33+
CACHE: undefined,
3034
};

src/templates/core/fetch/request.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): C
6969
const formData = getFormData(options);
7070
const body = getRequestBody(options);
7171
const headers = await getHeaders(config, options);
72+
const next = config.NEXT;
73+
const cache = config.CACHE;
7274

7375
if (!onCancel.isCancelled) {
74-
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
76+
const response = await sendRequest(
77+
config, options, url, body, formData, headers, onCancel, next, cache
78+
);
7579
const responseBody = await getResponseBody(response);
7680
const responseHeader = getResponseHeader(response, options.responseHeader);
7781

src/templates/core/fetch/sendRequest.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export const sendRequest = async (
55
body: any,
66
formData: FormData | undefined,
77
headers: Headers,
8-
onCancel: OnCancel
8+
onCancel: OnCancel,
9+
next: NextFetchRequestConfig | undefined,
10+
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload"
911
): Promise<Response> => {
1012
const controller = new AbortController();
1113

@@ -14,6 +16,8 @@ export const sendRequest = async (
1416
body: body ?? formData,
1517
method: options.method,
1618
signal: controller.signal,
19+
next: next,
20+
cache: cache
1721
};
1822

1923
if (config.WITH_CREDENTIALS) {

0 commit comments

Comments
 (0)