-
Notifications
You must be signed in to change notification settings - Fork 603
feat(hurl): Implement Hurl file importer for macOS #918
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
base: main
Are you sure you want to change the base?
Conversation
- Implemented Hurl file parser using official hurl_core library via Rust FFI - Added request selection dialog for choosing which requests to import - Supports method, URL, headers, query parameters, form data, JSON body, and basic auth - Integrated Hurl import into main app with new ImportFormat enum entry - Added comprehensive tests for enhanced parsing features - Fixed comprehensive.hurl BasicAuth syntax issue - All parsed requests converted to HttpRequestModel format Resolves foss42#123
- Added multipart form data support (text fields) to Rust parser - Added cookies support, converting to Cookie header in Dart - Enhanced hurl_io.dart to handle multipartParams and cookies - Added advanced_features_test.dart with 4 new tests - All 13 tests passing (basic + advanced features) - Multipart params converted to FormDataModel with type 'text' - Cookies concatenated with semicolon separator - Skipped Options section (not relevant for HTTP request import) Related to foss42#123
- Selection dialog now only appears for Hurl file imports - Other import formats (Postman, Insomnia, HAR) retain original behavior - Import all requests directly without selection - Added proper imports for ImportFormat and HttpRequestModel - Improved code organization with shouldShowSelectionDialog flag - Maintains backward compatibility for existing import workflows
…onsolidate tests - Renamed rust/src/api/simple.rs to hurl_parser.rs for clearer intent - Updated all FFI binding references in Dart generated code - Deleted scattered test files (parser_test.dart, enhanced_parser_test.dart, advanced_features_test.dart) - Created single consolidated hurl_parser_test.dart with 13 tests in 7 logical groups - Removed apidash_core hurl_io_test.dart (FFI limitations make it impractical) - Updated comment style in hurl_io.dart for consistency - Regenerated Flutter Rust Bridge bindings with correct content hash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements Hurl file import functionality for API Dash on macOS using Flutter Rust Bridge to interface with the official hurl_core v7.0.0 Rust library. The implementation parses Hurl files into a simplified JSON format, which is then mapped to API Dash's HttpRequestModel. A new request selection dialog allows users to choose which requests to import from multi-request Hurl files.
Key Changes:
- Added Rust FFI bridge using Flutter Rust Bridge 2.11.1 for Hurl parsing
- Implemented HurlIO class to convert parsed Hurl JSON to HttpRequestModel
- Added request selection dialog for multi-request imports
- Integrated Cargokit build system for automatic Rust compilation
Reviewed changes
Copilot reviewed 61 out of 65 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/hurl/rust/src/api/hurl_parser.rs |
Core Rust parsing logic extracting HTTP request data from Hurl AST |
packages/apidash_core/lib/import_export/hurl_io.dart |
Dart layer converting Hurl JSON to HttpRequestModel with auth/cookie handling |
lib/widgets/dialog_request_selection.dart |
New dialog UI for selective request import from Hurl files |
lib/importer/import_dialog.dart |
Integration of request selection dialog into import flow |
packages/hurl/rust/Cargo.toml |
Rust dependencies including hurl_core 7.0.0 |
packages/hurl/pubspec.yaml |
Flutter package configuration with flutter_rust_bridge 2.11.1 |
lib/main.dart |
RustLib initialization on app startup |
lib/consts.dart |
Added Hurl to ImportFormat enum |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Description
Overview
This pull request implements functional Hurl file import capability for API Dash on macOS, building upon the foundational Flutter Rust Bridge infrastructure established by @WrathOP. Support for other platforms remains a known issue (detailed below), but this provides the foundation.
The implementation utilizes the official
hurl_corev7.0.0 Rust library through FFI, following the architectural direction suggested by @ashitaprasad to leverage Flutter Rust Bridge for generating Dart-readable JSON output from Hurl files.Technical Approach and Key Differences
The current solution utilizes
hurl_core::parser::parse_hurl_file()and manually extracts only the HTTP request-relevant data from the AST, producing a simplified JSON structure tailored for API Dash's data models.This approach addresses the core requirement identified by @ashitaprasad: using Flutter Rust Bridge to parse Hurl files into Dart-readable JSON format, rather than attempting to reimplement the Hurl specification in pure Dart.
Implementation Details
The implementation follows a three-layers:
Rust FFI Bridge (hurl_parser.rs): The Rust layer exposes a single function parse_hurl_to_json(). It uses the official hurl_core library to parse the .hurl file, traverse its AST, and extract relevant request fields (method, URL, headers, bodies, auth, etc.) into a simplified JSON string.
Dart Integration (hurl_io.dart): The HurlIO class consumes this JSON and maps it to API Dash's HttpRequestModel. This layer handles the "business logic" of converting Hurl-specific sections (like [BasicAuth] and [Cookies]) into the standard HTTP headers and models that Apidash understands.
Build System Integration (Cargokit): Cargokit manages the Rust compilation and links the resulting dynamic library into the Flutter app during the build process.
Feature Coverage and Hurl Specification Support
The implementation supports the following Hurl features with varying degrees of completeness:
HTTPVerbenumurl+paramsheaderslist[QueryStringParams]Sectionparams[FormParams]SectionformDatawithContentType.formdata[MultipartFormData]SectionformDatawith type metadata[BasicAuth]SectionAuthorizationheader[Cookies]SectionCookieheaderbodywithContentType.jsonbodywithContentType.text[Options]SectionCritical Limitations and Platform Constraints
FFI Testing Architecture Constraints
The test suite in
hurl_parser_test.dartcannot execute via the standardflutter testcommand due to fundamental FFI architectural limitations. The Dart VM test environment does not include the compiled Rust dynamic library, which is only built during full application compilation throughflutter buildorflutter run. This constraint affects all Flutter FFI implementations and is not specific to this codebase.Platform-Specific Build Requirements: macOS
On macOS, the Hurl Rust library has a transitive dependency on
libxml2for XML parsing capabilities. While macOS includes a systemlibxml2, the Homebrew-installed version is often required for proper compilation. The Podfile requires manual modification after runningflutter create --platforms=macos .to add necessary linker flags:This limitation is inherited from @WrathOP's original implementation. Since the macos directory is Flutter-generated and conventionally excluded from version control, developers must manually apply these modifications. This represents a known documentation gap and a significant friction point for other contributors.
@ashitaprasad - I'm not familiar enough with Cargokit or the Podfile to automate this. Do you have any suggestions on how we could script these linker flags as part of the flutter build process?
Cross-Platform Testing Status and Known Blockers
Testing has been conducted exclusively on macOS (Apple Silicon M-series processor) because that is the machine I own. The implementation theoretically supports all platforms through Cargokit's cross-compilation infrastructure, but the following platforms remain unverified:
Windows: Cargokit should compile successfully on Windows, but Windows-specific linker requirements and
libxml2availability are unknown. The Rust ecosystem supports Windows natively, suggesting likely compatibility, but verification is required.Linux: Expected to work without significant modification, as Linux distributions typically include
libxml2development packages. The dynamic library linking process on Linux may require different configuration than macOS, pending verification.iOS and Android: These platforms face a critical blocker identified by @WrathOP during initial implementation. Mobile platforms do not include
libxml2as a system library, and the Rust crate wrapper used byhurl_coredoes not currently support iOS or Android compilation targets. @WrathOP's extensive investigation documented influtter_rust_bridge_experiment.mddetails the attempted solutions and confirmed this as an unresolved issue.The mobile platform limitation represents the primary outstanding technical challenge for this feature. Potential solutions documented by @WrathOP include using legacy Hurl versions predating the
libxml2dependency, implementing custom XML parsing, or waiting for mobile platform support in the Rustlibxml2wrapper crate. Each approach involves significant trade-offs in terms of maintenance burden, feature completeness, and implementation complexity.Demonstration Video
hurl-implementation.mp4
Related Issues
Checklist
mainbranch before making this PRflutter upgradeand verify)flutter test) and all tests are passingAdded/updated tests?
OS on which you have developed and tested the feature?
Platform Testing Notes:
Development and comprehensive testing were conducted exclusively on macOS running on Apple Silicon (M-series) processors. The implementation utilizes Cargokit for theoretical cross-platform support, but other platforms remain untested in this PR.