Fix #24603 (anyOf serialization in dart-dio) - #24605
Open
bw-flagship wants to merge 2 commits into
Open
Conversation
bw-flagship
marked this pull request as ready for review
August 4, 2026 10:59
Contributor
There was a problem hiding this comment.
1 issue found across 84 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientCodegenTest.java">
<violation number="1" location="modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientCodegenTest.java:246">
P3: The regression test does not exercise the reported RangeError path: it only checks generated source text, so it cannot verify that serializing the second anyOf variant succeeds at runtime. Adding a generated-Dart integration test that constructs the second variant and invokes the standard serializers would make the regression test cover the actual failure.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| Path fieldValue = output.toPath().resolve("lib/src/model/field_value.dart"); | ||
|
|
||
| TestUtils.assertFileContains(fieldValue, | ||
| "FullType(AnyOf, anyOf.types.map((type) => FullType(type)).toList())"); |
Contributor
There was a problem hiding this comment.
P3: The regression test does not exercise the reported RangeError path: it only checks generated source text, so it cannot verify that serializing the second anyOf variant succeeds at runtime. Adding a generated-Dart integration test that constructs the second variant and invokes the standard serializers would make the regression test cover the actual failure.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientCodegenTest.java, line 246:
<comment>The regression test does not exercise the reported RangeError path: it only checks generated source text, so it cannot verify that serializing the second anyOf variant succeeds at runtime. Adding a generated-Dart integration test that constructs the second variant and invokes the standard serializers would make the regression test cover the actual failure.</comment>
<file context>
@@ -215,6 +215,39 @@ public void testOptionalNonNullablePropertyDeserializesAsNullable() throws IOExc
+ Path fieldValue = output.toPath().resolve("lib/src/model/field_value.dart");
+
+ TestUtils.assertFileContains(fieldValue,
+ "FullType(AnyOf, anyOf.types.map((type) => FullType(type)).toList())");
+ TestUtils.assertFileNotContains(fieldValue,
+ "FullType(AnyOf, anyOf.valueTypes.map((type) => FullType(type)).toList())");
</file context>
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.
Fixes #24603
@jaumard @amondnet @sbu-WBT @kuhnroyal @agilob @ahmednfwela
Regenerating the samples introduced these blanklines. When I did not do that, the checks would fail. Not sure whether this is acceptable.
PR checklist
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.
Summary by cubic
Fixes anyOf serialization in
dart-diobuilt_value by using declared types to buildFullTypeparameters. Prevents RangeError when the selected variant is not the first.anyOf.typesinstead ofanyOf.valueTypesinclass_serializer.mustachewhen buildingFullType(AnyOf, ...).anyOfprimitive schema; regeneratedart-diosamples.Written for commit 22f3fec. Summary will update on new commits.