Skip to content
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

properties with 2 chars upper case have getter and setter badly generated #445

Closed
herveDarritchon opened this issue Feb 23, 2015 · 3 comments

Comments

@herveDarritchon
Copy link
Contributor

When a properties has the second character in uppercase, such as pId for example, the getter and setter are not well generated.

The getter and setter are generated like this getPId and setPId and it is not as it should be.
In fact, it should be getpId and setpId.

DefaultCodegen.java (line 441/442)
property.getter = "get" + initialCaps(name);
property.setter = "set" + initialCaps(name);

initialCaps is :
public String initialCaps(String name) {
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}

in the case of getter and setter, we should make an evolution to the code to be compliant with the getter and setter rules.

You should use Introspector.decapitalize from package java.beans instead of a home made function.

    property.getter = "get" +  Introspector.decapitalize(name);
    property.setter = "set" +  Introspector.decapitalize(name);
fehguy added a commit that referenced this issue Mar 4, 2015
Defect (Issue #445) : change the call of initialCaps for getter and setter proper generation
cchafer added a commit to cchafer/swagger-codegen that referenced this issue Mar 4, 2015
* commit '9ce4156e4cd1696b8758ed868fe3854ef19da2c9':
  Pull request swagger-api#452 : Add some unit tests for this PR
  Defect (Issue swagger-api#445) : change the call of initialCaps for getter and setter with Introspector.decapitalize from pakage java.beans.
@webron
Copy link
Contributor

webron commented May 3, 2015

@herveDarritchon - #447, #449 and #452 resolve together resolve this issue?

@herveDarritchon
Copy link
Contributor Author

yes. it's ok. it is resolved.

@webron
Copy link
Contributor

webron commented May 3, 2015

Thank you!

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

No branches or pull requests

2 participants