@@ -140,11 +140,14 @@ export function compileOperation(
140
140
const parameter = compiler . resolveMaybeRef ( refParameter ) ;
141
141
const paramValueIdentifier = builders . identifier ( `queryParam${ index } ` ) ;
142
142
const resultIdentifier = builders . identifier ( `queryParamResult${ index } ` ) ;
143
+
143
144
const schemaFn = compileValueSchema ( compiler , parameter . schema ) ;
144
145
146
+ const isArrayType = 'type' in parameter . schema && parameter . schema . type === 'array' ;
147
+
145
148
// Assign the query parameter to a variable
146
149
nodes . push (
147
- builders . variableDeclaration ( 'const ' , [
150
+ builders . variableDeclaration ( 'let ' , [
148
151
builders . variableDeclarator (
149
152
paramValueIdentifier ,
150
153
builders . memberExpression (
@@ -179,6 +182,29 @@ export function compileOperation(
179
182
: [ ] ,
180
183
) ,
181
184
builders . blockStatement ( [
185
+ // If expected type is array, convert to array if it's a string
186
+ ...( isArrayType
187
+ ? [
188
+ builders . ifStatement (
189
+ // typeof paramValue === 'string'
190
+ builders . binaryExpression (
191
+ '===' ,
192
+ builders . unaryExpression ( 'typeof' , paramValueIdentifier ) ,
193
+ builders . literal ( 'string' ) ,
194
+ ) ,
195
+ builders . blockStatement ( [
196
+ // paramValue = [paramValue]
197
+ builders . expressionStatement (
198
+ builders . assignmentExpression (
199
+ '=' ,
200
+ paramValueIdentifier ,
201
+ builders . arrayExpression ( [ paramValueIdentifier ] ) ,
202
+ ) ,
203
+ ) ,
204
+ ] ) ,
205
+ ) ,
206
+ ]
207
+ : [ ] ) ,
182
208
// Validate the value
183
209
builders . variableDeclaration ( 'const' , [
184
210
builders . variableDeclarator (
0 commit comments