Skip to content

Enum should be translated using .name(), not .toString() #2048

@jasperjanuar

Description

@jasperjanuar

Versions:
spring boot 2.7.4
java 17.0.4
springdoc-openapi-ui:1.6.14

Currently Enums are "translated" using their .toString()method.

public enum CustomerFeature {
  PAYOUT_APPROVAL("payoutApproval"),
  FX("fx");

  private String name;

  CustomerFeature(String name) {
    this.name = name;
  }

  @Override
  public String toString() {
    return name;
  }
}

results in
image

Describe the solution you'd like
This current workaround is to add @JsonProperty(value = "Foo") to each Enum value, but I think using Enum.name() would be better solution just as proposed and fixed in Springfox springfox/springfox#2860

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions