Skip to content

Importing Requests from OpenAPI Specification file #121

@ashitaprasad

Description

@ashitaprasad
Member

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.

Activity

ashitaprasad

ashitaprasad commented on Nov 8, 2024

@ashitaprasad
MemberAuthor

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

sajid-31 commented on Dec 21, 2024

@sajid-31

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

ashitaprasad commented on Dec 21, 2024

@ashitaprasad
MemberAuthor

@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

sajid-31 commented on Dec 21, 2024

@sajid-31

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

ashitaprasad commented on Dec 21, 2024

@ashitaprasad
MemberAuthor
sajid-31

sajid-31 commented on Dec 23, 2024

@sajid-31

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

ashitaprasad commented on Dec 23, 2024

@ashitaprasad
MemberAuthor

@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.

2 remaining items

akshayw1

akshayw1 commented on Mar 3, 2025

@akshayw1
Contributor

@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

ashitaprasad commented on Mar 3, 2025

@ashitaprasad
MemberAuthor

@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

akshayw1 commented on Mar 3, 2025

@akshayw1
Contributor

@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

akshayw1 commented on Mar 3, 2025

@akshayw1
Contributor

@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

ashitaprasad commented on Mar 3, 2025

@ashitaprasad
MemberAuthor

@akshayw1 You can send across a draft PR.

akshayw1

akshayw1 commented on Mar 3, 2025

@akshayw1
Contributor

@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 commented on Mar 6, 2025

@akshayw1
Contributor

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Participants

    @ashitaprasad@sajid-31@akshayw1

    Issue actions

      Importing Requests from OpenAPI Specification file · Issue #121 · foss42/apidash