feat(export): add Insomnia v5 JSON export option#10071
Open
hexbinoct wants to merge 10 commits into
Open
Conversation
Insomnia v5 (app v11) can only export collections/workspaces as YAML. Many people export specifically to share with other tooling (e.g. Postman) or to diff/process the result with JSON tools, and lost JSON export in the v4 -> v5 transition (Kong#8672). This adds a non-destructive "Insomnia v5 (JSON)" choice alongside the existing YAML and HAR options. YAML stays the default, so the v5 diff-friendly sync format is unchanged. - getInsomniaV5DataExport takes an optional `format: 'yaml' | 'json'` (default 'yaml') and serializes the same validated InsomniaFile through a single serialize() helper, so YAML and JSON outputs are the same data. - The export-type modal offers JSON; the collection and project/folder export paths thread the format through and pick the .json/.yaml extension. - Import detection recognizes JSON-serialized v5 files (a `{` object with the `*.insomnia(.rest)?/5.0` type discriminator) in addition to YAML, so a JSON export round-trips back in. tryImportV5Data already validates with zod and never throws. - Tests: JSON export is valid JSON, equals the YAML export's data, and is detected as `insomnia-5` on re-import.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #8672.
Since the v4 → v5 format change, collections/workspaces can only be exported
as YAML. A lot of people export specifically to hand the file to other tooling
(Postman compatibility comes up repeatedly in the issue) or to diff/process it
with JSON tools, and JSON export disappeared in that transition.
I understand from #8672 that YAML was chosen deliberately to keep the sync
format diff-friendly, so this change is purely additive: it adds an
"Insomnia v5 (JSON)" option next to the existing YAML and HAR options.
YAML stays the default and the sync format is untouched.
What changed
getInsomniaV5DataExportnow accepts an optionalformat: 'yaml' | 'json'(default
'yaml'). All five workspace scopes build the same validatedInsomniaFileand serialize through a singleserialize()helper, so theYAML and JSON outputs are guaranteed to be the same data.
the project/folder export paths thread the chosen format through and write
the matching
.json/.yamlextension.{objectcarrying the
*.insomnia(.rest)?/5.0type discriminator) as well as YAML,so a JSON export can be re-imported.
tryImportV5Dataalready validates withzod and returns errors instead of throwing, so no extra error handling was
needed.
Testing
npm run type-check -w packages/insomnia✅eslinton the changed files ✅vitestforinsomnia-v5.test.tsandimport.test.ts✅ (57 passing)New tests assert that the JSON export is valid JSON, contains the same data as
the YAML export, and is detected as
insomnia-5when scanned for import.Notes