support for params having multiple values
PR Description
The request parameters were previously handled as a Map<String, String>. I have updated this to Map<String, List<string> to support multiple values
Additionally, I have modified the relevant implementations to accommodate this change.
Related Issues
- Closes #268
Checklist
- [x] I have reviewed the contributing guide.
- [x] My branch is up to date and synced with the project's
mainbranch before creating this PR. - [x] I am using the latest stable Flutter version (
flutter upgradeverified). - [x] I have run all tests (
flutter test), and they pass successfully.
Added/Updated Tests?
We encourage contributors to add relevant test cases.
- [x] Yes
- [ ] No
Development & Testing Environment
- [ ] Windows
- [ ] Android
- [x] Linux
@ashitaprasad I am familiar with the codebase; however, I need to explore the test files further before making the necessary updates. I plan to work on that after updating codegen for all languages. In the meantime, please review the implementation and share your feedback.
@animator I request you to take a look(Feedback on the major changes is enough) . I've updated the code generation for all supported languages to handle parameters with multiple values. Before I move on to writing/updating tests, I just want to ensure that all changes are aligned with expectations .
@badnikhil do not conversations as resolved. You have to comment if you have fixed it, then the reviewer verifies the fix and marks it is resolved.
@badnikhil do not conversations as resolved. You have to comment if you have fixed it, then the reviewer verifies the fix and marks it is resolved.
Sorry about that, I’ll keep it in mind from now on.
@animator i have resolved the datatypes.. Also updated a widget test.
rows are now List
+796 ~1 -431: Some tests failed.
431 tests failed
+796 ~1 -431: Some tests failed.
431 tests failed
Tests for Codegen are not updated yet(as mentioned earlier )..
01:13 +383 ~1 -1: Some tests failed.
(this does not include codegen folder)
All other are passing except #646 and
00:13 +174 ~1 -1: /home/badnikhil/Desktop/apidash/test/models/http_request_model_test.dart: Testing getters [E]
Expected: {'size': '2', 'len': '3'}
Actual: {'size': ['2'], 'len': ['3']}
Which: at location ['size'] is ['2'] instead of '2'
package:matcher expect
test/models/http_request_model_test.dart 36:5 main.<fn>
Updated it to List,adding commit .
The approach has been reviewed. Please fix all the codegen tests so that the PR can be merged.
The approach has been reviewed. Please fix all the codegen tests so that the PR can be merged.
Updating as soon as possible
Also, why major code changes have been made to codegens?
Also, why major code changes have been made to codegens?
URL inside the swift code ->"https://postman-echo.com/get?param2=value4¶m1=v2"
Explanation ->
The params are added to the URL using
var rec = getValidRequestUri(requestModel.url, requestModel.enabledParams); -> uri_utils in apidash_core
Here the value of key(param) is replaced inside the function ..
and then query params are added to the uri..
So, an issue when we have multiple values for same key... codegen needs to be updated for the enhancement intended in this PR this was one thing.. Second is that in some codegen logics the params are directly added to the URL.. everything works well and get a short code but its hard to find param/values in the URL.. instead the params are handled seperately outside the URL for a convenience in editing the code manually..
var urlComponents = URLComponents(string: "https://postman-echo.com/get")!
var queryItems = [URLQueryItem]()
queryItems.append(URLQueryItem(name: "param1", value: "value1"))
queryItems.append(URLQueryItem(name: "param1", value: "value2"))
queryItems.append(URLQueryItem(name: "param2", value: "value3"))
queryItems.append(URLQueryItem(name: "param2", value: "value4"))
urlComponents.queryItems = queryItems
let requestUrl = urlComponents.url!
var request = URLRequest(url: requestUrl)
request.httpMethod = "GET"
request.addValue("asda", forHTTPHeaderField: "asd")
let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
defer { semaphore.signal() }
if let error = error {
print("Error: \(error.localizedDescription)")
return
}
guard let data = data else {
print("No data received")
return
}
if let responseString = String(data: data, encoding: .utf8) {
print("Response: \(responseString)")
}
}
task.resume()
semaphore.wait()
Here the changes can be made more easily
If you want params directly added to URL instead of handling seperately inside code Then the changes can be significantly reduced..
Thanks for the explanation. As mentioned earlier please update the tests for all the codegens.
@animator! Would appreciate a quick review whenever you're free —to move on to the next issue.