Skip to content

[BUG] [Java] uppercase property leads to duplicate fields after serialization #5705

Description

@zhangyangyu

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

My model get a field called OS-EXT-SRV-ATTR which generate code like:

  @JsonProperty("OS-EXT-SRV-ATTR")
  private ExtServerAttr OS_EXT_SRV_ATTR; 
  /**
   * Get OS_EXT_SRV_ATTR
   * @return OS_EXT_SRV_ATTR
  */
  @ApiModelProperty(value = "")
  @Valid
  public ExtServerAttr getOSEXTSRVATTR() {
    return OS_EXT_SRV_ATTR;
  }

  public void setOSEXTSRVATTR(ExtServerAttr OS_EXT_SRV_ATTR) {
    this.OS_EXT_SRV_ATTR = OS_EXT_SRV_ATTR;
  }

After serialize with jackson we will get two fields in the result: OS_EXT_SRV_ATTR and osextsrvattr. This is a expected behaviour for jackson, see FasterXML/jackson-databind#1609 . But it's definitely not ideal for my app.

openapi-generator version

I use openapi-generator-maven-plugin 3.3.4, but I tried the latest 4.2.3, no help.

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix

I think the idea behaviour is to seriliaze the field as-is in the yaml model declaration.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions