Conversation
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 474 files
Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Requires human review: Auto-approval blocked because this review re-detected 2 unresolved issues already reported by Cubic.
Re-trigger cubic
|
I’d strongly recommend moving the default-construction logic into its own dedicated component rather than keeping it in |
There was a problem hiding this comment.
All reported issues were addressed across 26 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
@Mattias-Sehlstedt Thanks for the suggestion. I agreed that the complex default construction logic was becoming too large for
The existing functional regressions remain covered, including arrays/objects, oneOf branch selection, date libraries, nullable defaults, and container initialization. The directed Java/Spring/Play tests pass and checkstyle passes. |
There was a problem hiding this comment.
All reported issues were addressed across 93 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
thanks for the PR. let's give it a try |
Closes: #24993
Type of change
This is primarily a bug fix: complex
defaultvalues in OpenAPI specs (nested arrays/objects, oneOf schemas with defaults, nullable fields, containers) previously generated non-compilable Java code (see #24993).As part of making the generation correct, default rendering was also extended where it silently produced invalid or incomplete output (e.g. date library specific defaults), so minor parts of this PR could be considered new behavior. I'm happy to split any feature-like part into a separate PR if the maintainers prefer smaller, atomic changes.
Problem
Given an OpenAPI spec with complex default values, e.g.:
the previous generator output for Java clients was syntactically invalid Java, such as:
or a default that referenced a schema class without constructing it, resulting in compile errors in the generated samples.
Root cause
The default-value rendering path in
AbstractJavaCodegenonly supported scalar defaults. When the default was a complex structure (arrays, nested arrays, objects, oneOf branches, date/time values), the renderer emitted fragments that could not be compiled.Fix
JavaDefaultValueRenderercomponent (following the pattern of other util components), soAbstractJavaCodegenkeeps only the generator policy/configuration and delegates recursive default rendering through an explicit context (schema resolution, Java naming/type conversion, collection construction, date-library configuration, oneOf handling).List/Set,Arrays.asList(...),LinkedHashSetforuniqueItems)java8,threetenbp,joda, legacyjava.util.Date)Map-like and nested containers)Tests
JavaClientCodegenTest,SpringCodegenTestandJavaPlayFrameworkCodegenTestcovering arrays/objects defaults, oneOf branch selection, date libraries, nullable defaults and container initialization.Affected generators
Java-based generators that share
AbstractJavaCodegen/ the updatedpojo.mustachetemplates: java client libraries (okhttp-gson, jersey2/3, resttemplate/webclient, native, rest-assured, feign, microprofile, helidon, retrofit2), spring (boot/declarative), JavaJaxRS, java-msf4j-server, and JavaPlayFramework.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.
@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08) @wing328