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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1.13, 3.3.5, 3.2.12
    • 3.3.6, 3.2.13, 3.4.0
    • JAX-RS, JAXB Databinding
    • None
    • CXF 3.1.13

      Tomcat apache 8.5.34

    • 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

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

            Dates

              Created:
              Updated:
              Resolved: