Enum generate int values when should be double
Describe the bug
Given the following schema
{
"$id": "Root",
"enum": [
2,
3
],
"type": "number"
}
The generator will generate the following schema
import com.fasterxml.jackson.annotation.*;
public enum Root {
NUMBER_2(2), NUMBER_3(3);
private Double value;
Root(Double value) {
this.value = value;
}
@JsonValue
public Double getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static Root fromValue(Double value) {
for (Root e : Root.values()) {
if (e.value.equals(value)) {
return e;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
Which throws the following error, when compiled:
incompatible types: int cannot be converted to Double
Expected behavior
Expected the enum to be compiled successfully. So the enum generator has to check the type of the enum, to see if integer values should convert to double values, or the other way around.
Related BlackBox tests that currently is being blacklisted - https://github.com/asyncapi/modelina/blob/3f14b6cc44eb10af4c74fbba9d8d12037ae66ad4/test/blackbox/blackbox.spec.ts#L54 https://github.com/asyncapi/modelina/blob/3f14b6cc44eb10af4c74fbba9d8d12037ae66ad4/test/blackbox/blackbox.spec.ts#L41
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
Still relevant, waiting on #530
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart: