cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Chicchiriccò <ilgro...@apache.org>
Subject WADL generation: linkJsonToXmlSchema & XMLName
Date Tue, 15 Oct 2013 12:07:27 GMT
Hi,
I am currently trying to enrich the WADL auto-generated by CXF 2.7.7 in 
Syncope.

I currently have these Spring beans defined:

   <bean id="wadlGenerator" 
class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
     <property name="applicationTitle" value="Apache Syncope 
${project.version}"/>
     <property name="namespacePrefix" value="syncope"/>
     <property name="linkJsonToXmlSchema" value="true"/>
     <property name="useJaxbContextForQnames" value="true"/>
     <property name="ignoreMessageWriters" value="true"/>
     <property name="addResourceAndMethodIds" value="true"/>
   </bean>

and

   <jaxrs:server id="restContainer" address="/" 
staticSubresourceResolution="true">
       <!-- snip -->
     <jaxrs:providers>
       <ref bean="jaxbProvider"/>
       <ref bean="jsonProvider"/>
       <ref bean="exceptionMapper"/>
       <ref bean="wadlGenerator"/>
     </jaxrs:providers>
   </jaxrs:server>

I am currently testing one of available services that now looks as 
follows (showing only a couple of methods for simplicity):

@Path("users")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public interface UserService {

     @GET
     @Path("{userId}")
     @Descriptions(
             @Description(target = DocTarget.METHOD, value = "Returns a 
single user matching the provided userId"))
     UserTO read(@PathParam("userId") Long userId);


     @GET
     @XMLName("{http://syncope.apache.org/1.1}users")
     List<UserTO> list();
}

Now, while the former becomes (in the WADL)

<method name="GET" id="read">
   <doc>Returns a single user matching the provided userId</doc>
   <request/>
   <response>
     <representation mediaType="application/xml" element="syncope1:user"/>
     <representation mediaType="application/json" element="syncope1:user"/>
   </response>
</method>

which is just fine, the latter is instead reported as

<method name="GET" id="list">
   <response>
     <representation mediaType="application/xml" element="syncope1:users"/>
     <representation mediaType="application/json" element="syncope1:user"/>
   </response>
</method>

As you can see, representation/@element is different between JSON and 
XML, e.g. for XML the value provided via @XMLName is used, while for 
JSON it is reported as if the return type was plain 'UserTO' instead of 
'List<UserTO>'.
Without @XMLName, element attribute is not even reported for XML.

Moreover, I would expect to find something in the <schema> section of 
the WADL for '{http://syncope.apache.org/1.1}users', as [1] seems to 
suggest.

Any clue?
TIA

Regards.

[1] 
http://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-RepresentingexplicitJAXBcollections

-- 
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


Mime
View raw message