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

Added insomia importer #525

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Conversation

StormGear
Copy link
Contributor

PR Description

Importer for Insomnia v4 json format for importing into APIDash

Add your description
Insomnia offers the feature to export APIs collection in various formats such as v4 and yaml. In this PR, I implemented importer for Insomnia v4 which is a json format, similar to already existing postman importer. The format specification is not very consistent compared to the export files from Postman. However I managed to implement a working example.

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

Added unit tests for converting json str and json object to InsomniaCollection which is the model used for converting v4 to Dart.

  • Yes
  • No, and this is why:

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

lib/consts.dart Outdated
@@ -141,7 +141,8 @@ enum CodegenLanguage {

enum ImportFormat {
curl("cURL"),
postman("Postman Collection v2.1");
postman("Postman Collection v2.1"),
insomia("Insomnia v4");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insomia -> insomnia

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And correct it everywhere else.

@@ -1,2 +1,3 @@
export 'curl_io.dart';
export 'postman_io.dart';
export 'insomia_io.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling of insomnia is incorrect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename package name to insomnia_collection and change it everywhere as insomnia package name is not available on pub.dev

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you change the name of the folder too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the folder should be collection_examples not collection_examples.dart

@ashitaprasad
Copy link
Member

ashitaprasad commented Jan 9, 2025

The Dart model is incomplete and does not handle environments and body of content type formdata.
Also, the model does not incorporate a field which can help determine the values of isHeaderEnabledList and isParamEnabledList.

@StormGear
Copy link
Contributor Author

All points well noted, I'll make the needed modifications and revert. Thank you.

@StormGear
Copy link
Contributor Author

StormGear commented Jan 12, 2025

The Dart model is now complete with content type formdata. Also the model now is able to determine values for isHeaderEnabledList and isParamEnabledList. However, I'm still working to implement the environment and I would add that commit soon.

@ashitaprasad
Copy link
Member

Sure @StormGear 👍

@StormGear
Copy link
Contributor Author

StormGear commented Jan 13, 2025

@ashitaprasad Please I would like to ask a clarifying question, when importing, does one need to navigate to the "Variables" section to import the environment or when the collection is imported the environment it contains should be automatically added?

PS: To import environment in Postman, one has to navigate to the environment section and import the environment there separate from importing collections.

@ashitaprasad
Copy link
Member

@ashitaprasad Please I would like to ask a clarifying question, when importing, does one need to navigate to the "Variables" section to import the environment or when the collection is imported the environment it contains should be automatically added?

The most important thing is to build insomnia collection model properly such that all data is parsed properly and stored in the Dart model.
How we handle things at fronted and import only relevant items in API Dash is separate thing.
You can give an option where the user can check if he/she wants to import env variable from insomnia collection.

PS: To import environment in Postman, one has to navigate to the environment section and import the environment there separate from importing collections.

You can add import feature in env variables too in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing from Insomnia
2 participants