Skip to content

Enum Names Not Overriden with @JsonProperty #2707

@PeaceInColour

Description

@PeaceInColour
Q A
Bug or feature request? Bug
Which Swagger-Core version? 1.5.18
Which Java version? 1.8u151
Which JAX-RS framework & version? RESTEasy 3.0.19 with JAX-RS 2.0

Using @JsonProperty to override enum names isn't working. The following example below:

public enum SomeEnum {
	@JsonProperty("num-one")
	NUMONE,
	
	@JsonProperty("num-two")
	NUMTWO
}

results in an OpenAPI file that looks like:

"enum": [
	"NUMONE",
	"NUMTWO"
]

instead of the expected:

"enum": [
	"num-one",
	"num-two"
]

The issue is in ModelResolver which is using the deprecated Jackson Databind method findEnumValue to read in the enum name. This method does not look for any overrides and just defaults to the name in the code. Using the replacement method findEnumValues fixes this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions