cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guy Dumais (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (CXF-3135) WadlGenerator does not respect Consumes annotation
Date Mon, 22 Nov 2010 16:29:18 GMT

    [ https://issues.apache.org/jira/browse/CXF-3135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12934503#action_12934503
] 

Guy Dumais edited comment on CXF-3135 at 11/22/10 11:28 AM:
------------------------------------------------------------

Here is the example I was concerned with.  It seems that these two methods should generate
the same *mediaType attribute* in the request representation element but there are not:
{code}
@Service("wadlTest")
@Path("/resource")
@Description("Shouldn't these two cases give the same representation")
public class WadlTest {
	org.apache.cxf.jaxrs.model.wadl.WadlGenerator wadl;
	
	@POST
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	@Description("using MultiValuedMap gives application/x-www-form-urlencoded")
	public String postWithMultiValued(MultivaluedMap<String, String> formParams) {
		String stringParam = formParams.getFirst("stringParam");
		long longParam = Long.parseLong(formParams.getFirst("longParam"));
		return "{}";
	}
	
	@POST
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	@Description("using FormParam gives application/json")
	public String postWithFormParam(@FormParam("stringParam") String stringParam,
			@FormParam("longParam") long longParam) {
		return "{}";
	}
}
{code}
The generated WADL with CXF 2.2.9 is 
{code:xml}
<resource path="/resource">
      <doc>Shouldn't these two cases give the same representation</doc>
      <method name="POST">
            <doc>using MultiValuedMap gives application/x-www-form-urlencoded</doc>
            <request>
                  <representation mediaType="application/x-www-form-urlencoded"/>
            </request>
            <response>
                  <!-- Primitive type : xs:string -->
                  <representation mediaType="application/json"/>
            </response>
      </method>
      <method name="POST">
            <doc>using FormParam gives application/json</doc>
            <request>
                  <representation mediaType="application/json">
                        <param name="stringParam" style="query" type="xs:string"/>
                        <param name="longParam" style="query" type="xs:long"/>
                  </representation>
            </request>
            <response>
                  <!-- Primitive type : xs:string -->
                  <representation mediaType="application/json"/>
            </response>
      </method>
</resource>
{code}

      was (Author: guyd):
    Here is the example I was concerned with.  It seems that these two methods should generate
the same *request representation* element but there are not:
{code}
@Service("wadlTest")
@Path("/resource")
@Description("Shouldn't these two cases give the same representation")
public class WadlTest {
	org.apache.cxf.jaxrs.model.wadl.WadlGenerator wadl;
	
	@POST
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	@Description("using MultiValuedMap gives application/x-www-form-urlencoded")
	public String postWithMultiValued(MultivaluedMap<String, String> formParams) {
		String stringParam = formParams.getFirst("stringParam");
		long longParam = Long.parseLong(formParams.getFirst("longParam"));
		return "{}";
	}
	
	@POST
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	@Description("using FormParam gives application/json")
	public String postWithFormParam(@FormParam("stringParam") String stringParam,
			@FormParam("longParam") long longParam) {
		return "{}";
	}
}
{code}
The generated WADL with CXF 2.2.9 is 
{code:xml}
<resource path="/resource">
      <doc>Shouldn't these two cases give the same representation</doc>
      <method name="POST">
            <doc>using MultiValuedMap gives application/x-www-form-urlencoded</doc>
            <request>
                  <representation mediaType="application/x-www-form-urlencoded"/>
            </request>
            <response>
                  <!-- Primitive type : xs:string -->
                  <representation mediaType="application/json"/>
            </response>
      </method>
      <method name="POST">
            <doc>using FormParam gives application/json</doc>
            <request>
                  <representation mediaType="application/json">
                        <param name="stringParam" style="query" type="xs:string"/>
                        <param name="longParam" style="query" type="xs:long"/>
                  </representation>
            </request>
            <response>
                  <!-- Primitive type : xs:string -->
                  <representation mediaType="application/json"/>
            </response>
      </method>
</resource>
{code}
  
> WadlGenerator does not respect Consumes annotation
> --------------------------------------------------
>
>                 Key: CXF-3135
>                 URL: https://issues.apache.org/jira/browse/CXF-3135
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.3.0
>         Environment: any
>            Reporter: Guy Dumais
>            Priority: Minor
>
> {{WadlGenerator}} invokes {{handleRepresentation}} with the wrong parameter when creating
the {{<request>}} element.  The last parameter of {{handleRepresentation}} should be
_true_ not _false_:
> {code}
>  if (ori.getMethodToInvoke().getParameterTypes().length != 0) {
>             sb.append("<request>");
>             if (isFormRequest(ori)) {
>                 handleRepresentation(sb, jaxbTypes, qnameResolver, clsMap, ori, null,
false);
>             } else {
>                 for (Parameter p : ori.getParameters()) {        
>                     handleParameter(sb, jaxbTypes, qnameResolver, clsMap, ori, p);  
          
>                 }
>             }
>             sb.append("</request>");
>  }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message