I have a JAX-RS service that handles multipart PUT
operations, with a request object mapped using the @RestForm
annotation. All of the parameters within the @RestForm
are serialized/deserialized properly, and I'm able to see them come across to my JAX-RS endpoint method. However, when I added a property to the form that is an Enum
it does not seem to be mapped correctly. When I PUT
a request with this Enum
value set, my JAX-RS endpoint sees the value as null
.
My form is quite simple and looks something like this:
public class MyEnumForm {
@RestForm("paramA")
private String paramA = null;
@RestForm("paramB")
private String paramB = null;
@RestForm("enumParam")
private MyEnumType enumParam = null;
...snip...
}
My JAX-RS endpoint method looks like this...
@Path("/myendpoint")
@PUT
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response testPut(@MultipartForm MyEnumForm) {
...snip...
}
Am I missing an annotation on the enum
in my form class? Is there something special I have to do for enum
types in this scenario?
The issue was that my enum
needed a public static fromString(String)
method to convert the provided String
value to an Enum
instance. Once that was added, RestEasy converted it properly.