fix: issues with codegen (#3293)

* fix: fix issues with httpsnippet upgrade

* chore: fix HttpSnippet import
This commit is contained in:
Akash K
2023-08-28 15:57:44 +05:30
committed by GitHub
parent 3e83828722
commit fd162e242c
5 changed files with 274 additions and 184 deletions

View File

@@ -63,7 +63,7 @@
"graphql": "^16.8.0",
"graphql-language-service-interface": "^2.9.1",
"graphql-tag": "^2.12.6",
"httpsnippet": "^2.0.0",
"httpsnippet": "^3.0.1",
"insomnia-importers": "^3.6.0",
"io-ts": "^2.2.20",
"js-yaml": "^4.1.0",
@@ -117,6 +117,7 @@
"@intlify/vite-plugin-vue-i18n": "^7.0.0",
"@relmify/jest-fp-ts": "^2.1.1",
"@rushstack/eslint-patch": "^1.3.3",
"@types/har-format": "^1.2.12",
"@types/js-yaml": "^4.0.5",
"@types/lodash-es": "^4.17.8",
"@types/lossless-json": "^1.0.1",

View File

@@ -98,7 +98,11 @@ const buildHarPostData = (req: HoppRESTRequest): Har.PostData | undefined => {
}
}
export const buildHarRequest = (req: HoppRESTRequest): Har.Request => {
export const buildHarRequest = (
req: HoppRESTRequest
): Har.Request & {
postData: Har.PostData & Exclude<Har.PostData, undefined>
} => {
return {
bodySize: -1, // TODO: It would be cool if we can calculate the body size
headersSize: -1, // TODO: It would be cool if we can calculate the header size
@@ -108,6 +112,9 @@ export const buildHarRequest = (req: HoppRESTRequest): Har.Request => {
method: req.method,
queryString: buildHarQueryStrings(req),
url: req.endpoint,
postData: buildHarPostData(req),
postData: buildHarPostData(req) ?? {
mimeType: "x-unknown",
params: [],
},
}
}

View File

@@ -1,4 +1,4 @@
import * as HTTPSnippet from "httpsnippet"
import { HTTPSnippet } from "httpsnippet"
import { HoppRESTRequest } from "@hoppscotch/data"
import * as O from "fp-ts/Option"
import * as E from "fp-ts/Either"