Repository navigation
test(kotlin-client): compile gson anyOf/oneOf wrappers for [number, string] - #25693
Merged
wing328 merged 1 commit intoNov 16, 2026
Merged
Conversation
…tring] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
No issues found across 1 file
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Re-trigger cubic
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.
Adds a regression test that generates the
kotlinclient withjvm-retrofit2+serializationLibrary=gson+generateOneOfAnyOfWrappers=truefor ananyOf [number, string]and aoneOf [number, string]schema, then compiles the generated model sources withKotlinTestUtils.buildModuleand checks that both wrapper classes (AnyOfValue,OneOfValue) load.This was requested by @AndreyVMarkelov in review of #25246. That PR rewrites the gson error messages in
kotlin-client/anyof_class.mustacheand leaves a trailing comma after the Number message inside arequire { }block:require(jsonElement.getAsJsonPrimitive().isNumber()) { "Expected json element to be of type Number in the JSON string but got `${jsonElement}`", }Existing tests only check the generated text, so they don't catch this. Compiling the output does.
KotlinClientCodegenModelTest#testGsonAnyOfOneOfNumberStringWrappersCompilesrc/test/resources/3_0/kotlin/issue25452-anyof-oneof-number.yaml, which already has exactly oneanyOfand oneoneOfoverstring/numberand nothing elseVerified locally:
anyof_class.mustache: fails to compile withAnyOfValue.kt:104:117: error: unexpected tokens (use ';' to separate expressions on the same line). Column 117 is that trailing comma.Run it with:
PR checklist
Kotlin TC: @karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l @AndreyVMarkelov
🤖 Generated with Claude Code
Summary by cubic
Adds a regression test that compiles the generated Kotlin client sources for
anyOf/oneOf [number, string]wrappers withjvm-retrofit2andserializationLibrary=gson. Existing tests only check generated text, so they miss syntax errors like the trailing comma in the Number error message insideanyof_class.mustachethat breaksAnyOfValue.kt; the new test fails on that output.The test is
KotlinClientCodegenModelTest#testGsonAnyOfOneOfNumberStringWrappersCompileand reuses the existingissue25452-anyof-oneof-number.yamlspec. It's test-only: no template, generator, or dependency changes.Written for commit 1cc1cb9. Summary will update on new commits.