You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2018/09/11 11:15:00 UTC
[jira] [Comment Edited] (CXF-7825) wadl2java: support multiple
representations of the same element
[ https://issues.apache.org/jira/browse/CXF-7825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16610446#comment-16610446 ]
Sergey Beryozkin edited comment on CXF-7825 at 9/11/18 11:14 AM:
-----------------------------------------------------------------
I saw that but that is prob invalid, a query type for beans might work for multiparts only, it is not really well defined.
To be honest I see no problems with the 2 methods. If you prefer to have a single method then consider doing it only if a (new) option allowing for it is set, IMHO
it is not ideal collapsing them into a single method for the reason I mentioned above, besides it will break some existing code if you do it by default, thanks
was (Author: sergey_beryozkin):
I saw that but that is prob invalid, a query type for beans might work for multiparts only, it is not really well defined.
To be honest I see no problems with the 2 methods. If you prefer to have a single method then consider doing it only if a (new) option allowing for it is set, IMHO
it is not ideal collapsing them into a single method for the reason I mentioned above, besides it will break some existing code if you do it without and option, thanks
> wadl2java: support multiple representations of the same element
> ---------------------------------------------------------------
>
> Key: CXF-7825
> URL: https://issues.apache.org/jira/browse/CXF-7825
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS, Tooling
> Affects Versions: 3.2.6
> Reporter: Andrei Ivanov
> Priority: Major
>
> Hi,
> I have little experience using WADL and I'm trying to define a resource which accepts a request parameter with multiple representations (JSON and XML):
> {code:xml}
> <resource id="PaymentManagementService" path="/paymentmanagement">
> <resource path="/transaction/{uuid}">
> <doc>Store a Payment corresponding to the specified transaction</doc>
> <param name="uuid" style="template" type="ns:uuid" />
> <method id="storePayment" name="PUT">
> <request>
> <representation mediaType="application/json" element="ns:Payment" />
> <representation mediaType="application/xml" element="ns:Payment" />
> </request>
> <response status="200" >
> <doc>Returns the newly stored payment</doc>
> <representation mediaType="application/json" element="ns:Payment" />
> <representation mediaType="application/xml" element="ns:Payment" />
> </response>
> <response status="500" >
> <doc>Storing of the payment failed</doc>
> <representation mediaType="application/json" element="ns:ExceptionDetails" />
> <representation mediaType="application/xml" element="ns:ExceptionDetails" />
> </response>
> </method>
> </resource>
> </resource>
> {code}
> As far as I see, after CXF-3797, the generator doesn't handle this scenario, considering them as different types.
> I've also tried this way, which I'm not even sure is correct, but the generator seems to generate correct code, which is a single method which consumes the 2 media types:
> {code:xml}
> <representation mediaType="application/json">
> <param name="payment" style="query" type="ns:Payment" />
> </representation>
> <representation mediaType="application/xml">
> <param name="payment" style="query" type="ns:Payment" />
> </representation>
> {code}
> {code:java}
> @Path("/paymentmanagement")
> public interface PaymentManagementService {
> /**
> * @return Returns the newly stored payment
> */
> @PUT
> @Consumes({"application/json", "application/xml" })
> @Produces({"application/json", "application/xml" })
> @Path("/transaction/{uuid}")
> Payment storePayment(@PathParam("uuid") String uuid, Payment payment);
> }
> {code}
> The problem with this approach is that now I'm trying to enable _bean validation_, but the generator ignores this 2nd approach representations because it doesn't find an {{element}} attribute on the representations.
> Not sure what the solution is, maybe just update the generator to handle the 1st approach properly.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)