Skip to content

Java enumeration and Spring Converter no longer generates enum drop-down #1992

Closed
@arey

Description

@arey

Describe the bug

After upgrading from springdoc-openapi 1.6.6 to 1.6.7/1.6.13, the enum drop-down list is not visible in Swagger UI.
This issue looks like related to the previous one: #1663
I'm using a Spring MVC Converter to convert upper case to lower case.

@Component
public class FooBarConverter implements Converter<String, FooBar> {
  @Override
  public FooBar convert(String source) {
    return FooBar.fromValue(source);
  }
}
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public enum FooBar {
    FOO("foo"),
    BAR("bar");

    private String value;

    FooBar(String value) {
        this.value = value;
    }

    @JsonValue
    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }

    @JsonCreator
    public static FooBar fromValue(String value) {
        for (FooBar b : FooBar.values()) {
            if (b.value.equals(value)) {
                return b;
            }
        }
        throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }
}

To Reproduce

Expected behavior

I would like to see a drop down list on Swagger UI

Screenshots

See the sample repository: https://github.com/arey/springdoc-enum-example

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions