Skip to content

feat: add support for complex default values in code generation - #25001

Open
jorgerod wants to merge 15 commits into
OpenAPITools:masterfrom
InditexTech:fix/24993-java-complex-defaults-clean
Open

jorgerod wants to merge 15 commits into
OpenAPITools:masterfrom
InditexTech:fix/24993-java-complex-defaults-clean

Conversation

@jorgerod

@jorgerod jorgerod commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #24993

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
    @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

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Mattias-Sehlstedt

Copy link
Copy Markdown
Contributor

I’d strongly recommend moving the default-construction logic into its own dedicated component rather than keeping it in AbstractJavaCodegen. That class already carries quite a bit of responsibility, so separating this into a more focused unit would likely make the design easier to manage, reason about, and extend/mimic. So similar to other Util components that have been introduced.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jorgerod
jorgerod marked this pull request as draft September 23, 2026 19:29
@jorgerod
jorgerod marked this pull request as ready for review September 24, 2026 08:36
@jorgerod

Copy link
Copy Markdown
Contributor Author

@Mattias-Sehlstedt Thanks for the suggestion. I agreed that the complex default construction logic was becoming too large for AbstractJavaCodegen, so I extracted it into a focused JavaDefaultValueRenderer component in follow-up commit d8b7b798d77.

AbstractJavaCodegen now keeps the generator policy/configuration and delegates recursive default rendering through an explicit context containing schema resolution, Java naming/type conversion, collection construction, date-library configuration, and oneOf handling. This keeps the renderer reusable and makes the rendering logic easier to test without duplicating generator behavior.

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 93 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][JAVA] Complex OpenAPI defaults generate uncompilable Java code

2 participants