mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-16 17:51:48 +01:00
feat: add support for importing collection-level variables from Postman collections
This commit is contained in:
parent
40001949b8
commit
286fb3f46b
@ -166,6 +166,18 @@ const importScriptsFromEvents = (events, requestObject, options, pushTranslation
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const importCollectionLevelVariables = (variables, brunoObject) => {
|
||||||
|
|
||||||
|
const vars = variables.map((v) => ({
|
||||||
|
uid: uuid(),
|
||||||
|
name: v.key,
|
||||||
|
value: v.value,
|
||||||
|
enabled: true
|
||||||
|
}));
|
||||||
|
|
||||||
|
brunoObject.vars.req = vars;
|
||||||
|
};
|
||||||
|
|
||||||
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) => {
|
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) => {
|
||||||
brunoParent.items = brunoParent.items || [];
|
brunoParent.items = brunoParent.items || [];
|
||||||
const folderMap = {};
|
const folderMap = {};
|
||||||
@ -494,6 +506,10 @@ const importPostmanV2Collection = (collection, options) => {
|
|||||||
importScriptsFromEvents(collection.event, brunoCollection.root.request, options, pushTranslationLog);
|
importScriptsFromEvents(collection.event, brunoCollection.root.request, options, pushTranslationLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (collection.variable){
|
||||||
|
importCollectionLevelVariables(collection.variable, brunoCollection.root.request);
|
||||||
|
}
|
||||||
|
|
||||||
importPostmanV2CollectionItem(brunoCollection, collection.item, collection.auth, options);
|
importPostmanV2CollectionItem(brunoCollection, collection.item, collection.auth, options);
|
||||||
|
|
||||||
return brunoCollection;
|
return brunoCollection;
|
||||||
|
Loading…
Reference in New Issue
Block a user