[PR #5986] fix(import): include scheme in OpenAPI v2 base URL #5450

Open
opened 2026-03-17 02:53:24 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5986
Author: @mahmoodhamdi
Created: 3/13/2026
Status: 🔄 Open

Base: mainHead: fix/openapi-v2-scheme-in-url


📝 Commits (3)

  • acbb172 fix(import): include scheme in OpenAPI v2 base URL
  • ca5c6c5 fix(import): avoid prefixing scheme to baseUrl placeholder
  • c9859f8 fix: use || for scheme fallback to handle empty strings

📊 Changes

1 file changed (+4 additions, -2 deletions)

View changed files

📝 packages/hoppscotch-common/src/helpers/import-export/import/openapi/index.ts (+4 -2)

📄 Description

Description

When importing Swagger 2.0 (OpenAPI v2) specifications, the base URL is currently built from only host and basePath, completely ignoring the schemes array. This produces URLs like api.example.com/v1 instead of https://api.example.com/v1.

For example, given this Swagger 2.0 spec:

host: petstore.swagger.io
basePath: /v2
schemes:
  - https

The importer currently generates: petstore.swagger.io/v2
Expected: https://petstore.swagger.io/v2

Changes

In parseOpenAPIUrl, read the first entry from doc.schemes (falling back to https when the array is absent or empty) and prepend it to the constructed URL.

Testing

  • All 680 existing tests in hoppscotch-common pass
  • Full typecheck passes across all packages
  • Lint passes (0 errors, only pre-existing warnings)

Summary by cubic

Include the scheme when constructing the base URL for Swagger 2.0 (OpenAPI v2) imports. Imported requests now use the correct protocol (e.g., https://petstore.swagger.io/v2).

  • Bug Fixes
    • Prefix base URL with the first schemes entry; fall back to https when the array is missing or the entry is empty.
    • When host is missing, return <<baseUrl>> without a scheme to avoid double-scheme URLs after substitution.

Written for commit c9859f868e. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5986 **Author:** [@mahmoodhamdi](https://github.com/mahmoodhamdi) **Created:** 3/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/openapi-v2-scheme-in-url` --- ### 📝 Commits (3) - [`acbb172`](https://github.com/hoppscotch/hoppscotch/commit/acbb172c7b1b499f7f2ef04c39f4b5b200233208) fix(import): include scheme in OpenAPI v2 base URL - [`ca5c6c5`](https://github.com/hoppscotch/hoppscotch/commit/ca5c6c5c6e2d8354dbfea48988c8169df53bf2c3) fix(import): avoid prefixing scheme to baseUrl placeholder - [`c9859f8`](https://github.com/hoppscotch/hoppscotch/commit/c9859f868e517f7022c34b2d96241e8152a1fad0) fix: use || for scheme fallback to handle empty strings ### 📊 Changes **1 file changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/import-export/import/openapi/index.ts` (+4 -2) </details> ### 📄 Description ### Description When importing Swagger 2.0 (OpenAPI v2) specifications, the base URL is currently built from only `host` and `basePath`, completely ignoring the `schemes` array. This produces URLs like `api.example.com/v1` instead of `https://api.example.com/v1`. For example, given this Swagger 2.0 spec: ```yaml host: petstore.swagger.io basePath: /v2 schemes: - https ``` The importer currently generates: `petstore.swagger.io/v2` Expected: `https://petstore.swagger.io/v2` ### Changes In `parseOpenAPIUrl`, read the first entry from `doc.schemes` (falling back to `https` when the array is absent or empty) and prepend it to the constructed URL. ### Testing - All 680 existing tests in `hoppscotch-common` pass - Full typecheck passes across all packages - Lint passes (0 errors, only pre-existing warnings) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Include the scheme when constructing the base URL for Swagger 2.0 (OpenAPI v2) imports. Imported requests now use the correct protocol (e.g., https://petstore.swagger.io/v2). - **Bug Fixes** - Prefix base URL with the first `schemes` entry; fall back to `https` when the array is missing or the entry is empty. - When `host` is missing, return `<<baseUrl>>` without a scheme to avoid double-scheme URLs after substitution. <sup>Written for commit c9859f868e517f7022c34b2d96241e8152a1fad0. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5450
No description provided.