From f350fadf9c2b172aae69b335c740d7f54a560f0c Mon Sep 17 00:00:00 2001 From: Thomas Leeds Date: Mon, 10 Jun 2024 13:02:35 +0100 Subject: [PATCH] fix: generate each http status is now zod specific (#1445) --- packages/core/src/types.ts | 2 ++ packages/orval/src/utils/options.ts | 2 ++ packages/zod/src/index.ts | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 6c9072b72..4e891d5c5 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -388,6 +388,7 @@ export type ZodOptions = { body?: Mutator; response?: Mutator; }; + generateEachHttpStatus?: boolean; }; export type ZodCoerceType = 'string' | 'number' | 'boolean' | 'bigint' | 'date'; @@ -414,6 +415,7 @@ export type NormalizedZodOptions = { body?: NormalizedMutator; response?: NormalizedMutator; }; + generateEachHttpStatus: boolean; }; export type HonoOptions = { diff --git a/packages/orval/src/utils/options.ts b/packages/orval/src/utils/options.ts index ad4a2ff6f..4ef66af74 100644 --- a/packages/orval/src/utils/options.ts +++ b/packages/orval/src/utils/options.ts @@ -286,6 +286,7 @@ export const normalizeOptions = async ( } : {}), }, + generateEachHttpStatus: outputOptions.override?.zod?.generateEachHttpStatus ?? false, }, swr: { ...(outputOptions.override?.swr ?? {}), @@ -463,6 +464,7 @@ const normalizeOperationsAndTags = ( } : {}), }, + generateEachHttpStatus: zod?.generateEachHttpStatus ?? false, }, } : {}), diff --git a/packages/zod/src/index.ts b/packages/zod/src/index.ts index 5d26950af..5018d7093 100644 --- a/packages/zod/src/index.ts +++ b/packages/zod/src/index.ts @@ -25,7 +25,6 @@ import { ZodCoerceType, generateMutator, GeneratorMutator, - GlobalMockOptions, } from '@orval/core'; import uniq from 'lodash.uniq'; @@ -680,7 +679,7 @@ const generateZodRoute = async ( }); const responses = ( - (context.output.mock as GlobalMockOptions)?.generateEachHttpStatus + context.output.override.zod.generateEachHttpStatus ? Object.entries(spec?.[verb]?.responses ?? {}) : [['', spec?.[verb]?.responses[200]]] ) as [string, ResponseObject | ReferenceObject][];