Skip to content

Conversation

@MintsInc
Copy link
Member

@MintsInc MintsInc commented Oct 10, 2025

Context

PR #3177 fixed constructor collisions in oneOf types by using static factory methods when multiple types have the same type erasure (e.g., List<String> and List<Double> both erase to List). However, the example generation code was not updated to use these new factory methods, causing compilation failures in generated examples.

Issue

The failing example in PR #3057 attempted to instantiate CustomAttributeValuesUnion with a List<String>:

new CustomAttributeValuesUnion(Arrays.asList("Abba", "The Cure"))  // ❌ Constructor doesn't exist

This fails because CustomAttributeValuesUnion has:

  • oneOf: String, List<String>, Double, List<Double>
  • Regular constructors for String and Double (no collision)
  • Static factory methods for List<String> and List<Double> (collision detected)

Changes

Updated .generator/src/generator/formatter.py to detect type erasure collisions when generating examples:

  1. _format_oneof(): Now calls prepare_oneof_methods() to determine whether to use a regular constructor or static factory method
  2. format_data_with_schema_list(): Same collision detection for list-based oneOf types

The example generator now correctly produces:

CustomAttributeValuesUnion.fromStringList(Arrays.asList("Abba", "The Cure"))  // ✓ Correct

Test

This fix resolves the compilation failure in PR #3057's UpdateCaseCustomAttribute.java example.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@MintsInc MintsInc marked this pull request as ready for review October 10, 2025 09:09
@MintsInc MintsInc requested review from a team as code owners October 10, 2025 09:09
@MintsInc MintsInc added the changelog/no-changelog Changes don't appear in changelog label Oct 10, 2025
@MintsInc MintsInc merged commit 7e5cffb into master Oct 10, 2025
17 of 18 checks passed
@MintsInc MintsInc deleted the ulysse.mavrocordatos/fix-oneof-example-gen branch October 10, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog Changes don't appear in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants