Skip to content

Fix child constructor no longer has invalid access to parent field#23205

Merged
wing328 merged 6 commits intomasterfrom
hugin78-fix-23034-microprofile-readonly-parent-invalid-code
Mar 11, 2026
Merged

Fix child constructor no longer has invalid access to parent field#23205
wing328 merged 6 commits intomasterfrom
hugin78-fix-23034-microprofile-readonly-parent-invalid-code

Conversation

@wing328
Copy link
Member

@wing328 wing328 commented Mar 11, 2026

Fix #23204

based on #23043

tested locally to confirm the issue and the fix

[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.633 s -- in org.openapitools.client.api.DefaultApiTest
[INFO] Running org.openapitools.client.model.ChildTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 s -- in org.openapitools.client.model.ChildTest
[INFO] Running org.openapitools.client.model.ParentTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s -- in org.openapitools.client.model.ParentTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- jar:3.4.1:jar (default-jar) @ openapi-java-client ---
[INFO] Building jar: C:\Users\User\AppData\Local\Temp\mip\target\openapi-java-client-v1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.982 s
[INFO] Finished at: 2026-03-11T16:26:48+08:00
[INFO] ------------------------------------------------------------------------\

cc @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)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • 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.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes a Java microprofile client codegen bug where child constructors accessed private parent readOnly fields, causing compilation errors. Model fields are now generated as protected so subclasses can access parent fields. Fixes #23204.

  • Bug Fixes
    • Update Java/libraries/microprofile/pojo.mustache to generate model fields as protected instead of private.
    • Add test and repro spec (issue_23034.yaml) to verify Parent.java contains a protected parent field and compiles.
    • Regenerate samples across microprofile variants to reflect protected fields in models.

Written for commit 9b7e525. Summary will update on new commits.

@wing328 wing328 marked this pull request as ready for review March 11, 2026 08:26
@wing328 wing328 added this to the 7.21.0 milestone Mar 11, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 173 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

@wing328 wing328 merged commit b3244e9 into master Mar 11, 2026
121 of 122 checks passed
@wing328 wing328 deleted the hugin78-fix-23034-microprofile-readonly-parent-invalid-code branch March 11, 2026 09:06
davidricodias pushed a commit to davidricodias/openapi-generator that referenced this pull request Mar 11, 2026
…penAPITools#23205)

* Fix fix that child constructor was invalid when having readonly field in parent

* add classType field

* fix test

* update samples

---------

Co-authored-by: bdurca <rca@bankdata.dk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants