Skip to content

Commit

Permalink
fix: TypeError custom override (#1229)
Browse files Browse the repository at this point in the history
* fix: enum string escape can be nullable

* fix: returntype on custom mock
  • Loading branch information
dipsaus9 committed Feb 19, 2024
1 parent d5ccc8c commit 4f95efb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mock/src/msw/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const generateMSW = (
const handlerName = `get${pascal(operationId)}MockHandler`;

const mockImplementation = isReturnHttpResponse
? `export const ${getResponseMockFunctionName} = (${isResponseOverridable ? `overrideResponse: any = {}` : ''}): ${returnType} => (${value})\n\n`
? `export const ${getResponseMockFunctionName} = (${isResponseOverridable ? `overrideResponse: any = {}` : ''})${mockData ? '' : `: ${returnType}`} => (${value})\n\n`
: '';

const handlerImplementation = `
Expand Down
20 changes: 20 additions & 0 deletions tests/configs/default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,24 @@ export default defineConfig({
target: '../generated/default/example-v3-1/endpoints.ts',
},
},
'override-mock': {
input: '../specifications/petstore.yaml',
output: {
mode: 'split',
mock: true,
schemas: '../generated/default/override-mock/model',
target: '../generated/default/override-mock/endpoints.ts',
override: {
operations: {
listPets: {
mock: {
data: () => {
return {};
},
},
},
},
},
},
},
});

0 comments on commit 4f95efb

Please sign in to comment.