You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Mattias Andersson (Jira)" <ji...@apache.org> on 2020/01/21 15:19:00 UTC

[jira] [Created] (CXF-8200) Use name() instead of toString() for enums when generating WADL

Mattias Andersson created CXF-8200:
--------------------------------------

             Summary: Use name() instead of toString() for enums when generating WADL
                 Key: CXF-8200
                 URL: https://issues.apache.org/jira/browse/CXF-8200
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS, JAXB Databinding
    Affects Versions: 3.1.13
         Environment: CXF 3.1.13

Tomcat apache 8.5.34
            Reporter: Mattias Andersson


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:
 
{code:java}
public enum Status {
  INVOICED("Invoiced"),
  NOT_INVOICED("Not invoiced");
 
  String desc;

  Status(String desc) {
   this.desc = desc;
  }
  public String toString() {
   return desc;
  }
}
 
{code}
@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.
 
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)