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(common): handle missing host and basePath in OpenAPI URL parsing (#4908)

Anwarul Islam5f3a7754d598
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 2678389dc..1d4516ed2 100644
--- a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts
+++ b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts
@@ -745,7 +745,9 @@ const parseOpenAPIUrl = (
**/
if (objectHasProperty(doc, "swagger")) {
- return `${doc.host}${doc.basePath}`
+ const { host = "<<baseUrl>>", basePath = "" } =
+ doc satisfies OpenAPIV2.Document
+ return `${host}${basePath}`
}
/**