users@jersey.java.net

[Jersey] WADL generation bug?

From: Mark Petrovic <mspetrovic_at_gmail.com>
Date: Sun, 6 Mar 2011 09:15:59 -0800

I feel like I must be missing something, but this hunk of WADL
generated by Jersey-1.5 (using curl http://blah/blah/application.wadl)
, and that represents a POST to a resource method

       <resource path="creditcards">
           <param xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="start" style="query" type="xs:int" default="0"/>
           <param xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="limit" style="query" type="xs:int" default="0"/>
           <resource path="{email}">
               <param xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="email" style="template" type="xs:string"/>
               <method id="addCreditCard" name="POST">
                   <request>
                       <representation
mediaType="application/x-www-form-urlencoded">
                           <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="accountnumber"
style="query" type="xs:string" default=""/>
                           <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="expiresyear"
style="query" type="xs:int" default="0"/>
                           <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="expiresmonth"
style="query" type="xs:int" default="0"/>
                           <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="cnpcode"
style="query" type="xs:int" default="-1"/>
                       </representation>
                   </request>
                   <response>
                       <representation mediaType="application/xml"/>
                       <representation mediaType="application/json"/>
                   </response>
               </method>
           </resource>
       </resource>

cannot be correctly parsed by the Nottingham WADL stylesheets. The
Form entity parameters (accountnumber, etc.) are missing from the html
representation the stylesheet is supposed to produce.

https://github.com/mnot/wadl_stylesheets

I assume the reason is that the Nottingham stylesheet conforms to this
W3C specfication for <method> definitions

http://www.w3.org/Submission/wadl/#x3-170002.8.2

Specifically, in the <request> element, <param>'s are not supposed to
be children of <representation>; they are peers of <representation>.
Both <param> and <representation> are supposed to be children of
<request>.

If I make this change where <representation> and <param>'s are peers,
and which I believe conforms to the W3C spec, the Nottingham
stylesheets work on the input:

                   <request>
                      <representation
mediaType="application/x-www-form-urlencoded"/>
                      <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="accountnumber"
style="query" type="xs:string" default=""/>
                      <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="expiresyear"
style="query" type="xs:int" default="0"/>
                      <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="expiresmonth"
style="query" type="xs:int" default="0"/>
                      <param
xmlns:xs="http://www.w3.org/2001/XMLSchema" name="cnpcode"
style="query" type="xs:int" default="-1"/>
                   </request>


Do I have this right?

--
Mark