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
Use an Orval configuration with client: 'react-query' and mock: { type: 'msw', generateEachHttpStatus: true, ... }
What happens?
Orval generates two mock functions and two mock handler functions that are completely identical:
exportconstgetProjectInsightsQueryResponseMock=(): InsightsResponse=>({// A very long mock definition});exportconstgetProjectInsightsQueryResponseMock200=(): InsightsResponse=>({// Exactly the same mock definition, again});exportconstgetProjectInsightsQueryMockHandler=(overrideResponse?:
|InsightsResponse|((info: Parameters<Parameters<typeofhttp.get>[1]>[0])=>Promise<InsightsResponse>|InsightsResponse))=>{returnhttp.get('*/data/analytics/projects/:projectId/insights',async(info)=>{returnnewHttpResponse(JSON.stringify(overrideResponse!==undefined
? typeofoverrideResponse==='function'
? awaitoverrideResponse(info)
: overrideResponse
: getProjectInsightsQueryResponseMock()),{status: 200,headers: {'Content-Type': 'application/json',},});});};exportconstgetProjectInsightsQueryMockHandler200=(overrideResponse?:
|InsightsResponse|((info: Parameters<Parameters<typeofhttp.get>[1]>[0])=>Promise<InsightsResponse>|InsightsResponse))=>{// Duplicate of getProjectInsightsQueryMockHandlerreturnhttp.get('*/data/analytics/projects/:projectId/insights',async(info)=>{returnnewHttpResponse(JSON.stringify(overrideResponse!==undefined
? typeofoverrideResponse==='function'
? awaitoverrideResponse(info)
: overrideResponse
: getProjectInsightsQueryResponseMock200()),{status: 200,headers: {'Content-Type': 'application/json',},});});};
What were you expecting to happen?
This works, but the duplication unnecessarily bloats the generated MSW file.
IMO the ideal output would be for getProjectInsightsQueryResponseMock to just be an alias of getProjectInsightsQueryResponseMock200, and same for getProjectInsightsQueryMockHandler.
For example:
exportconstgetProjectInsightsQueryResponseMock200=(): InsightsResponse=>({// Long mock definition});exportconstgetProjectInsightsQueryResponseMock=getProjectInsightsQueryResponseMock200;exportconstgetProjectInsightsQueryMockHandler200=(overrideResponse?:
|InsightsResponse|((info: Parameters<Parameters<typeofhttp.get>[1]>[0])=>Promise<InsightsResponse>|InsightsResponse))=>{// Omitted};exportconstgetProjectInsightsQueryMockHandler=getProjectInsightsQueryResponseMock200;
Any logs, error output, etc?
N/A
Any other comments?
This is not high priority request. Functionally, generateEachHttpStatus=true works fine.
Though I believe there is benefit in the output of orval being clean and easy to read, since that contributes towards a positive DevEx.
What versions are you using?
Operating System: Does not matter for the issue Package Version: 0.30.2 Browser Version: Does not matter for the issue
The text was updated successfully, but these errors were encountered:
What are the steps to reproduce this issue?
Use an Orval configuration with
client: 'react-query'
andmock: { type: 'msw', generateEachHttpStatus: true, ... }
What happens?
Orval generates two mock functions and two mock handler functions that are completely identical:
What were you expecting to happen?
This works, but the duplication unnecessarily bloats the generated MSW file.
IMO the ideal output would be for
getProjectInsightsQueryResponseMock
to just be an alias ofgetProjectInsightsQueryResponseMock200
, and same forgetProjectInsightsQueryMockHandler
.For example:
Any logs, error output, etc?
N/A
Any other comments?
This is not high priority request. Functionally,
generateEachHttpStatus=true
works fine.Though I believe there is benefit in the output of orval being clean and easy to read, since that contributes towards a positive DevEx.
What versions are you using?
Operating System: Does not matter for the issue
Package Version: 0.30.2
Browser Version: Does not matter for the issue
The text was updated successfully, but these errors were encountered: