-
Notifications
You must be signed in to change notification settings - Fork 6k
Issue 7638 #7790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Issue 7638 #7790
Conversation
@@ -155,6 +156,11 @@ public void processOpts() { | |||
this.setRemoveOperationIdPrefix(Boolean.valueOf(additionalProperties | |||
.get(CodegenConstants.REMOVE_OPERATION_ID_PREFIX).toString())); | |||
} | |||
|
|||
if (additionalProperties.containsKey(CodegenConstants.BOOLEAN_GETTER_PREFIX)) { | |||
this.setRemoveOperationIdPrefix(Boolean.valueOf(additionalProperties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps s/setRemoveOperationPrefix/setBooleanGetterPrefix/
I assume that this new option will be available from the maven plugin as well. If so, LGTM |
This PR resolves #7638 |
I don’t think this should be a global option. Most generators don’t care about it |
I even don’t think this should be an option at all. Boolean wrapper should be called with get, not is. Always. |
@cbornet @dkellenb To be honest, I think this is the same kind of debate that we could have for indentation style, tabs vs space, etc... I agree with you that most generators don't care because they don't have the concept of getter/setter (think of typescript) or it's another concept completely (C# with properties) Maybe this should be implemented on a selected few generators (java mostly I think)? It could be in the AbstractJavaCodegen file? As for always using "get" like @cbornet said, many people would disagree with him. Using "is" in the getter name help to see if the name of the variable is ok: https://stackoverflow.com/questions/5322648/for-a-boolean-field-what-is-the-naming-convention-for-its-getter-setter I have projects who use both. So maybe we should move this to the |
I agree with @JFCote that it is better to have the getter naming customizable. |
Sorry but I disagree. The more options there are, the harder it is to maintain, refactor, evolve, etc... I think we already have too many options on the Java gen which has become very messy (we should do something about that at some point btw).
This SOF link is about the |
Was this never merged? |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
.Description of the PR
As described in Issue 7638 there is now the option to define the getter-prefix for
Boolean
s. For those who favorisValid
(or maybehasValue
) instead ofgetValid
. Default isget
.Option example:
--boolean-getter-prefix is
or--boolean-getter-prefix has
@bbdouglas, @JFCote, @sreeshas, @jfiala, @lukoyanov, @cbornet, @jeff9finger: Please verify
I have have not changed the generation in
AbstractCppCodegen
which is still by defaultis
. Same is true forSymfonyServerCodegen
(PHP). Maybe it would be good to clean up these exceptional cases or keep it like i did inAbstractCppCodegen
(C++).Last remark: Note that it would even be better to have
is
-prefix for primitiveboolean
andget
-prefix forBoolean
type.