Skip to content

Commit 2f33022

Browse files
committed
add fetcherOption to enable responseValidator
1 parent 4d6ddcc commit 2f33022

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

plugins/typescript/src/templates/context.ts

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const getContext = (prefix: string, componentsFile: string) =>
1414
* Query params to inject in the fetcher
1515
*/
1616
queryParams?: {};
17+
/**
18+
* Enable response validation
19+
*/
20+
responseValidatorEnabled?: boolean
1721
};
1822
queryOptions: {
1923
/**

plugins/typescript/src/templates/fetcher.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export async function ${camel(prefix)}Fetch<
6868
queryParams,
6969
signal,
7070
responseValidator,
71+
responseValidatorEnabled,
7172
}: ${pascal(prefix)}FetcherOptions<
7273
TBody,
7374
THeaders,
@@ -118,7 +119,7 @@ export async function ${camel(prefix)}Fetch<
118119
119120
if (response.headers.get('content-type')?.includes('json')) {
120121
const json = await response.json();
121-
if (responseValidator) {
122+
if (responseValidator && responseValidatorEnabled) {
122123
return responseValidator(json);
123124
} else {
124125
return json;

0 commit comments

Comments
 (0)