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

WADL contains wrong parameter name for parameter beans

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0, 3.0.1
    • 2.7.13, 3.0.2, 3.1
    • JAX-RS
    • None
    • Unknown

    Description

      I'm using auto generated wadl from jax-rs annotated service beans in conjunction with cxf parameter bean extension (cool feature , thx. alot). Wenn accessing the auto generated wadl (url extension ?_wadl) the resulting parameter names are always lower cased and do not reflect e.g. real path variable names when using the parameter bean extension. Assume the following example code (annotated service, sample parameter bean, relevant wadl snippets)...:

      MyService.java
      @Path("sample/{camelCasedVariable}")
      @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
      public class MyService {
          @GET
          @Path("test1/{userId}")
          public Response test1(@PathParam("camelCasedVariable") final String variable, @PathParam("userId") final String id) {
              return Response.accepted().build();
          }
      
          @GET
          @Path("test2/{userId}")
          public Response test2(@PathParam("") final SampleBean bean) {
              return Response.serverError().build();
          }
      }
      
      SampleBean.java
      public class SampleBean {
          private String camelCasedVariable;
          private String userId;
      
          public String getCamelCasedVariable() {
              return camelCasedVariable;
          }
      
          public void setCamelCasedVariable(final String camelCasedVariable) {
              this.camelCasedVariable = camelCasedVariable;
          }
      
          public String getUserId() {
              return userId;
          }
      
          public void setUserId(final String userId) {
              this.userId = userId;
          }
      }
      

      ... resulting in the following wadl snippet, shortened:

      <!-- intro, grammer,... -->
      <resources base="http://localhost:8080/services/">
          <resource path="/sample/{camelCasedVariable}/test1/{userId}>
              <param name="camelCasedVariable" style="template" type="xs:string">
              <param name="userId" style="template" type="xs:string">
          </resource>
      
          <resource path="/sample/{camelCasedVariable}/test2/{userId}>
              <param name="camelcasedvariable" style="template" type="xs:string">
              <param name="userid" style="template" type="xs:string">
          </resource>
      </resources>
      

      In test1 standard jax-rs annotations have been used and generated wadl part is ok. In test2 cxf-parameter bean has been used, resulting in lowercased variable names which seems to be incorrect. Same occurs when using parameter beans in QueryParams, probably on other jax-rs variable type as well (Matrix,Form etc.).

      I've checked the WadlGenerator.java class and found the following referenced code snippet from InjectionUtils.java (cxf-rt-frontend), maybe this is a starting hint for your analysis:

      InjectionUtils.java
      //... 
      public static Map<Parameter, Class<?>> getParametersFromBeanClass(Class<?> beanClass, 
                                                                            ParameterType type,
                                                                            boolean checkIgnorable) {
          // some stuff to detect public setter methods...
         // cxf-3.0.0: line1219 | cxf.3.0.1 line 1224
         String propertyName = methodName.substring(minLen).toLowerCase();
        // this propertyName is used as Parameter model name later on...
        params.put(new Parameter(type, propertyName), m.getReturnType());
      

      From my point of view the propertyName should not be lowercased here.

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            escheider Enrico Scheider
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: