fix: include unsaved changes in generate code

This commit is contained in:
pooja-bruno
2025-06-27 12:56:21 +05:30
parent ff0ceb2879
commit 1d6566679b
2 changed files with 14 additions and 7 deletions

View File

@@ -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
};
};

View File

@@ -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 || [])];