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

Use name() instead of toString() for enums when generating WADL

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.13, 3.3.5, 3.2.12
    • Fix Version/s: 3.3.6, 3.2.13, 3.4.0
    • Component/s: JAX-RS, JAXB Databinding
    • Labels:
      None
    • Environment:

      CXF 3.1.13

      Tomcat apache 8.5.34

    • Estimated Complexity:
      Unknown

      Description

      When generating WADL the enum option value contains the toString() of the enum (the human readable value for the option) but it should use the name() method instead. Ex:
       

      public enum Status {
        INVOICED("Invoiced"),
        NOT_INVOICED("Not invoiced");
       
        String desc;
      
        Status(String desc) {
         this.desc = desc;
        }
        public String toString() {
         return desc;
        }
      }
       
      

      @GET
      @Path("customers/{customerNo}/creditnotes")
      public Response findCreditNotesForCustomerNo(
      @QueryParam("session") @XmlElement(required = true) String session,
      @PathParam("customerNo") int customerNo,
      @QueryParam("status") Status status);
       
      The WADL contains:
      <resource path="customers/{customerNo}/creditnotes">
      <param name="customerNo" style="template" type="xs:int"/>
      <method name="GET">
      <request>
      <param name="session" style="query" type="xs:string"/>
      <param name="status" style="query" type="xs:string">
      <option value="Not invoiced"/>
      <option value="Invoiced"/>
      </param>
      </request>

      I would expect it to be using the name() method. Like this:
       
      <resource path="customers/{customerNo}/creditnotes">
      <param name="customerNo" style="template" type="xs:int"/>
      <method name="GET">
      <request>
      <param name="session" style="query" type="xs:string"/>
      <param name="status" style="query" type="xs:string">
      <option value="NOT_INVOICED"/>
      <option value="INVOICED"/>
      </param>
      </request>
       
       Otherwise if someone looks at the WADL he would think that one should sent the human readable string which is not correct.
       
       

        Attachments

          Activity

            People

            • Assignee:
              reta Andriy Redko
              Reporter:
              mattias1972 Mattias Andersson
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: