Repository navigation
fix(kotlin-client): read API class properties through this. in jvm-volley - #25692
Merged
wing328 merged 1 commit intoNov 30, 2026
Merged
Conversation
…lley In the jvm-volley library, generated API classes referenced their own properties (requestQueue, requestFactory, basePath, postProcessors) unqualified inside the suspendCoroutine block. An operation parameter with the same name shadowed the member: basePath silently replaced the configured URL with the parameter value, and requestFactory, postProcessors and requestQueue collisions did not even compile. Qualify all member references with this.; spec parameters stay unqualified and still reach the wire. context is left alone because it is read only inside a constructor default value (the requestQueue lazy initializer), where operation arguments cannot reach it and so cannot shadow it. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
khayashi4337
added a commit
to khayashi4337/openapi-generator
that referenced
this pull request
Dec 1, 2026
The following fixes were extracted into separate PRs and no longer belong here; revert them to upstream/master so that this PR now only carries the OpenAPI 3.2 changes. | fix | what | original commits | split-out PR | |-----|------|------------------|--------------| | A1 | kotlin jvm-vertx form sending | parts of 75be8f4, 7f1bcb8 | OpenAPITools#25623 | | A2 | kotlin ktor/multiplatform form `it` | parts of 07530ab, 3a953e5, f1575f3, 7f1bcb8 | OpenAPITools#25624 | | A3 | kotlin `$` escaping | parts of 9074531, 7f1bcb8 | OpenAPITools#25625 | | A4 | kotlin member reads via `this.` | 94aca3a, 19694ac (main part) | OpenAPITools#25691, OpenAPITools#25692 | | A5 | kotlin param/generated-local collisions | rename part of 6b82674 | OpenAPITools#25690 | | A6 | kotlin deepObject keys | 910b590 | OpenAPITools#25622 | | A7 | core form required (allOf) | 7ab9da5, bc20a2c | OpenAPITools#25627 | | A8 | php internal-variable collisions | 9f2676e, a00d51c (keeping the 3.2 capture/fixture parts) | OpenAPITools#25630 | | A9 | csharp webhook input models | webhook-scan part of e49e09e | OpenAPITools#25626 | | A10 | core unexpected-attribute regex | widen part of e5ec5f4 | OpenAPITools#25621 | This PR now only carries the OpenAPI 3.2 changes. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #25691, same approach for
jvm-volley.The
jvm-volleyAPI classes read their own propertiesrequestFactory,basePath,postProcessorsandrequestQueuewithoutthis.. In Kotlin a function parameter hides a class property with the same name, so a spec parameter with one of these names replaces the property inside that operation. On master,jvm-volleygenerates:basePath, the request goes to the parameter's value instead of the configured base path. This fails silently.requestFactory,postProcessorsorrequestQueue, the generated code does not compile. I checkedrequestFactorywithkotlinc(unresolved reference 'build').Fix
jvm-volley/api.mustachenow reads the four properties throughthis.:this.requestFactory.build("${this.basePath}$path"this.postProcessors.forEachthis.requestQueue.value.addAll four are directly inside the receiver-less
suspendCoroutine { continuation -> ... }lambda, sothisis the API class. They are outside theResponse.Listener/Response.ErrorListenerlambdas. I compiled and ran the same shape withkotlinc: with a parameterbasePath = "http://WRONG", the qualified version uses the property"http://localhost".The fifth property,
context, is only read in the constructor's default value forrequestQueue, where operation parameters are not in scope, so it cannot collide.Parameters keep their names; the generated signatures do not change.
Not covered here
The operation's own locals can also collide with parameter names:
body,contentTypes,contentType,path,formParams,queryParamsandheaderParams. For example, a query parameter namedpathsends the URL path as its value. Neither this PR, #25691 nor #25690 renames them. Renaming them touches lines that #25690's test asserts and that #25625 changes, so I'd rather do it after those are settled.Relation to other open PRs
this.qualification tojvm-vertx. The two PRs are independent, except that both add a test toKotlinClientCodegenApiTest.$in wire-name string literals #25625 changes lines 63–85 of the same template (escapeDollar), and this PR changes lines 98–112. The template changes merge without conflict.jvm-volleylines and does not touch these four. Only the test file overlaps.Whichever PR is merged later needs a rebase of the test file, which I will do.
Tests
KotlinClientCodegenApiTest.testJvmVolleyApiClassMembersAreThisQualified(new) generatesjvm-volley(gson) from3_0/kotlin/kotlin-volley-member-collision.yaml, whose query parameters are named after the properties. It checks:this.;./mvnw -nsu -Denforcer.skip=true -pl modules/openapi-generator -am -Dtest=KotlinClientCodegenApiTest -Dsurefire.failIfNoSpecifiedTests=false testtestJvmVolleyApiClassMembersAreThisQualifiedfailsthis.basePathremovedtestJvmVolleyApiClassMembersAreThisQualifiedfailsSamples
There is no
bin/configsentry for thejvm-volleylibrary, so no samples change. This also means CI does not compilejvm-volleyoutput. The compile check above was done withkotlinc, on a class of the same shape, not on a generated client.cc @wing328 and the Kotlin technical committee: @karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l @AndreyVMarkelov
PR checklist
jvm-volley, so there is nothing to regenerate.export_docs_generators.shnot run: no generator option or metadata changes.Commit all changed files.
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*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
🤖 Generated with Claude Code
Summary by cubic
Qualifies the
jvm-volleyAPI class property reads withthis.so operation parameters no longer shadow them. On master, a query parameter namedbasePathsilently replaces the configured base URL, and parameters namedrequestFactory,postProcessors, orrequestQueuegenerate code that does not compile.Parameter names and generated signatures are unchanged.
contextstays unqualified because it is only read in a constructor default value where operation parameters are not in scope.Tests
testJvmVolleyApiClassMembersAreThisQualified, which generates from a spec whose query parameters are named after the four properties and verifies the property reads are this-qualified while the parameters still reach the wire under their own names.Written for commit 74576e1. Summary will update on new commits.