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

Add feature to support url params having the same key and different values #276

Closed

Conversation

aryanraj
Copy link

PR Description

NEED HELP

In order to support duplicate search params, the type of paramsMap in RequestModel was changed from Map<String, String> to Map<String, dynamic> which matches with the queryParameters which is accepted by the Uri constructor.

Going through the documentation for Uri class I have found that there are two properties, queryParameters and queryParametersAll of which former supports duplicate query parameters by returning Map<String, List<String>> object. Similar behaviour is also observed in NodeJS [URLSearchParams] where we have urlSearchParams.get and urlSearchParams.getAll.Therefore, all the occurrences of Uri.queryParameters were changed to Uri.queryParametersAll.

The response sent also have query parameters as expected.
Screenshot 2024-03-11 at 4 37 42 PM

This however, breaks all the codegen tests as the earlier expectation was to override query params. Therefore, I have updated the requestModelGet3 to accept query params.

/// GET request model with duplicate query params
const requestModelGet3 = RequestModel(
  id: 'get3',
  url: 'https://api.apidash.dev/country/data?code=US&code=UK',
  method: HTTPVerb.get,
  requestParams: [
    NameValueModel(name: 'code', value: 'IN'),
    NameValueModel(name: 'code', value: 'JP'),
  ],
);

I have fixed the codegen for curl, but will need help to change codegen for other languages/frameworks also.
Screenshot 2024-03-11 at 5 03 44 PM

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes
  • No, and this is why: please replace this line with details on why tests have not been included

@aryanraj aryanraj marked this pull request as ready for review March 11, 2024 14:44
@animator animator changed the title Add feature duplicate search params Add feature to support url params having the same key and different values Mar 12, 2024
@animator
Copy link
Member

Reviewing this issue & PR might take some time as it will have major changes across the project. I recommend you to keep this PR open, but start working on some other issue.

@ashitaprasad
Copy link
Member

Closing this PR due to conflicts.

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.

Can not pass multiple query parameters with same key name
3 participants