Added support for getter sections in unions codegen#1229
Open
timocov wants to merge 1 commit into
Open
Conversation
adwsingh
approved these changes
Jun 5, 2026
Contributor
|
I wonder if the better design here is to generically be able to add support for custom Annotations in the codegen. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What behavior changes?
This PR adds
GetterSectionto getter of union variant classes.Why is this change needed?
One of the places where
GetterSectionhelps is when you want to add custom annotations to getters. For instance, when integrating generated code with jakarta validation in Spring Boot, complex fields require to have@Validannotation attached in order to be validated (e.g. to run full depth validation). Currently,GetterSectionis not "emitted" which means that union member getters aren't being processed and it is possible to add@Validannotation in this case.How was this validated?
I changed to code locally, run
gw pTML, run the codegen, spin up a spring boot application and validated that the request is being validated correctly.What should reviewers focus on?
Should I use
instead to avoid people accidentally removing the content of the method?
Also, should I do the same for enums?
Additional Links
N/A.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.