refactor: update codegen and curlparser

This commit is contained in:
nivedin
2024-02-14 19:11:19 +05:30
committed by Andrew Bastin
parent 359633102e
commit ca1a4ec31b
2 changed files with 22 additions and 1 deletions

View File

@@ -188,11 +188,25 @@ const copyCodeIcon = refAutoReset<typeof IconCopy | typeof IconCheck>(
const requestCode = computed(() => { const requestCode = computed(() => {
const aggregateEnvs = getAggregateEnvs() 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 = { const env: Environment = {
v: 1, v: 1,
id: "env", id: "env",
name: "Env", name: "Env",
variables: aggregateEnvs, variables: [
...(requestVariables as Environment["variables"]),
...aggregateEnvs,
],
} }
const effectiveRequest = getEffectiveRESTRequest(request.value, env) const effectiveRequest = getEffectiveRESTRequest(request.value, env)
@@ -212,6 +226,12 @@ const requestCode = computed(() => {
active: true, active: true,
})), })),
endpoint: effectiveRequest.effectiveFinalURL, endpoint: effectiveRequest.effectiveFinalURL,
requestVariables: effectiveRequest.effectiveFinalRequestVariables.map(
(requestVariable) => ({
...requestVariable,
active: true,
})
),
}) })
) )

View File

@@ -181,5 +181,6 @@ export const parseCurlCommand = (curlCommand: string) => {
testScript: defaultRESTReq.testScript, testScript: defaultRESTReq.testScript,
auth, auth,
body: finalBody, body: finalBody,
requestVariables: defaultRESTReq.requestVariables,
}) })
} }