Skip to content

Enums containing digits are generated with unnecessary underscores #1738

@quandor

Description

@quandor

If Enum members contain a digit, the generated model contains an unnecessary underscore ('_') in front of the digit, if the java model is generated. While I do understand that a leading digit is not allowed in Enum members, I do not think digits at other locations in the name strictly need this prefix. Other tools behave differently as well.
See example below:

Schema:

{
  "$schema": "http://json-schema.org/draft-04/schema#",

  "properties": {
    "Android": {
      "enum": [
        "R2D2",
        "C3PO"
      ]
    }
  },
  "type": "object"
}

Generated model:

// This is not the complete model. Uninteresting parts are left out for brevity.
@Generated("jsonschema2pojo")
public enum Android {
        R_2_D_2("R2D2"),
        C_3_PO("C3PO");
}

Expected model:

// This is not the complete model. Uninteresting parts are left out for brevity.
@Generated("jsonschema2pojo")
public enum Android {
        R2D2("R2D2"),
        C3PO("C3PO");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions