Skip to content

Commit ee01104

Browse files
authoredMar 19, 2024
fix(swr): make sure to not include comma when not valid while generating swrMutationFetcher (#1271)
1 parent 54df332 commit ee01104

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎packages/swr/src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,9 @@ export const ${swrKeyFnName} = (${queryKeyProps}) => [\`${route}\`${
703703
export const ${swrMutationFetcherName} = (${swrProps} ${swrMutationFetcherOptions}) => {
704704
return (_: string, ${swrMutationFetcherArg}: { arg: Arguments }): ${swrMutationFetcherType} => {
705705
return ${operationName}(${httpFnProperties}${
706-
swrMutationFetcherOptions.length ? ', options' : ''
706+
swrMutationFetcherOptions.length
707+
? (httpFnProperties.length ? ', ' : '') + 'options'
708+
: ''
707709
});
708710
}
709711
}\n`;

‎tests/configs/swr.config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,15 @@ export default defineConfig({
145145
},
146146
},
147147
},
148+
nestedArrays: {
149+
output: {
150+
target: '../generated/swr/nested-arrays/endpoints.ts',
151+
schemas: '../generated/swr/nested-arrays/model',
152+
client: 'swr',
153+
mock: true,
154+
},
155+
input: {
156+
target: '../specifications/arrays.yaml',
157+
},
158+
},
148159
});

0 commit comments

Comments
 (0)
Please sign in to comment.