Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSW: Generates Incorrect Schema with MSW + Faker #1775

Open
lorof opened this issue Dec 27, 2024 · 0 comments
Open

MSW: Generates Incorrect Schema with MSW + Faker #1775

lorof opened this issue Dec 27, 2024 · 0 comments
Labels
msw MSW related issues

Comments

@lorof
Copy link

lorof commented Dec 27, 2024

What are the steps to reproduce this issue?

image

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

@melloware melloware added the msw MSW related issues label Dec 27, 2024
@melloware melloware changed the title Orval Generates Incorrect Schema with MSW and Faker MSW: Orval Generates Incorrect Schema with MSW + Faker Dec 27, 2024
@melloware melloware changed the title MSW: Orval Generates Incorrect Schema with MSW + Faker MSW: Generates Incorrect Schema with MSW + Faker Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msw MSW related issues
Projects
None yet
Development

No branches or pull requests

2 participants