Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: unwanted double slashes when importing from openapi (#3745)

Akash K99f5070f71f8
diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts
index febf950eb..29600acf7 100644
--- a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts
+++ b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts
@@ -549,13 +549,19 @@ const convertPathToHoppReqs = (
),
// Construct request object
- RA.map(({ method, info }) =>
- makeRESTRequest({
+ RA.map(({ method, info }) => {
+ const openAPIUrl = parseOpenAPIUrl(doc)
+ const openAPIPath = replaceOpenApiPathTemplating(pathName)
+
+ const endpoint =
+ openAPIUrl.endsWith("/") && openAPIPath.startsWith("/")
+ ? openAPIUrl + openAPIPath.slice(1)
+ : openAPIUrl + openAPIPath
+
+ return makeRESTRequest({
name: info.operationId ?? info.summary ?? "Untitled Request",
method: method.toUpperCase(),
- endpoint: `${parseOpenAPIUrl(doc)}${replaceOpenApiPathTemplating(
- pathName
- )}`,
+ endpoint,
// We don't need to worry about reference types as the Dereferencing pass should remove them
params: parseOpenAPIParams(
@@ -572,7 +578,7 @@ const convertPathToHoppReqs = (
preRequestScript: "",
testScript: "",
})
- ),
+ }),
// Disable Readonly
RA.toArray