mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 12:45:38 +00:00
Merge pull request #4995 from pooja-bruno/fix/include-unsaved-changes-in-generate-code
fix: include unsaved changes in generate code
This commit is contained in:
@@ -16,12 +16,16 @@ 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
|
||||
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 +47,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 {
|
||||
@@ -21,15 +20,14 @@ const generateSnippet = ({ language, item, collection, shouldInterpolate = false
|
||||
processEnvVars: collection.processEnvVariables || {}
|
||||
});
|
||||
|
||||
// Get the request with resolved auth
|
||||
const request = resolveInheritedAuth(item, collection);
|
||||
const request = item.request;
|
||||
|
||||
// Prepare headers
|
||||
let headers = [...(request.headers || [])];
|
||||
|
||||
// Add auth headers if needed
|
||||
if (request.auth && request.auth.mode !== 'none') {
|
||||
const authHeaders = getAuthHeaders(request.auth, variables);
|
||||
const authHeaders = getAuthHeaders(collection.root.request.auth, request.auth);
|
||||
headers = [...headers, ...authHeaders];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user