feat(common): enhance URL parsing to use environment variables on openapi import (#5232)

Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
Anwarul Islam 2025-07-14 14:42:28 +06:00 committed by GitHub
parent 39124fb50d
commit 56c8652990
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -754,6 +754,8 @@ const parseOpenAPIUrl = (
**/
if (objectHasProperty(doc, "swagger")) {
// TODO: dynamically add doc.host, doc.basePath value as variables in the environment if available. or notify user to add it.
// add base url variable to each request
const host = doc.host?.trim() || "<<baseUrl>>"
const basePath = doc.basePath?.trim() || ""
return `${host}${basePath}`
@ -765,7 +767,9 @@ const parseOpenAPIUrl = (
* Relevant v3 reference: https://swagger.io/specification/#server-object
**/
if (objectHasProperty(doc, "servers")) {
return doc.servers?.[0]?.url ?? "<<baseUrl>>"
// TODO: dynamically add server URL value as variable in the environment if available, or notify user to add it.
const serverUrl = doc.servers?.[0]?.url
return !serverUrl || serverUrl === "./" ? "<<baseUrl>>" : serverUrl
}
// If the document is neither v2 nor v3 or missing required fields