Skip to content

[REQ] Support modelPropertyNaming on Spring/Java #21190

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

Open
azam opened this issue Apr 30, 2025 · 0 comments
Open

[REQ] Support modelPropertyNaming on Spring/Java #21190

azam opened this issue Apr 30, 2025 · 0 comments

Comments

@azam
Copy link

azam commented Apr 30, 2025

Is your feature request related to a problem? Please describe.

Property names on models are (mostly) camelCased when using Spring openapi-generator and there is no way to configure and change this behavior.
I understand the usual need of conforming to Java Beans convention, but on my case we don't need the conformity and would like to have the property names on models to be of the original names on the spec file.
This helps in reducing code and use less reflection (get the original name from Schema annotation of the field) by just using the same naming conventions.

e.g.)
Spec

components:
  schemas:
    FooReq:
      type: object
      properties:
        Name:
          type: string
          description: ABC
        ABC:
          type: integer
          description: Unicode full-width alphabet name

Generated model (Current behavior)

private String name;
private Integer abc;

public String getName() { ... };
public void setName(String name) { ... };

public Integer getAbc() { ... };
public void setAbc(Integer abc) { ... };

Generated model (Desired behavior)

private String Name;
private Integer ABC;

public String getName() { ... };
public void setName(String Name) { ... };

public Integer getABC() { ... };
public void setABC(Integer ABC) { ... };

Describe the solution you'd like

Add an option to keep the original property names from spec for Spring generators.

Describe alternatives you've considered

Option A

Generate file that contains all property names, and add one-to-one entry as nameMappings.

Option B

Extend SpringCodeGen and override toVarName etc methods and publish as library.

Additional context

Other generators (scala, typescript) have modelPropertyNaming that can be set to original as configurable option that does this.

@azam azam changed the title [REQ] Feature Request Description [REQ] Support modelPropertyNaming on Spring/Java Apr 30, 2025
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

1 participant