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

Guus der Kinderen commented on CXF-5475:
----------------------------------------

I am experiencing a similar problem with method references (as opposed to 
inline method definitions). Given a method that uses a 'template' parameter, a 
corresponding Java argument is generated only when in the WADL, the method is 
defined inline.

WADL, Inline:
{code:xml}
<resource path="{paperId}">
    <param name="paperId" style="template" type="xsd:int"/>
    <method name="GET">
       <!-- child elements removed to keep this example short -->
    </method>
</resource>
{code}

Generated Java (as expected):
{code:java}
@GET
@Produces("application/xml")
@Path("/{paperId}")
Paper getPaperId(@PathParam("paperId") int paperId);
{code}

WADL, Method-by-Reference:
{code:xml}
<resource path="{paperId}">
    <param name="paperId" style="template" type="xsd:int"/>
    <method href="#getPaper"/>
</resource>
{code}

Generated Java (missing argument):
{code:java}
@GET
@Produces("application/xml")
@Path("/{paperId}")
Paper getPaper();
{code}

I assume this behavior is related to the problem described in this issue, as it 
also relates to WADL references.

> wadl2java fails when using representation reference
> ---------------------------------------------------
>
>                 Key: CXF-5475
>                 URL: https://issues.apache.org/jira/browse/CXF-5475
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.0.0-milestone1
>            Reporter: Guus der Kinderen
>            Priority: Minor
>              Labels: wadl2java
>         Attachments: cxf-5475.tar.gz
>
>
> It appears that wadl2java fails to produce some code when a response 
> representation is defined as a reference (as opposed to an inline definition).
> To illustrate the issue, snippets of a WADL are provided below. Each snippet 
> is followed by a snippet of code as generated by wadl2java.
>  
> The first WADL snippet defines a response representation inline:
> {code:xml}<resource path="inline">
>     <method name="GET">
>         <response status="200">
>             <representation element="SkuType" mediaType="application/xml"/>
>         </response>
>     </method>
> </resource>
> {code}
> This Java code is generated:
> {code:java}
> @Path("inline")
> public interface InlineResource {
>     @GET
>     @Produces("application/xml")
>     Response get();
> }
> {code}
> When the response representation is using a representation 
> reference[^(1)^|http://www.w3.org/Submission/wadl/#x3-220002.11.1], then the 
> generated code appears to be missing details. This modified WADL snippet 
> illustrates the issue:
> {code:xml}
> <resource path="reference">
>     <method name="GET">
>         <response status="200">
>             <representation href="SkuRep"/>
>         </response>
>     </method>
> </resource>
> <representation id="SkuRep" element="SkuType" 
> mediaType="application/xml"/>{code}
> Based on the last WADL snippet, this Java code is generated:
> {code:java}@Path("reference")
> public interface ReferenceResource {
>     @GET
>     @Produces()
>     Response get();
> }{code}
> *Observed behavior* 
> Code details are missing (note that the media type is missing from the last 
> snippet of Java code), when a representation reference is used.
> *Expected behavior*
> wadl2java should generate similar Java code for both WADL snippets that are 
> provided above.
> Side-note: when the mediaType attribute is added to the representation 
> reference the generated code looks ok. However, this appears to be prohibited 
> by the WADL specification: ??"A representation reference element MUST NOT 
> have any other WADL-defined attributes or contain any WADL-defined child 
> elements.??"
> {code:xml}
> <resource path="illegal">
>     <method name="GET">
>         <response status="200">
>             <representation href="SkuRep" mediaType="application/xml"/>
>         </response>
>     </method>
> </resource>{code}
> {code:java}@Path("illegal")
> public interface IllegalResource {
>     @GET
>     @Produces("application/xml")
>     Response get();
> }{code}
> Note that for the purpose of illustrating the problem, the mediaType 
> attribute was used. The issue might or might not affect other attributes or 
> aspects of code generation (this remains untested).
> The behavior described in this issue was reproduced using the wadl2java Maven 
> plugin, version 3.0.0-milestone1.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to