[PR #5950] fix(common): fallback to operation title when summary is missing in O… #5428

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

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5950
Author: @hypergadam
Created: 3/5/2026
Status: 🔄 Open

Base: mainHead: fix/openapi-import-title-fallback


📝 Commits (3)

  • 20948b3 fix(common): fallback to operation title when summary is missing in OpenAPI import
  • 0b6770d fix(openapi): validate operation name candidates are non-empty strings
  • da7180c fix(openapi): prevent non-string values from being used as operation names

📊 Changes

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

View changed files

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

📄 Description

Fix fallback naming for OpenAPI import

Closes #4612

What's changed

  • Extracted a getOperationName helper that centralises request name resolution during OpenAPI/Swagger import
  • Extended the fallback chain from operationId → summary → "Untitled Request" to operationId → summary → title → "Untitled Request"
  • Applied the helper to both makeRESTRequest and makeHoppRESTResponseOriginalRequest call sites in convertPathToHoppReqs
  • Used the existing objectHasProperty type guard to safely access title without introducing any casts

Notes to reviewers

Problem: When importing an OpenAPI/Swagger spec where operations define title but omit both operationId and summary, every request shows as "Untitled Request". Several code-gen tools (e.g. certain Swagger generators) emit title on the operation object as a substitute for summary.

Why title? While title is not part of the official OpenAPI Operation Object schema, it appears in real-world specs often enough to warrant a fallback. The fix uses a safe runtime check (objectHasProperty) so it is a no-op for conforming specs that already have operationId or summary.

Scope: Single file change in packages/hoppscotch-common/src/helpers/import-export/import/openapi/index.ts. No new dependencies, no API changes.

Before:

operationId ?? summary ?? "Untitled Request"

After:

operationId ?? summary ?? title ?? "Untitled Request"

Summary by cubic

Ensure operation "title" is used as a fallback when "summary" is missing during OpenAPI import, so imported requests have better names.
Request names now resolve as: operationId > summary > title > "Untitled Request".

Written for commit 20948b388154bf8e8ea94e1b04b1d92278d0880c. 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/5950 **Author:** [@hypergadam](https://github.com/hypergadam) **Created:** 3/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/openapi-import-title-fallback` --- ### 📝 Commits (3) - [`20948b3`](https://github.com/hoppscotch/hoppscotch/commit/20948b388154bf8e8ea94e1b04b1d92278d0880c) fix(common): fallback to operation title when summary is missing in OpenAPI import - [`0b6770d`](https://github.com/hoppscotch/hoppscotch/commit/0b6770d9ac309e5eccbd1250ead867fcbc8cff31) fix(openapi): validate operation name candidates are non-empty strings - [`da7180c`](https://github.com/hoppscotch/hoppscotch/commit/da7180c7152aa4ffc7dae79bbd0a5b7dd101fdae) fix(openapi): prevent non-string values from being used as operation names ### 📊 Changes **1 file changed** (+25 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/import-export/import/openapi/index.ts` (+25 -2) </details> ### 📄 Description ## Fix fallback naming for OpenAPI import <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> Closes #4612 ### What's changed - [x] Extracted a `getOperationName` helper that centralises request name resolution during OpenAPI/Swagger import - [x] Extended the fallback chain from `operationId → summary → "Untitled Request"` to `operationId → summary → title → "Untitled Request"` - [x] Applied the helper to both `makeRESTRequest` and `makeHoppRESTResponseOriginalRequest` call sites in `convertPathToHoppReqs` - [x] Used the existing `objectHasProperty` type guard to safely access `title` without introducing `any` casts ### Notes to reviewers **Problem:** When importing an OpenAPI/Swagger spec where operations define `title` but omit both `operationId` and `summary`, every request shows as "Untitled Request". Several code-gen tools (e.g. certain Swagger generators) emit `title` on the operation object as a substitute for `summary`. **Why `title`?** While `title` is not part of the official OpenAPI Operation Object schema, it appears in real-world specs often enough to warrant a fallback. The fix uses a safe runtime check (`objectHasProperty`) so it is a no-op for conforming specs that already have `operationId` or `summary`. **Scope:** Single file change in `packages/hoppscotch-common/src/helpers/import-export/import/openapi/index.ts`. No new dependencies, no API changes. **Before:** ``` operationId ?? summary ?? "Untitled Request" ``` **After:** ``` operationId ?? summary ?? title ?? "Untitled Request" ``` --- ## Summary by cubic Ensure operation "title" is used as a fallback when "summary" is missing during OpenAPI import, so imported requests have better names. Request names now resolve as: operationId > summary > title > "Untitled Request". <sup>Written for commit 20948b388154bf8e8ea94e1b04b1d92278d0880c. Summary will update on new commits.</sup> --- <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#5428
No description provided.