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

feat(msw): define the return value type in the msw mock function. #1171

Conversation

soartec-lab
Copy link
Member

@soartec-lab soartec-lab commented Jan 23, 2024

Status

READY

Description

Define the return value type in the msw mock function.
Since the type of the model is used as the type to return, in split, split-tag, and tags modes, the list of imports required by the mock is similar to the http client.

Related PRs

none

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

Outline the steps to test or reproduce the PR here.

> git pull --prune
> git checkout <branch>
> grunt jasmine
  1. Specify basic pet schema as input
  2. execute orval
orval
  1. generated mock function bellow:

The return type is specified.

export const getListPetsMock = (overrideResponse?: any): Pets =>
  Array.from(
    { length: faker.number.int({ min: 1, max: 10 }) },
    (_, i) => i + 1,
  ).map(() => ({
    id: faker.number.int({ min: undefined, max: undefined }),
    name: faker.word.sample(),
    tag: faker.helpers.arrayElement([faker.word.sample(), undefined]),
    ...overrideResponse,
  }));

export const getShowPetByIdMock = (overrideResponse?: any): Pet => ({
  id: faker.number.int({ min: undefined, max: undefined }),
  name: faker.word.sample(),
  tag: faker.helpers.arrayElement([faker.word.sample(), undefined]),
  ...overrideResponse,
});

@soartec-lab soartec-lab marked this pull request as draft January 23, 2024 09:41
@soartec-lab soartec-lab force-pushed the feat/specify-return-type-in-mock-values-gene-fn branch from 7bbd7dc to d36acc4 Compare January 28, 2024 00:52
@soartec-lab soartec-lab marked this pull request as ready for review January 28, 2024 01:04
@soartec-lab
Copy link
Member Author

soartec-lab commented Jan 28, 2024

This PR became ready, so please review🙌

@melloware melloware added this to the 6.24.0 milestone Jan 28, 2024
@melloware melloware added the enhancement New feature or request label Jan 28, 2024
@melloware melloware merged commit 99cc5a6 into orval-labs:master Jan 28, 2024
2 checks passed
soartec-lab added a commit to soartec-lab/orval that referenced this pull request Feb 5, 2024
soartec-lab added a commit to soartec-lab/orval that referenced this pull request Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants