MSW: Generates Incorrect Schema with MSW + Faker #1775
Open
Description
What are the steps to reproduce this issue?
const LimitOrderBatchReplaceObject = z.object({ orderId: z.string() }).and(
z.object({ success: z.literal(true) }).or(
z.object({
success: z.literal(false),
failReason: z.string(),
}),
),
);
export type PutApiOrderLimit200ItemAllOf = {
orderId: string;
};
export type PutApiOrderLimit200ItemAllOfTwo = PutApiOrderLimit200ItemAllOfTwoAnyOf | PutApiOrderLimit200ItemAllOfTwoAnyOfTwo;
export type PutApiOrderLimit200ItemAllOfTwoAnyOf = {
success: true;
};
export type PutApiOrderLimit200ItemAllOfTwoAnyOfTwo = {
failReason: string;
success: boolean;
};
msw
(
Array.from(
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1
).map(() => ({
orderId: faker.word.sample(),
{ success: faker.datatype.boolean() },
{ failReason: faker.word.sample() }
}))
)
What were you expecting to happen?
export type PutApiOrderLimit200ItemAllOf = {
orderId: string;
};
export type PutApiOrderLimit200ItemAllOfTwo = PutApiOrderLimit200ItemAllOfTwoAnyOf | PutApiOrderLimit200ItemAllOfTwoAnyOfTwo;
export type PutApiOrderLimit200ItemAllOfTwoAnyOf = {
success: true;
};
export type PutApiOrderLimit200ItemAllOfTwoAnyOfTwo = {
failReason: string;
success: false;
};
msw
Array.from(
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => ({
orderId: faker.word.sample(),
success: faker.datatype.boolean(),
failReason: faker.word.sample()
})
);
Any logs, error output, etc?
Any other comments?
What versions are you using?
orval version: 7.3.0