[ 
https://issues.apache.org/jira/browse/CAMEL-11622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16110413#comment-16110413
 ] 

Claus Ibsen edited comment on CAMEL-11622 at 8/2/17 7:25 AM:
-------------------------------------------------------------

In the rest-dsl the uri past must be different, you cannot have multiple POSTs 
on the same path with different type classes.

There is no HTTP header with a discriminator/type so Camel cannot safely know 
if its type A or type B. But you can say with JSon then it can always transfrom 
to a Map type first. And then try to find the best match of the classes, and 
then transform afterwards again.

But at this moment its a 1:1.
And I am not sure if we want to open up the possibility as its maybe a can of 
worm we open up.



was (Author: davsclaus):
The uri past must be different, you cannot have multiple POSTs on the same path.


> Rest-dsl doesn't support post() endpoints with different request body types
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-11622
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11622
>             Project: Camel
>          Issue Type: Bug
>          Components: rest
>    Affects Versions: 2.18.1
>         Environment: Spring-Boot with Tomcat8 container
>            Reporter: Balazs Szeti
>
> The rest-dsl doesn't support two post() endpoints with different request body 
> types.
> {code:java}
> restConfiguration()
>   .component("servlet")
>   .contextPath("/api")
>   .bindingMode(RestBindingMode.json)
> ;
> rest("/user")
>   .post("/").type(UserPojo.class)
>       .route()
>       .log("Name: ${body.name}")
>       .endRest()
> ;
> rest("/country")
>   .post("/").type(CountryPojo.class)
>       .route()
>       .log("Name: ${body.country}")
>       .endRest()
> ;
> {code}
> Both endpoints (/api/user, /api/country) tries to unmarshal the post body to 
> CountryPojo and a JsonProcessingException is thrown when a UserPojo json is 
> sent to /user.
> The problem is that they share one JascksonDataFormat instance registered 
> with name "json-jackson" and the RestDefinition.type() sets the 
> JascksonDataFormat.unmarshalType so at the end both post() endpoints will try 
> to unmarshal to the same class.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to