mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-25 13:45:52 +00:00
fix: include unsaved changes in generate code
This commit is contained in:
@@ -16,12 +16,20 @@ export const getTreePathFromCollectionToItem = (collection, _itemUid) => {
|
||||
|
||||
// Resolve inherited auth by traversing up the folder hierarchy
|
||||
export const resolveInheritedAuth = (item, collection) => {
|
||||
const request = item.draft?.request || item.request;
|
||||
const authMode = request?.auth?.mode;
|
||||
const mergedRequest = {
|
||||
...(item.request || {}),
|
||||
...(item.draft?.request || {})
|
||||
};
|
||||
|
||||
// If auth is not inherit or no auth defined, return the request as is
|
||||
if (item.request?.url) {
|
||||
mergedRequest.url = item.request.url;
|
||||
}
|
||||
|
||||
const authMode = mergedRequest?.auth?.mode;
|
||||
|
||||
// If auth is not inherit or no auth defined, return the merged request as is
|
||||
if (!authMode || authMode !== 'inherit') {
|
||||
return request;
|
||||
return mergedRequest;
|
||||
}
|
||||
|
||||
// Get the tree path from collection to item
|
||||
@@ -43,7 +51,7 @@ export const resolveInheritedAuth = (item, collection) => {
|
||||
}
|
||||
|
||||
return {
|
||||
...request,
|
||||
...mergedRequest,
|
||||
auth: effectiveAuth
|
||||
};
|
||||
};
|
||||
@@ -2,7 +2,6 @@ import { buildHarRequest } from 'utils/codegenerator/har';
|
||||
import { getAuthHeaders } from 'utils/codegenerator/auth';
|
||||
import { getAllVariables } from 'utils/collections/index';
|
||||
import { interpolateHeaders, interpolateBody, createVariablesObject } from './interpolation';
|
||||
import { resolveInheritedAuth } from './auth-utils';
|
||||
|
||||
const generateSnippet = ({ language, item, collection, shouldInterpolate = false }) => {
|
||||
try {
|
||||
@@ -22,7 +21,7 @@ const generateSnippet = ({ language, item, collection, shouldInterpolate = false
|
||||
});
|
||||
|
||||
// Get the request with resolved auth
|
||||
const request = resolveInheritedAuth(item, collection);
|
||||
const request = item.request;
|
||||
|
||||
// Prepare headers
|
||||
let headers = [...(request.headers || [])];
|
||||
|
||||
Reference in New Issue
Block a user