From ca1a4ec31b662e33070c6117baa96f04b52028cc Mon Sep 17 00:00:00 2001 From: nivedin Date: Wed, 14 Feb 2024 19:11:19 +0530 Subject: [PATCH] refactor: update codegen and curlparser --- .../src/components/http/CodegenModal.vue | 22 ++++++++++++++++++- .../src/helpers/curl/curlparser.ts | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-common/src/components/http/CodegenModal.vue b/packages/hoppscotch-common/src/components/http/CodegenModal.vue index 1c7fa178f..3044b548a 100644 --- a/packages/hoppscotch-common/src/components/http/CodegenModal.vue +++ b/packages/hoppscotch-common/src/components/http/CodegenModal.vue @@ -188,11 +188,25 @@ const copyCodeIcon = refAutoReset( const requestCode = computed(() => { const aggregateEnvs = getAggregateEnvs() + const requestVariables = request.value.requestVariables.map( + (requestVariable) => { + if (requestVariable.active) + return { + key: requestVariable.key, + value: requestVariable.value, + secret: false, + } + return [] + } + ) const env: Environment = { v: 1, id: "env", name: "Env", - variables: aggregateEnvs, + variables: [ + ...(requestVariables as Environment["variables"]), + ...aggregateEnvs, + ], } const effectiveRequest = getEffectiveRESTRequest(request.value, env) @@ -212,6 +226,12 @@ const requestCode = computed(() => { active: true, })), endpoint: effectiveRequest.effectiveFinalURL, + requestVariables: effectiveRequest.effectiveFinalRequestVariables.map( + (requestVariable) => ({ + ...requestVariable, + active: true, + }) + ), }) ) diff --git a/packages/hoppscotch-common/src/helpers/curl/curlparser.ts b/packages/hoppscotch-common/src/helpers/curl/curlparser.ts index 155923eee..638680c5b 100644 --- a/packages/hoppscotch-common/src/helpers/curl/curlparser.ts +++ b/packages/hoppscotch-common/src/helpers/curl/curlparser.ts @@ -181,5 +181,6 @@ export const parseCurlCommand = (curlCommand: string) => { testScript: defaultRESTReq.testScript, auth, body: finalBody, + requestVariables: defaultRESTReq.requestVariables, }) }