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: import openapi file servers url detection (#4373)

Claudio Pennati35a471f1208e
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 1ea2a758b..c2db7c2b0 100644
--- a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts
+++ b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts
@@ -735,7 +735,7 @@ const parseOpenAPIUrl = (
* Relevant v3 reference: https://swagger.io/specification/#server-object
**/
if (objectHasProperty(doc, "servers")) {
- return doc.servers?.[0].url ?? "<<baseUrl>>"
+ return doc.servers?.[0]?.url ?? "<<baseUrl>>"
}
// If the document is neither v2 nor v3 then return a env variable as placeholder