0

The folowing json was turned into an enum with version 1.0.2 but not with any version after that.

{
  "title": "ApiErrorCode",
  "description": "",
  "type": "integer",
  "format": "int32",
  "existingJavaType": "java.lang.Integer",
  "javaType": "com.hristovski.gjorgi.api.ApiErrorCode",
  "enum": [
    400,
    402,
    403,
    404,
    500,
    503
  ],
  "javaEnumNames": [
    "BAD_REQUEST",
    "INSUFFICIENT_FUNDS",
    "FORBIDDEN",
    "NOT_FOUND",
    "SERVER_ERROR",
    "SERVICE_UNAVAILABLE"
  ]
}

Maven is not building it, online and CLI tools also return empty POJO. By checking the code it is stated that javaEnumNames cannot me used with javaEnums and it is not. I cannot find anything that should stop the code from generationg a class file, but it returns empty.

In the cli I included DEBUG logs, and they are also not telling me anything.

The expected class is


package com.hristovski.gjorgi.api;

import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;


/**
 * ApiErrorCode
 * <p>
 * 
 * 
 */
public enum ApiErrorCode {

    BAD_REQUEST(400),
    INSUFFICIENT_FUNDS(402),
    FORBIDDEN(403),
    NOT_FOUND(404),
    SERVER_ERROR(500),
    SERVICE_UNAVAILABLE(503);
    private final Integer value;
    private final static Map<Integer, ApiErrorCode> CONSTANTS = new HashMap<Integer, ApiErrorCode>();

    static {
        for (ApiErrorCode c: values()) {
            CONSTANTS.put(c.value, c);
        }
    }

    private ApiErrorCode(Integer value) {
        this.value = value;
    }

    @JsonValue
    public Integer value() {
        return this.value;
    }

    @JsonCreator
    public static ApiErrorCode fromValue(Integer value) {
        ApiErrorCode constant = CONSTANTS.get(value);
        if (constant == null) {
            throw new IllegalArgumentException((value +""));
        } else {
            return constant;
        }
    }

}

I have more examples of code that has the same issue.

Gjorgi
  • 1
  • 1

0 Answers0