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

Support integer enum values #4768

Open
T3rm1 opened this issue Oct 25, 2024 · 0 comments · May be fixed by #4769
Open

Support integer enum values #4768

T3rm1 opened this issue Oct 25, 2024 · 0 comments · May be fixed by #4769

Comments

@T3rm1
Copy link

T3rm1 commented Oct 25, 2024

Currently only string values are supported for enums. Is there a reason why this limitation exists?

Creation of StringSchema for enum types:
https://github.com/swagger-api/swagger-core/blame/dc8785efc71c243eebf1ad57dd612cc75112d351/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java#L309

Props are only added if schema is of type StringSchema:
https://github.com/swagger-api/swagger-core/blame/dc8785efc71c243eebf1ad57dd612cc75112d351/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java#L1220-L1223

Please add support for enums like this:

public enum MyEnumInteger {

	FIRST(1), SECOND(2), THIRD(3);

	@JsonCreator
	MyEnumInteger(int value) {
		this.value = value;
	}

	@JsonValue
	private int value;

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}
}

Expected result:

"MyEnumInteger": {
    "type": "integer",
    "format": "int32",
    "enum": [
        1,
        2,
        3
    ]
}

Actual result:

"MyEnumInteger": {
    "type": "string",
    "enum": [
        "1",
        "2",
        "3"
    ]
}
@T3rm1 T3rm1 linked a pull request Oct 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant