Guus der Kinderen created CXF-5475:
--------------------------------------

             Summary: 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


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