[PR #4917] [MERGED] feat(common): lenient OpenAPI imports #4990

Closed
opened 2026-03-17 02:28:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4917
Author: @anwarulislam
Created: 3/19/2025
Status: Merged
Merged: 4/9/2025
Merged by: @jamesgeorge007

Base: patchHead: fix/openapi-import-issue


📝 Commits (5)

  • 04ecaf1 fix(common): openapi import issue
  • a87c570 feat(common): add support for detecting unresolved references in documents
  • 9fafd68 chore: clean up
  • ba0d210 fix: improve unresolved references detection in OpenAPI documents
  • 9bd6adb chore: cleanup

📊 Changes

1 file changed (+73 additions, -29 deletions)

View changed files

📝 packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts (+73 -29)

📄 Description

Closes HFE-792 #4297 #4850

While importing OpenAPI a particular OpenAPI JSON file is being failed. This PR addresses that issue. It includes several changes to the OpenAPI importer to improve error handling, logging, and validation logic. The most important changes include making the validation less strict, adding detailed logging, and handling errors more gracefully during the importing process.

OpenAPI JSON File:
A-E.V3_OpenAPI.json

What's changed

  • Made validation less strict for basic OpenAPI documents by allowing either title or version in the info section to be present instead of requiring both. (packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts)
  • Not Completed
  • Completed

Notes to reviewers

  • Added detailed logging for the validation process, including logging the OpenAPI spec being validated and any errors encountered. (packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts)
  • Improved error handling by logging errors when parsing file contents as JSON or YAML, and when validation or dereferencing fails. (packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts) [1] [2] [3]

🔄 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/4917 **Author:** [@anwarulislam](https://github.com/anwarulislam) **Created:** 3/19/2025 **Status:** ✅ Merged **Merged:** 4/9/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `patch` ← **Head:** `fix/openapi-import-issue` --- ### 📝 Commits (5) - [`04ecaf1`](https://github.com/hoppscotch/hoppscotch/commit/04ecaf19c41bb83e8feeb515ac883db892269e2a) fix(common): openapi import issue - [`a87c570`](https://github.com/hoppscotch/hoppscotch/commit/a87c570643c1b3849f5d3ad0f57f8bb6a3d09c77) feat(common): add support for detecting unresolved references in documents - [`9fafd68`](https://github.com/hoppscotch/hoppscotch/commit/9fafd68196204c38788e52bab1ee7e1de97b3210) chore: clean up - [`ba0d210`](https://github.com/hoppscotch/hoppscotch/commit/ba0d210509d24142c093e86b99412fcd3d463be7) fix: improve unresolved references detection in OpenAPI documents - [`9bd6adb`](https://github.com/hoppscotch/hoppscotch/commit/9bd6adbca38092e540adc5d74cb8c4f8b3cea6ea) chore: cleanup ### 📊 Changes **1 file changed** (+73 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts` (+73 -29) </details> ### 📄 Description Closes HFE-792 #4297 #4850 While importing OpenAPI a particular OpenAPI JSON file is being failed. This PR addresses that issue. It includes several changes to the OpenAPI importer to improve error handling, logging, and validation logic. The most important changes include making the validation less strict, adding detailed logging, and handling errors more gracefully during the importing process. OpenAPI JSON File: [A-E.V3_OpenAPI.json](https://github.com/user-attachments/files/19339876/A-E.V3_OpenAPI.json) ### What's changed * Made validation less strict for basic OpenAPI documents by allowing either `title` or `version` in the `info` section to be present instead of requiring both. (`packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts`) - [ ] Not Completed - [x] Completed ### Notes to reviewers * Added detailed logging for the validation process, including logging the OpenAPI spec being validated and any errors encountered. (`packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts`) * Improved error handling by logging errors when parsing file contents as JSON or YAML, and when validation or dereferencing fails. (`packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts`) [[1]](diffhunk://#diff-c7992f56eb17c0444eeca92f7d651940427aefe0456922f71006559db1f49062R922) [[2]](diffhunk://#diff-c7992f56eb17c0444eeca92f7d651940427aefe0456922f71006559db1f49062R989-R995) [[3]](diffhunk://#diff-c7992f56eb17c0444eeca92f7d651940427aefe0456922f71006559db1f49062R1007-R1025) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:28:39 +03:00
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#4990
No description provided.