feat(#1130): file upload schema updates

This commit is contained in:
Anoop M D
2024-02-05 02:52:03 +05:30
parent 634f9ca4a2
commit 09e7ea0d4d
15 changed files with 88 additions and 50 deletions

View File

@@ -256,6 +256,7 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
return map(params, (param) => {
return {
uid: param.uid,
type: param.type,
name: param.name,
value: param.value,
description: param.description,
@@ -520,10 +521,6 @@ export const refreshUidsInItem = (item) => {
return item;
};
export const isLocalCollection = (collection) => {
return collection.pathname ? true : false;
};
export const deleteUidsInItem = (item) => {
delete item.uid;
const params = get(item, 'request.params', []);

View File

@@ -11,10 +11,6 @@ export const isElectron = () => {
return window.ipcRenderer ? true : false;
};
export const isLocalCollection = (collection) => {
return collection.pathname ? true : false;
};
export const resolveRequestFilename = (name) => {
return `${trim(name)}.bru`;
};

View File

@@ -71,6 +71,18 @@ export const transformItemsInCollection = (collection) => {
}
delete item.request.query;
// from 5 feb 2024, multipartFormData needs to have a type
// this was introduced when we added support for file uploads
// below logic is to make older collection exports backward compatible
let multipartFormData = _.get(item, 'request.body.multipartForm');
if (multipartFormData) {
_.each(multipartFormData, (form) => {
if (!form.type) {
form.type = 'text';
}
});
}
}
if (item.items && item.items.length) {

View File

@@ -152,6 +152,7 @@ const transformInsomniaRequestItem = (request, index, allRequests) => {
each(request.body.params, (param) => {
brunoRequestItem.request.body.multipartForm.push({
uid: uuid(),
type: 'text',
name: param.name,
value: param.value,
description: param.description,

View File

@@ -168,6 +168,7 @@ const transformOpenapiRequestItem = (request) => {
each(bodySchema.properties || {}, (prop, name) => {
brunoRequestItem.request.body.multipartForm.push({
uid: uuid(),
type: 'text',
name: name,
value: '',
description: prop.description || '',

View File

@@ -144,8 +144,9 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => {
if (bodyMode === 'formdata') {
brunoRequestItem.request.body.mode = 'multipartForm';
each(i.request.body.formdata, (param) => {
brunoRequestItem.request.body.formUrlEncoded.push({
brunoRequestItem.request.body.multipartForm.push({
uid: uuid(),
type: 'text',
name: param.key,
value: param.value,
description: param.description,