Skip to content
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

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

Closed
arey opened this issue Dec 8, 2022 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@arey
Copy link

arey commented Dec 8, 2022

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

@bnasslahsen bnasslahsen added the bug Something isn't working label Dec 12, 2022
@arey
Copy link
Author

arey commented Dec 12, 2022

Thanks a lot Badr :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants