fix: improved codegen compat

This commit is contained in:
Andrew Bastin
2021-08-26 13:02:53 +05:30
parent 0b12901344
commit f5c84b57b2
2 changed files with 14 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
<template> <template>
<SmartModal <SmartModal
v-if="show" v-if="show"
:title="$t('request.generate_code')" :title="t('request.generate_code')"
@close="hideModal" @close="hideModal"
> >
<template #body> <template #body>
@@ -35,7 +35,7 @@
</tippy> </tippy>
<div class="flex flex-1 justify-between"> <div class="flex flex-1 justify-between">
<label for="generatedCode" class="px-4 pt-4 pb-4"> <label for="generatedCode" class="px-4 pt-4 pb-4">
{{ $t("request.generated_code") }} {{ t("request.generated_code") }}
</label> </label>
</div> </div>
<SmartAceEditor <SmartAceEditor
@@ -58,14 +58,11 @@
<template #footer> <template #footer>
<ButtonPrimary <ButtonPrimary
ref="copyRequestCode" ref="copyRequestCode"
:label="$t('action.copy')" :label="t('action.copy')"
:icon="copyIcon" :icon="copyIcon"
@click.native="copyRequestCode" @click.native="copyRequestCode"
/> />
<ButtonSecondary <ButtonSecondary :label="t('action.dismiss')" @click.native="hideModal" />
:label="$t('action.dismiss')"
@click.native="hideModal"
/>
</template> </template>
</SmartModal> </SmartModal>
</template> </template>
@@ -90,7 +87,7 @@ const {
$toast, $toast,
app: { i18n }, app: { i18n },
} = useContext() } = useContext()
const $t = i18n.t.bind(i18n) const t = i18n.t.bind(i18n)
const options = ref<any | null>(null) const options = ref<any | null>(null)
@@ -123,7 +120,7 @@ const hideModal = () => emit("hide-modal")
const copyRequestCode = () => { const copyRequestCode = () => {
copyToClipboard(requestCode.value) copyToClipboard(requestCode.value)
copyIcon.value = "done" copyIcon.value = "done"
$toast.success($t("state.copied_to_clipboard").toString(), { $toast.success(t("state.copied_to_clipboard").toString(), {
icon: "content_paste", icon: "content_paste",
}) })
setTimeout(() => (copyIcon.value = "content_copy"), 1000) setTimeout(() => (copyIcon.value = "content_copy"), 1000)

View File

@@ -75,7 +75,7 @@ export type HoppCodegenContext = {
bodyParams: FormDataKeyValue[] bodyParams: FormDataKeyValue[]
rawParams: string | null rawParams: string | null
rawInput: boolean rawInput: boolean
rawRequestBody: any rawRequestBody: string | null
contentType: string | null contentType: string | null
queryString: string queryString: string
} }
@@ -138,6 +138,9 @@ function getCodegenGeneralRESTInfo(
| "headers" | "headers"
> { > {
const urlObj = new URL(request.effectiveFinalURL) const urlObj = new URL(request.effectiveFinalURL)
request.effectiveFinalParams.forEach(({ key, value }) => {
urlObj.searchParams.append(key, value)
})
return { return {
name: request.name, name: request.name,
@@ -168,7 +171,10 @@ function getCodegenReqBodyData(
request.body.contentType === "multipart/form-data" request.body.contentType === "multipart/form-data"
? request.body.body ? request.body.body
: [], : [],
rawParams: null, rawParams:
request.body.contentType !== "multipart/form-data"
? request.body.body
: null,
} }
} }