Skip to content

Fix 23034 - child constructor no longer has invalid access to parent field#23043

Open
hugin78 wants to merge 3 commits intoOpenAPITools:masterfrom
hugin78:fix-23034-microprofile-readonly-parent-invalid-code
Open

Fix 23034 - child constructor no longer has invalid access to parent field#23043
hugin78 wants to merge 3 commits intoOpenAPITools:masterfrom
hugin78:fix-23034-microprofile-readonly-parent-invalid-code

Conversation

@hugin78
Copy link

@hugin78 hugin78 commented Feb 24, 2026

fixes #23034

Problem:
When using extensions with allOff and having a readonly field in the parent, then the generated child class, does not compile, as it access the private field in the parent class directly.

Solution:
This has been solved the same way as in the 'resteasy' library where the access type of the field in the parent is changed from 'private' to 'protected'.

Test:
A unittest has been added to verify the fix.

@bbdouglas @sreeshas@jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg


Summary by cubic

Fixes a compile error in the MicroProfile generator when a child model extends a parent with a readOnly field. Parent fields are now generated as protected so child classes compile correctly.

  • Bug Fixes
    • Fixed the unit test to assert Parent.java uses a protected parentField and ensured the test spec (issue_23034.yaml) includes the classType discriminator to reproduce the inheritance case.

Written for commit eb40215. Summary will update on new commits.

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.

1 issue found across 3 files

Prompt for AI agents (all 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/resources/bugs/issue_23034.yaml">

<violation number="1" location="modules/openapi-generator/src/test/resources/bugs/issue_23034.yaml:26">
P3: Discriminator `classType` is referenced but not defined in `Parent.properties` or `required`, making the OpenAPI schema invalid and likely generating models without the discriminator field.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@hugin78 hugin78 marked this pull request as draft February 24, 2026 08:28
@hugin78 hugin78 marked this pull request as ready for review February 24, 2026 08:43
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 3 files

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.

readonly fields in parents generate invalid code with 'microprofile' generator

2 participants