diff --git a/plugins/typescript/src/templates/context.ts b/plugins/typescript/src/templates/context.ts index 30b75fd..6ca2e23 100644 --- a/plugins/typescript/src/templates/context.ts +++ b/plugins/typescript/src/templates/context.ts @@ -14,6 +14,10 @@ export const getContext = (prefix: string, componentsFile: string) => * Query params to inject in the fetcher */ queryParams?: {}; + /** + * Enable response validation + */ + responseValidatorEnabled?: boolean }; queryOptions: { /** diff --git a/plugins/typescript/src/templates/fetcher.ts b/plugins/typescript/src/templates/fetcher.ts index 80c715d..b5a3466 100644 --- a/plugins/typescript/src/templates/fetcher.ts +++ b/plugins/typescript/src/templates/fetcher.ts @@ -68,6 +68,7 @@ export async function ${camel(prefix)}Fetch< queryParams, signal, responseValidator, + responseValidatorEnabled, }: ${pascal(prefix)}FetcherOptions< TBody, THeaders, @@ -118,7 +119,7 @@ export async function ${camel(prefix)}Fetch< if (response.headers.get('content-type')?.includes('json')) { const json = await response.json(); - if (responseValidator) { + if (responseValidator && responseValidatorEnabled) { return responseValidator(json); } else { return json;