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

Importing Requests from OpenAPI Specification file #121

Open
ashitaprasad opened this issue Feb 22, 2024 · 15 comments · May be fixed by #634
Open

Importing Requests from OpenAPI Specification file #121

ashitaprasad opened this issue Feb 22, 2024 · 15 comments · May be fixed by #634
Labels
good first issue Good for newcomers import-export Import into from other formats & Export from API Dash priority: high

Comments

@ashitaprasad
Copy link
Member

ashitaprasad commented Feb 22, 2024

Tell us about the task you want to perform and are unable to do so because the feature is not available
Add support for importing requests from the json or yaml files in OpenAPI 3 and Swagger 2 data formats. The developed code should be able to parse the data & examples provided in the specs, let user choose the requests he wants to add to the API Dash collection and create the corresponding request items.

@ashitaprasad ashitaprasad added enhancement New feature or request good first issue Good for newcomers import-export Import into from other formats & Export from API Dash labels Feb 22, 2024
@ashitaprasad
Copy link
Member Author

Update: The frontend is already implemented.
The only change required will be the addition on OpenAPI in ImportFormat enum and adding the parser code.

@sajid-31
Copy link

OPENAPI specification document contains multiple endpoints and these endpoints branched into folders based on tags and into sub-folders based on /paths
The POSTMAN implementation creates a separate collection on importing openapi file and maintains branching based on tags and endpoints.
But I'm not sure if APIDASH has nested collections.
Rightnow, I'm implementing the parser using DART:CONVERT package.
The basic implementation will add all the endpoints by parsing them into HttpRequestModel
Can I proceed with this approach?

@ashitaprasad
Copy link
Member Author

@sajid-31 You can use this package to parse the OpenAPI spec file - https://pub.dev/packages/openapi_spec
Since OpenAPI spec is usually a dump of all the endpoints, once you have the parsed results, you should focus on allowing user to select the endpoints they want to include and add request models to the collections for the selected endpoints.

@sajid-31
Copy link

There is no documentation for openapi_spec. I'm not sure how to implement using this package.
Can you provide a resource which might help me understand this package.
Or should I look for alternatives?

@ashitaprasad
Copy link
Member Author

https://pub.dev/documentation/openapi_spec/latest/openapi_spec/

@sajid-31
Copy link

Query parameters can be added directly to the request model for each request endpoint.
How should path parameters be handled?
Since these can be accessed through environment variables, is it better to create a new environment for an OPENAPI JSON/YAML file upload and add the path parameters as variables, or should they be added to the global variables?

@ashitaprasad
Copy link
Member Author

@sajid-31 There is no need to create a new environment. You can add path parameters enclosed as{{param}} in the URL itself. It will get highlighted in red and user can create the requisite environment variable or replace it with a hardcoded string as per personal preference.

@akshayw1
Copy link
Contributor

akshayw1 commented Mar 3, 2025

@ashitaprasad , I will work on this just few question for clarification, and my approach being by adding OpenAPI to our ImportFormat enum and building a parser with the openapi_spec package. Where I will extract endpoints, parameters, and examples from JSON/YAML specifications, then let users select which endpoints they want to add to their API Dash collection. I'll convert selected endpoints to RequestModel objects, handling path parameters, query parameters, and headers appropriately.

  • Where in the existing UI should I integrate the OpenAPI import option, and which component handles the current import functionality?

  • Will the entire implementation be client-side in Flutter, or should some parsing logic be handled server-side, large OpenAPI specifications that might impact Flutter's performance ?

I'd like to know if anyone has previously started work on this feature or if I need to build it from scratch, As as you mentioned UI is completed for these right?

@akshayw1
Copy link
Contributor

akshayw1 commented Mar 3, 2025

@ashitaprasad, I successfully set up the application locally and explored it. If you can answer my query, I can kickstart the issue. Also, while using the application, I noticed how it allows importing from a Postman collection. Similarly, in the same kind of UI, we would need to add OpenAPI specs, right, to conclude?

@ashitaprasad
Copy link
Member Author

@ashitaprasad , I will work on this just few question for clarification, and my approach being by adding OpenAPI to our ImportFormat enum and building a parser with the openapi_spec package. Where I will extract endpoints, parameters, and examples from JSON/YAML specifications, then let users select which endpoints they want to add to their API Dash collection. I'll convert selected endpoints to RequestModel objects, handling path parameters, query parameters, and headers appropriately.

  • Where in the existing UI should I integrate the OpenAPI import option, and which component handles the current import functionality?
  • Will the entire implementation be client-side in Flutter, or should some parsing logic be handled server-side, large OpenAPI specifications that might impact Flutter's performance ?

I'd like to know if anyone has previously started work on this feature or if I need to build it from scratch, As as you mentioned UI is completed for these right?

@akshayw1 Figuring out answers to these questions are part of the task.

@akshayw1
Copy link
Contributor

akshayw1 commented Mar 3, 2025

@ashitaprasad, I have everything figured out and can start now. I asked for confirmation earlier, but no worries—I’ll implement the integration similar to what we have for Postman and Insomnia, but for OpenAPI.

@akshayw1
Copy link
Contributor

akshayw1 commented Mar 3, 2025

@ashitaprasad I have completed work on the issue. Now, I can import OpenAPI JSON or YAML files, select/delete items via a dialog, and import them into the side panel. Below is the demo video of implementation—please review it, and if everything looks good, I'll proceed with the PR.

Screen.Recording.2025-03-03.at.8.42.30.PM.mp4

@ashitaprasad
Copy link
Member Author

@akshayw1 You can send across a draft PR.

@akshayw1
Copy link
Contributor

akshayw1 commented Mar 3, 2025

@akshayw1 You can send across a draft PR.

Okay will do , Just wanted to confirm the flow seems correct right? Will make PR in morning

@akshayw1 akshayw1 linked a pull request Mar 4, 2025 that will close this issue
9 tasks
@akshayw1
Copy link
Contributor

akshayw1 commented Mar 6, 2025

@ashitaprasad I would appreciate it if you could review the PR. If there are any issues, please let me know, and I'll be happy to address them promptly. It's been open for over 48 hours now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers import-export Import into from other formats & Export from API Dash priority: high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants