Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Git Sync): Introduce Git Projects #8382

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/insomnia/src/common/insomnia-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,23 @@ export async function getInsomniaV5DataExport(workspaceId: string) {

function getSpecFromResources(resources: ApiSpec[]): Extract<InsomniaFile, { type: 'spec.insomnia.rest/5.0' }>['spec'] {
const spec = resources[0];
const parser = spec.contentType === 'json' ? JSON.parse : parse;
// const parser = spec.contentType === 'json' ? JSON.parse : parse;
let contents = {};

try {
contents = JSON.parse(spec.contents);
} catch (err) {
// @TODO For some reason switching a spec from JSON to YAML doesn't update it's content type so we need to handle both here
// This must be fixed in the apiSpec model
try {
contents = parse(spec.contents);
} catch (err) {
console.error('Failed to parse spec contents', err);
}
}
return {
// @TODO In the future we want to support also reading from a file like this: file: resources[0].fileName,
contents: parser(resources[0].contents),
contents,
meta: {
id: spec._id,
created: spec.created,
Expand Down
Loading
Loading