camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Balazs Szeti (JIRA)" <>
Subject [jira] [Commented] (CAMEL-11622) Rest-dsl doesn't support post() endpoints with different request body types
Date Wed, 02 Aug 2017 14:44:00 GMT


Balazs Szeti commented on CAMEL-11622:

Thanks for looking into this.

I modified the sample above to make clear that the two post URIs are different: /api/user/employee
vs. /api/country/origin, the problem is still there. The root cause I think is that there
can be used only one DataFormat instance ("json-jackson" by default) and it can unmarshal
to one type only. This means that all post() endpoints in a CamelContext must accept the same
type json object in request body.

I couldn't find a way to build a CamelContext providing two post() endpoints (on different
URIs) with different type().

> Rest-dsl doesn't support post() endpoints with different request body types
> ---------------------------------------------------------------------------
>                 Key: CAMEL-11622
>                 URL:
>             Project: Camel
>          Issue Type: Wish
>          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("/employee").type(UserPojo.class)
>       .route()
>       .log("Name: ${}")
>       .endRest()
> ;
> rest("/country")
>   .post("/origin").type(CountryPojo.class)
>       .route()
>       .log("Name: ${}")
>       .endRest()
> ;
> {code}
> Both endpoints (/api/user/employee, /api/country/origin) tries to unmarshal the post
body to CountryPojo and a JsonProcessingException is thrown when a UserPojo json is sent to
> 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

View raw message