diff --git a/packages/bruno-app/src/utils/importers/openapi-collection.js b/packages/bruno-app/src/utils/importers/openapi-collection.js index 1b6a2dd92..55719e74f 100644 --- a/packages/bruno-app/src/utils/importers/openapi-collection.js +++ b/packages/bruno-app/src/utils/importers/openapi-collection.js @@ -40,9 +40,12 @@ const buildEmptyJsonBody = (bodySchema) => { each(bodySchema.properties || {}, (prop, name) => { if (prop.type === 'object') { _jsonBody[name] = buildEmptyJsonBody(prop); - // handle arrays } else if (prop.type === 'array') { - _jsonBody[name] = []; + if (prop.items && prop.items.type === 'object') { + _jsonBody[name] = [buildEmptyJsonBody(prop.items)]; + } else { + _jsonBody[name] = []; + } } else { _jsonBody[name] = ''; } @@ -164,6 +167,9 @@ const transformOpenapiRequestItem = (request) => { let _jsonBody = buildEmptyJsonBody(bodySchema); brunoRequestItem.request.body.json = JSON.stringify(_jsonBody, null, 2); } + if (bodySchema && bodySchema.type === 'array') { + brunoRequestItem.request.body.json = JSON.stringify([buildEmptyJsonBody(bodySchema.items)], null, 2); + } } else if (mimeType === 'application/x-www-form-urlencoded') { brunoRequestItem.request.body.mode = 'formUrlEncoded'; if (bodySchema && bodySchema.type === 'object') {