add tests for https://github.com/oapi-codegen/oapi-codegen/issues/2183#2184
add tests for https://github.com/oapi-codegen/oapi-codegen/issues/2183#2184TelpeNight wants to merge 6 commits intooapi-codegen:mainfrom
Conversation
|
Please have a look at TelpeNight#1, I sent you a PR with the fix. WE can merge all in one once you approve. There's a limitation dependent on a runtime bug. I'll fix that separately. |
|
Oh, and you will need to rebase for CI to pass. |
The generated client code was round-tripping styled query parameter fragments through url.ParseQuery + url.Values.Encode(), which re-encoded comma delimiters as %2C. Per the OpenAPI spec, form/explode=false arrays should use literal commas as delimiters (e.g. color=blue,black,brown). Change the client template to collect pre-encoded fragments from StyleParamWithLocation and join them directly, bypassing the re-encoding. Also moves the issue-2183 test to internal/test/issues/issue-2183/, extends it with explode=true and multi-param cases, and documents the remaining server-side limitation (oapi-codegen/runtime#91) for values containing embedded commas. Fixes oapi-codegen#2183 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Greptile SummaryThis PR fixes issue #2183 by changing how styled query parameters are assembled in the generated client code: instead of routing them through Key observations:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| internal/test/issues/issue-2183/communication_test.go | New test file verifying the client-side serialization and server-side round-trip for OpenAPI query parameter styles. Missing test coverage for mixed styled + non-styled (passthrough/JSON) parameter scenarios. |
| pkg/codegen/templates/client.tmpl | Core template fix: styled params now bypass url.ParseQuery/url.Values.Encode to preserve comma delimiters. Introduces a behavior change where styled params always appear before passthrough/JSON params in the final query string. |
Last reviewed commit: 917dbdc
|
Could you allow maintainers to push changes to your branch in the PR settings so that I can resolve the conflicts and merge, or could you do a rebase and fix them yourself? |
|
Hello. I've opened access to maintainers. |
|
I've tried to resolve conflicts myself. But after regenerating tests, some of them start to fail. According to the specification New implementation seems to violate this. So I don't think it is ready to be merged. |
# Conflicts: # internal/test/any_of/param/param.gen.go # internal/test/parameters/parameters.gen.go # internal/test/schemas/schemas.gen.go # pkg/codegen/templates/client.tmpl
|
I resolved the conflicts, but we've caused a behavior regression with these changes (the CI will fail). I'm digging into it more. There is a behavioral change in how parameters are encoded now |
I need to think about this more, it's complex.
|
I pushed a fix which still encodes parameter names, but honestly, I am unsure if this is proper behavior. There's also an OpenAPI parameter property, This code is also very old with an I've removed the approval for this PR for the moment while I think about this. |
|
I believe that the better approach is to be spec compliant. Even |
|
After studding the runtime source a little bit, I think that it lacks a good test suit for serialisation/deserialisation process. The case I've started this issue from comes directly from oapi spec. Nothing extra-ordinal to be honest. |
I've added tests for #2183
But maybe adding more test cases would be helpful. It is pretty generic.
SpecQuery can be commented our to prevent comparison. In this case first test will pass, the second will fail.