Skip to content

Commit f350fad

Browse files
authoredJun 10, 2024
fix: generate each http status is now zod specific (#1445)
1 parent 738bb88 commit f350fad

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed
 

‎packages/core/src/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ export type ZodOptions = {
388388
body?: Mutator;
389389
response?: Mutator;
390390
};
391+
generateEachHttpStatus?: boolean;
391392
};
392393

393394
export type ZodCoerceType = 'string' | 'number' | 'boolean' | 'bigint' | 'date';
@@ -414,6 +415,7 @@ export type NormalizedZodOptions = {
414415
body?: NormalizedMutator;
415416
response?: NormalizedMutator;
416417
};
418+
generateEachHttpStatus: boolean;
417419
};
418420

419421
export type HonoOptions = {

‎packages/orval/src/utils/options.ts

+2
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export const normalizeOptions = async (
286286
}
287287
: {}),
288288
},
289+
generateEachHttpStatus: outputOptions.override?.zod?.generateEachHttpStatus ?? false,
289290
},
290291
swr: {
291292
...(outputOptions.override?.swr ?? {}),
@@ -463,6 +464,7 @@ const normalizeOperationsAndTags = (
463464
}
464465
: {}),
465466
},
467+
generateEachHttpStatus: zod?.generateEachHttpStatus ?? false,
466468
},
467469
}
468470
: {}),

‎packages/zod/src/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
ZodCoerceType,
2626
generateMutator,
2727
GeneratorMutator,
28-
GlobalMockOptions,
2928
} from '@orval/core';
3029
import uniq from 'lodash.uniq';
3130

@@ -680,7 +679,7 @@ const generateZodRoute = async (
680679
});
681680

682681
const responses = (
683-
(context.output.mock as GlobalMockOptions)?.generateEachHttpStatus
682+
context.output.override.zod.generateEachHttpStatus
684683
? Object.entries(spec?.[verb]?.responses ?? {})
685684
: [['', spec?.[verb]?.responses[200]]]
686685
) as [string, ResponseObject | ReferenceObject][];

0 commit comments

Comments
 (0)
Please sign in to comment.