Skip to content

Commit

Permalink
fix: generate each http status is now zod specific (#1445)
Browse files Browse the repository at this point in the history
  • Loading branch information
TommoLeedsy authored Jun 10, 2024
1 parent 738bb88 commit f350fad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export type ZodOptions = {
body?: Mutator;
response?: Mutator;
};
generateEachHttpStatus?: boolean;
};

export type ZodCoerceType = 'string' | 'number' | 'boolean' | 'bigint' | 'date';
Expand All @@ -414,6 +415,7 @@ export type NormalizedZodOptions = {
body?: NormalizedMutator;
response?: NormalizedMutator;
};
generateEachHttpStatus: boolean;
};

export type HonoOptions = {
Expand Down
2 changes: 2 additions & 0 deletions packages/orval/src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ export const normalizeOptions = async (
}
: {}),
},
generateEachHttpStatus: outputOptions.override?.zod?.generateEachHttpStatus ?? false,
},
swr: {
...(outputOptions.override?.swr ?? {}),
Expand Down Expand Up @@ -463,6 +464,7 @@ const normalizeOperationsAndTags = (
}
: {}),
},
generateEachHttpStatus: zod?.generateEachHttpStatus ?? false,
},
}
: {}),
Expand Down
3 changes: 1 addition & 2 deletions packages/zod/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
ZodCoerceType,
generateMutator,
GeneratorMutator,
GlobalMockOptions,
} from '@orval/core';
import uniq from 'lodash.uniq';

Expand Down Expand Up @@ -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][];
Expand Down

0 comments on commit f350fad

Please sign in to comment.