You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You will see, that the generated not-working.msw.ts looks like this:
/** * Generated by orval v6.22.1 🍺 * Do not edit manually. * API Documentation * API documentation for selected endpoints. * OpenAPI spec version: 1.0.0 */import{faker}from'@faker-js/faker';import{HttpResponse,delay,http}from'msw';// see duplicate function declaration below, only happens if only one endpoint is present per tag in swagger.jsonexportconstgetNotWorkingMock=()=>({accessToken: faker.helpers.arrayElement([faker.word.sample(),undefined])});// Cannot redeclare block-scoped variable 'getNotWorkingMock'.exportconstgetNotWorkingMock=()=>[http.get('http://localhost:8080/NotWorking',async()=>{awaitdelay(1000);returnnewHttpResponse(JSON.stringify(getNotWorkingMock()),{status: 200,headers: {'Content-Type': 'application/json',},});}),];
What happens?
Two functions with the same name are exported from the not-working.msw.ts file if only one endpoint is present for a tag in the swagger.json file.
What were you expecting to happen?
The first function should be called differently and used inside the second function.
Any logs, error output, etc?
I do see the warning Failed to parse provided mutator function in the console but could not figure out where that came from.
Any other comments?
Many thanks for developing this great tool!
What versions are you using?
Operating System: macOS 14.1.1 Package Version:
"orval": "6.22.1"
"msw": "2.0.10", Browser Version: -
The text was updated successfully, but these errors were encountered:
Apparently if the route is only 1 deep, e.g. /not-working and is the only route with that tag, e.g. , "tags": ["NotWorking"], the issue occurs.
If the route is 2 deep, e.g. /working/deep and is the only route with a tag, e.g. "tags": ["Working"], it works as expected.
SetupCoding
changed the title
Cannot redeclare block-scoped variable in mock service worker when only one route is present per tag
Duplicate function name in msw when route depth is one, e.g. /not-working
Dec 20, 2023
SetupCoding
changed the title
Duplicate function name in msw when route depth is one, e.g. /not-working
Duplicate function name in msw when route depth is one, e.g. /NotWorking
Dec 20, 2023
Hi @SetupCoding, Thanks for creating this report.
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.
What are the steps to reproduce this issue?
not-working.msw.ts
looks like this:What happens?
Two functions with the same name are exported from the
not-working.msw.ts
file if only one endpoint is present for a tag in the swagger.json file.What were you expecting to happen?
The first function should be called differently and used inside the second function.
Any logs, error output, etc?
I do see the warning
Failed to parse provided mutator function
in the console but could not figure out where that came from.Any other comments?
Many thanks for developing this great tool!
What versions are you using?
Operating System: macOS 14.1.1
Package Version:
Browser Version: -
The text was updated successfully, but these errors were encountered: