2

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?

gimpf
  • 4,503
  • 1
  • 27
  • 40
ToHe
  • 147
  • 3
  • 13
  • Just out of curiosity on your design of REST WS, I see that you pass as a parameter "JAXBElement", meaning that you expect complex hierarchical stricture in the request. In that case, would it be better to have just old plain SOAP based WS that defines complex types and validations? – user1697575 Nov 14 '12 at 17:26

1 Answers1

2

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)
Ryan Heaton
  • 1,173
  • 7
  • 11