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

fix(msw): changed naming convention for response mock functions to avoid function name conflicts #1217

Merged

Conversation

soartec-lab
Copy link
Member

Status

READY

Description

fix #1106

This issue is occur when the path name and operationId are the same. So a rare case because operationId is usually used like addXX or getXXX, but i will fix it because it causes unintended problems for users.

orval gets the mock name from title, which is the same naming convention as the response mock.

response mock function naming

`get${pascal(operationId)}Mock`;

mock function naming

`get${pascal(title)}Mock`,

Ref: https://github.com/anymaniax/orval/blob/master/packages/orval/src/client.ts#L172

Therefore, I changed the response mock function name.
It's a breaking change, but out of all my ideas, I decided to do this because it has the least impact.

Related PRs

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

  1. specify mock: true in orval.config.js
  2. execute orval
  3. check the name change in the generated mock function

@soartec-lab soartec-lab added the bug Something isn't working label Feb 12, 2024
@soartec-lab soartec-lab added this to the 6.25.0 milestone Feb 12, 2024
@melloware melloware merged commit e528e11 into orval-labs:master Feb 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate function name in msw when route depth is one, e.g. /NotWorking
2 participants