-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[BUG][kotlin] Make Kotlin client generate comma separated list for array path params #11228
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
[BUG][kotlin] Make Kotlin client generate comma separated list for array path params #11228
Conversation
|
Hi, could you please run the following commands and commit the changes, please? Thanks |
Done, although I see no changes except for the scripts butchering a lot of files by turning paths and file endings into Windows style, and performing some formatting. |
|
Sorry the script did end up creating a lot of noise not related to this command. |
685af6b to
d6fe994
Compare
Reverted and forced pushed the output from the command. Again, there are no changes except for the script re-indenting some lines, and it looks to me like the changes are for the worse. Should I revert this change too, or do we want it? :) |
|
Can you revert it please? |
d6fe994 to
c5c8f07
Compare
Reverted. I tested it locally. I wanted to add a test case, but did not see where or how to test it. If you could give me some pointers to how it would be tested, I could try to add one. |
|
The easiest way would be to create a spec file and a new sample project |
|
Or you could create a new spec file based on another one that already exists, and update one of the kotlin sample projects to use it, this would be much easier |
Just to be clear, when you say one of the kotlin sample projects, which file(s) do you refer to? |
|
The sample projects have a configuration file, for example this one. |
|
Tested with the provided spec and the result is good: The output looks correct: return RequestConfig(
method = RequestMethod.GET,
path = "/{ids}".replace("{"+"ids"+"}", ids.joinToString(",")),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
) |
|
I'll add a CI test after merging this PR |
resolve #7199
The Kotlin client codegen currently cannot handle path params of type array. The code being generated for the path is currently this:
path = "/stuff/{ids}".replace("{"+"ids"+"}", "$ids"). This works fine, but not ifidsis a list or an array, since thetoString()method is used to create the string.With the current code, if
idscontains 123 and 456, thenpathwould be set to:/stuff/[123,456]ifcollectionTypeis list./stuff/[Ljava.lang.String;@6a98f353ifcollectionTypeis array.In both cases,
/stuff/123,456is the expected result.If we change the code from
path = "/stuff/{ids}".replace("{"+"ids"+"}", "$ids")to
path = "/stuff/{ids}".replace("{"+"ids"+"}", ids.joinToString(",")),we get the expected result.
OpenAPI Spec demonstrating this:
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master(5.3.0),6.0.x@jimschubert @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m