Forum Discussion

du-it's avatar
New Contributor
3 years ago

Displaying enum properties

I have an enum like this:
public enum ErrorCode implements BaseError {
    // @formatter:off
    FOO(100001, "Foo message.",
    BAR(100002, "Bar message."), 
    FOOBAR(300003, "FOOBAR message.");

    public final int errorId;
    public final String errorMsg;

    ErrorCode(int errorId, String errorMsg) {
        this.errorId = errorId;
        this.errorMsg = errorMsg;

I know, I can use @Schema(implementation = ErrorCode.class) to display the enum in SwaggerUI but it displays the name. Ist there a way to display the errorId (or any other defined properties (or even combination) of an enum)?

In this case I would like to display the list of errorCodes instead of the default which displays the list of the enum names.

No RepliesBe the first to reply