[PR #2372] [CLOSED] feat: export hoppscotch collections as openapi document #3762

Closed
opened 2026-03-17 01:20:57 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/2372
Author: @amk-dev
Created: 5/27/2022
Status: Closed

Base: mainHead: feat/hopp-to-openapi


📝 Commits (10+)

  • 2d70183 feat: add basic hopp collection to open api converter functional
  • c52fd7a test: add sample test for openapi conversion
  • 1dd2214 feat: add openapi converter
  • 59b89df refactor: make generateOpenApiRequestBody functional
  • 68b7bb9 refactor: update types for hopp request body
  • 95d364f test: add tests for openapi body generation
  • 1ea3112 fix: add condition for empty body and content type
  • 9ed8c4e feat: add auth support
  • bdce14e feat: support for folders
  • de7594f feat: add getDataToWrite function

📊 Changes

14 files changed (+1690 additions, -817 deletions)

View changed files

📝 packages/hoppscotch-app/components/collections/ImportExport.vue (+50 -8)
📝 packages/hoppscotch-app/helpers/functional/json.ts (+10 -0)
packages/hoppscotch-app/helpers/import-export/export/__tests__/openapi.spec.ts (+887 -0)
📝 packages/hoppscotch-app/helpers/import-export/export/hopp.ts (+4 -3)
📝 packages/hoppscotch-app/helpers/import-export/export/index.ts (+52 -11)
packages/hoppscotch-app/helpers/import-export/export/openapi.ts (+468 -0)
packages/hoppscotch-app/jest-shims.d.ts (+7 -0)
📝 packages/hoppscotch-app/jest.setup.js (+35 -0)
📝 packages/hoppscotch-app/locales/en.json (+15 -6)
📝 packages/hoppscotch-app/package.json (+1 -0)
📝 packages/hoppscotch-data/package.json (+1 -1)
📝 packages/hoppscotch-data/src/rest/content-types.ts (+9 -0)
📝 packages/hoppscotch-data/src/rest/index.ts (+12 -8)
📝 pnpm-lock.yaml (+139 -780)

📄 Description

Closes #2092

Description

feature to export Hoppscotch collections as an Open API document.

Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

Additional Information

Problems to tackle / limitations

1. No Support For Enviornment Variables
1. Openapi doesn't support enviornment variables anywhere other than the server url
2. One way to tackle this is to replace env variables with their values when exporting, but sensitive env variables may get exported, not good from a security standpoint. but seems like the practical thing to do.
2. Openapi doesn't support giving values for authentication. eg: we can define the auth scheme is basic auth, but won't be able to give the username and password.
1. Workaround might be to generate the headers and add them to the headers object

3. When we convert a hopp collection to open api document, there are possible chances for missing data,
for eg: lets say we have two requests
1.POST https://jsonplaceholder.com/posts
2.POST https://someotherinfo.com/posts with some different body
So right now we don't have a way to represent these two requests in one openapi document. workaround might be to generate multiple openapi documents


🔄 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/2372 **Author:** [@amk-dev](https://github.com/amk-dev) **Created:** 5/27/2022 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/hopp-to-openapi` --- ### 📝 Commits (10+) - [`2d70183`](https://github.com/hoppscotch/hoppscotch/commit/2d7018385e367cf130eb36fdd657698e2b5b6afa) feat: add basic hopp collection to open api converter functional - [`c52fd7a`](https://github.com/hoppscotch/hoppscotch/commit/c52fd7a8dc811d49e69eb021434a39e098fb148e) test: add sample test for openapi conversion - [`1dd2214`](https://github.com/hoppscotch/hoppscotch/commit/1dd2214d4f64ebd729034879645974014ddfad6e) feat: add openapi converter - [`59b89df`](https://github.com/hoppscotch/hoppscotch/commit/59b89df4f719b507aad9b9dffd78f100fcf9d6ac) refactor: make generateOpenApiRequestBody functional - [`68b7bb9`](https://github.com/hoppscotch/hoppscotch/commit/68b7bb95ed7606dcd1b27c8f96bb96b1762c193e) refactor: update types for hopp request body - [`95d364f`](https://github.com/hoppscotch/hoppscotch/commit/95d364f4a472110120f6111940144715e3ec7342) test: add tests for openapi body generation - [`1ea3112`](https://github.com/hoppscotch/hoppscotch/commit/1ea31121442436398ca17cf05cdf4685cf02ed1e) fix: add condition for empty body and content type - [`9ed8c4e`](https://github.com/hoppscotch/hoppscotch/commit/9ed8c4ed630ec7f044b5d01a00b78bfd2da79132) feat: add auth support - [`bdce14e`](https://github.com/hoppscotch/hoppscotch/commit/bdce14e02c79ca2e0a26eee448b08d0c2cd63b2d) feat: support for folders - [`de7594f`](https://github.com/hoppscotch/hoppscotch/commit/de7594f52f5bfe6875912fc701936fd6f0d304e5) feat: add getDataToWrite function ### 📊 Changes **14 files changed** (+1690 additions, -817 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-app/components/collections/ImportExport.vue` (+50 -8) 📝 `packages/hoppscotch-app/helpers/functional/json.ts` (+10 -0) ➕ `packages/hoppscotch-app/helpers/import-export/export/__tests__/openapi.spec.ts` (+887 -0) 📝 `packages/hoppscotch-app/helpers/import-export/export/hopp.ts` (+4 -3) 📝 `packages/hoppscotch-app/helpers/import-export/export/index.ts` (+52 -11) ➕ `packages/hoppscotch-app/helpers/import-export/export/openapi.ts` (+468 -0) ➕ `packages/hoppscotch-app/jest-shims.d.ts` (+7 -0) 📝 `packages/hoppscotch-app/jest.setup.js` (+35 -0) 📝 `packages/hoppscotch-app/locales/en.json` (+15 -6) 📝 `packages/hoppscotch-app/package.json` (+1 -0) 📝 `packages/hoppscotch-data/package.json` (+1 -1) 📝 `packages/hoppscotch-data/src/rest/content-types.ts` (+9 -0) 📝 `packages/hoppscotch-data/src/rest/index.ts` (+12 -8) 📝 `pnpm-lock.yaml` (+139 -780) </details> ### 📄 Description <!-- 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 #2092 ### Description feature to export Hoppscotch collections as an Open API document. <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Checks <!-- Make sure your pull request passes the CI checks and do check the following fields as needed - --> - [x] My pull request adheres to the code style of this project - [ ] My code requires changes to the documentation - [ ] I have updated the documentation as required - [x] All the tests have passed ### Additional Information <!-- Any additional information like breaking changes, dependencies added, screenshots, comparisons between new and old behavior, etc. --> Problems to tackle / limitations ~~1. No Support For Enviornment Variables 1. Openapi doesn't support enviornment variables anywhere other than the server url 2. One way to tackle this is to replace env variables with their values when exporting, but sensitive env variables may get exported, not good from a security standpoint. but seems like the practical thing to do. 2. Openapi doesn't support giving values for authentication. eg: we can define the auth scheme is basic auth, but won't be able to give the username and password. 1. Workaround might be to generate the headers and add them to the headers object~~ 3. When we convert a hopp collection to open api document, there are possible chances for missing data, for eg: lets say we have two requests 1.POST https://jsonplaceholder.com/posts 2.POST https://someotherinfo.com/posts with some different body So right now we don't have a way to represent these two requests in one openapi document. workaround might be to generate multiple openapi documents --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 01:20:57 +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#3762
No description provided.