Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5475

wadl2java fails when using representation reference

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Invalid
    • 3.0.0-milestone1
    • None
    • None
    • Unknown

    Description

      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:

      <resource path="inline">
          <method name="GET">
              <response status="200">
                  <representation element="SkuType" mediaType="application/xml"/>
              </response>
          </method>
      </resource>
      

      This Java code is generated:

      @Path("inline")
      public interface InlineResource {
      
          @GET
          @Produces("application/xml")
          Response get();
      
      }
      

      When the response representation is using a representation reference(1), then the generated code appears to be missing details. This modified WADL snippet illustrates the issue:

      <resource path="reference">
          <method name="GET">
              <response status="200">
                  <representation href="SkuRep"/>
              </response>
          </method>
      </resource>
      
      <representation id="SkuRep" element="SkuType" mediaType="application/xml"/>

      Based on the last WADL snippet, this Java code is generated:

      @Path("reference")
      public interface ReferenceResource {
      
          @GET
          @Produces()
          Response get();
      
      }

      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."

      <resource path="illegal">
          <method name="GET">
              <response status="200">
                  <representation href="SkuRep" mediaType="application/xml"/>
              </response>
          </method>
      </resource>
      @Path("illegal")
      public interface IllegalResource {
      
          @GET
          @Produces("application/xml")
          Response get();
      
      }

      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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            guus.der.kinderen Guus der Kinderen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment