Search code examples
javarestjaxbenunciate

Enunciate not recognizing JAXBElement


I have a fully working & tested REST API. To create the documentation I am using enunciate.

The request & response objects are generated from xsd files using jaxb. In the documentation the response objects are recognized but the type of my request body is (custom).

The request body is encapsulated in a JAXBElement

code example:

@POST
@Consumes(
{
    MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
})
@Produces(
{
    MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
})
public ResponseObject post(JAXBElement<CreateRequestObject> JAXBCreateRequestObject,
        @HeaderParam(value = "X") String x,
        @HeaderParam(value = "Y") String y) throws WebApplicationException

Is there an annotation like @TypeHint to specify the type of the request object?


Solution

  • You should be able to apply @TypeHint to the parameter, e.g.:

      public ResponseObject post(@TypeHint(...) JAXBElement<CreateRequestObject> JAXBCreateRequestObject,
         @HeaderParam(value = "X") String x,
         @HeaderParam(value = "Y") String y)