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

[Java] Getter/Setter naming convention not followed in generated models #8282

Open
mixmastered opened this issue Jun 5, 2018 · 3 comments
Open

Comments

@mixmastered
Copy link

Description

When generating a client library (resttemplate), the getters/setters for a field xField are getXField and setXField. As per naming conventions, this is wrong: https://stackoverflow.com/questions/2948083/naming-convention-for-getters-setters-in-java

We found this issue when testing our API - the responses contained "xfield" and "xField" as jackson serializer did not match the field to the getter generated.

Swagger-codegen version

Using swagger codegen 2.3.1.

Swagger declaration file content or url
		  "xField" : {
			"type" : "string"
		  },
Command line used for generation

Using swagger-codegen-maven-plugin. Maven -> Generate sources

Steps to reproduce

Run generate-sources on a specification containing a field name in some object of form "xField" (a single lower case character followed by upper-case). Generated java model contains getXField() when it should be named getxField().

Suggest a fix/enhancement

Enhance whatever code creates getters and setters for fields in the specification.

@HugoMario
Copy link
Contributor

hey @mixmastered, sorry for delay.

do you think you have time to propose a PR? i would address this, but i'm really busy with other issues :( anyway in case you can't i think i can address this in a couple of weeks.

I think changes here must be ported to 3.0.0 too.

@gregas
Copy link

gregas commented Feb 4, 2021

Oh, cum on.

Why closing #9129 when it was actually providing a correction.

Was merged into forked project OpenAPITools / openapi-generator

And as we tested it there is working as expected - and according to the CONVENTIONS. But unfortunately, we can not just switch to another project - has other constraints.

So, what swagger-api/swagger-codegen provides is NOT according to Java/Beans conventions, and is plain wrong - see how many related open issues you have related to this topic, wrong getter/setter naming.

This is JAVA basics, should be fixed as critical, and not neglected for so long.

( there are many great topics how should be done

@HugoMario
Copy link
Contributor

Hello @gregas, if you are willing to resume that PR i can help you to merge it, please , let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants