question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] [DART][DART-DIO] API calls using parameters that take Lists are not being made correctly

See original GitHub issue

Bug Report Checklist

  • [✔ ] Have you provided a full/minimal spec to reproduce the issue?
  • [ ✔] Have you validated the input using an OpenAPI validator (example)?
  • [✔ ] What’s the version of OpenAPI Generator used? 4.3.1
  • [ ✔] Have you search for related issues/PRs? Yes, without fruition
  • [✔ ] What’s the actual output vs expected output?
Description

I’ve got an API generated using the dart-dio class that has an API call where some of the parameters take lists of strings. On those parameters the API call seems to insert [] (or the HTTP character encoding equivalent) before the = of the api request. e.g. http://komga.my.domain/api/v1/books?read_status[]=IN_PROGRESS when it should look like: https://komga.my.domain/api/v1/books?read_status=IN_PROGRESS

If you pass more than one item in the list, e.g. bookApi.getAllBooks(readStatus: ["IN_PROGRESS","READ"]) then the API request looks like this:

http://komga.my.domain/api/v1/books?read_status%5B%5D=IN_PROGRESS&read_status%5B%5D=READ when it should look like this: https://komga.my.domain/api/v1/books?read_status=READ&read_status=IN_PROGRESS

openapi-generator version

latest stable - 4.3.1

OpenAPI declaration file content or url

https://demo.komga.org/v3/api-docs/REST API

Command line used for generation

java -jar .\openapi-generator-cli.jar generate -i '.\REST API.json' -g dart-dio --additional-properties=dateLibrary=timemachine -o .\komga_api_client\ -c .\config.yaml

(the config.yaml merely contains some purely aesthetic parameters around branding)

I have a copy of the generated code in a github repo here - https://github.com/frameset/komga_api_client

Steps to reproduce

You could clone my github repo https://github.com/frameset/komga_client into an android studio project, open the screens\serverhome.dart page and modify line 101 to read: future: bookApi.getAllBooks(readStatus: ["IN_PROGRESS"]), Then start the app in an emulator and enter the server details Server: demo.komga.org Username: demo@komga.org Password: komga-demo

You may need to capture the http traffic in some way as dart devtools does not have this facility yet.

Related issues/PRs

I could not find something that closely matches the problem.

Suggest a fix

I am unsure personally, as this is beyond my understanding.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kuhnroyalcommented, Mar 4, 2021

There is a partial solution for this available in dio 4.0.0 but that requires breaking changes in the generator.

1reaction
kuhnroyalcommented, Jan 7, 2021

I am really interested in getting this fixed but Dio seems inactive atm. We could provide a custom DioPatched and RequestOptionsPatched class that does this correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RESTful API - Correct behaviour when spurious/not requested ...
We were wondering what is the correct behaviour when non requested/not expected parameters are passed along with the required ones. For example, we...
Read more >
Step 3: Parameters (API reference tutorial) | Documenting APIs
APIs may not process the parameter correctly if it's the wrong data type or wrong format. Listing the data type is usually a...
Read more >
Understanding And Using REST APIs - Smashing Magazine
Everything you need to know about REST APIs, from start to finish. How and why to use REST APIs, how to deal with...
Read more >
Use query parameters to customize responses - Microsoft Graph
For example, instead of $filter , you can use filter . On the v1 endpoint, the $ prefix is optional for only a...
Read more >
API Calls: What They Are & How to Make Them in 5 Easy Steps
If you're not familiar with JSON, that might look intimidating. So you can use Excel to make the call and get a simple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found