-
-
Notifications
You must be signed in to change notification settings - Fork 334
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): split polymorphic mocks into its own functions #1365
feat(msw): split polymorphic mocks into its own functions #1365
Conversation
e1be5b4
to
c2f3eb1
Compare
c2f3eb1
to
a7023c4
Compare
@AffeJonsson A conflict occurred when I merged the following PR. Could you please check again and correct it? https://github.com/anymaniax/orval/pulls?q=is%3Apr+is%3Aclosed |
Merged master and did a small update to make overrideResponse param Partial<name>, just like the new overrideResponse code |
Maybe wait with this until #1199 is complete? I assume we might need to change this when it is completed anyway |
@AffeJonsson No, they says it will take time, so we unnecessary wait. And. I'll share it to they. |
it would make sense to regenerate samples example in screenshot has
|
This is no longer the case after your PR was merged, only one overrideResponse is now present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AffeJonsson
Thank you for great update. I check it and commented.
allowOverride, | ||
}); | ||
if (newSchema.allOf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only can objects be separated using oneOf
, but also objects can now be separated using allOf
? ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, I did this backwards. I have now changed this to look at the combine.separator === 'oneOf
instead, which is much better.
packages/mock/src/types.ts
Outdated
@@ -8,6 +8,7 @@ export interface MockDefinition { | |||
name: string; | |||
overrided?: boolean; | |||
includedProperties?: string[]; | |||
functions?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to rename functions
for a couple of reasons.
- It is difficult to tell whether it is a list of typescript
Function
or a collection of function definitions as a string. MockDefinition
already has a fieldvalue
to get the value, so we need to clarify what value this field is.
If it's functions of split mock definition, how about splitMockImplementions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, done!
Seems I broke tests with this, fixing... |
93c0ed2
to
f565863
Compare
f565863
to
c3a6d8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AffeJonsson
I checked again and requested a minor correction. Please check.
packages/mock/src/msw/index.ts
Outdated
); | ||
splitMockImplementations.push(...addedSplitMockImplementations); | ||
const mockImplementations = addedSplitMockImplementations.length | ||
? `//#region ${getResponseMockFunctionName} sub functions\n${addedSplitMockImplementations.join('\n\n')}\n//#endregion\n\n` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to include annotate, I think another way to express them using variable names would be appropriate. Or i think you can just delete it if it's not necessary.
packages/mock/src/msw/mocks.ts
Outdated
}) => { | ||
// console.log(responses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I forgot to turn this off.
@AffeJonsson |
It's ready! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Status
READY
Description
Fixes #1318
This splits response mocks where the response contains objects that have a base object.
The specification in the linked issue is an example of a response mock that will get split.
Todos
Steps to Test or Reproduce
allOf
prop, e.g. the one in the linked issue.